Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Bob Winter

Ranch Hand
+ Follow
since Apr 18, 2020
Cows and Likes
Cows
Total received
6
In last 30 days
0
Total given
0
Likes
Total received
31
Received in last 30 days
0
Total given
17
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bob Winter

Aside from what Les Morgan already stated, Oracle took over some time between Java6 and Java7 - I remember that Java6 was still from Sun and even the very first early access version for Java7 came from Oracle. So, a lot has changed between those two versions.
As for "anything newer than Java8": Project Jigsaw in fact did broke a lot of stuff, but I honestly don't know for how long its JSR was already around to it got finally implemented. So the overall transition from Java8 and anything older to Java9 or anything newer can have the issue of breaking at all places.
As for Sun/Oracle vs openJDK: One has to keep this in mind: The language itself and its sepcification were always opensource and public and anyone could implement their own VM - in fact, Microsoft did it, IBM still does it today, and there were a couple of others over the decades. I can't remember the exact point in time and version - but if memory serves correctly on this one, at some point I started reading this line: "OpenJDK is the official reference implementation". So, by this line, unless you use some features specific to the VM vendor and version you currently use your code should run accross all VMs, at least of the same major version.

This brings me back around to ask: "What broke?". I guess there wasn't just the magic "it didn't worked no more" but actually a lot of exception stacktraces and such one sure could had at least tried to figure out what exactly gone wrong. Same for the "oh, uhm, yea, Oracle VM won'T work": There has to be some very specific uses of code one shouldn't use to create that specific dependency. So, to add to your "a java dev learns from the get go": Never use anything beyond the limits of the SE API like sun.* com.sun.* and such. The million dollar question starts when you do comply to this but it still breaks due to implementation specific differences.

So, thanks for sharing the story, but, at least for me and please, don't feel offended by it, in this way it doesn't really have any value. It would had been interesting to dive into the code and stacktraces to see were it breaks to analyse what's causing it. Just "yea, broke when migrated from 8 to 9 / oracle <-> open" is, at least to me, a bit like: "yea, heared it too much - can'T take it anymore".
Don'T get me wrong - sure, this has to be addressed within the community to either stick to the mantra - or get rid of it as it doesn't seem to get followed anymore. Yes, something marked as deprecated always had the line "may get removed in future versions" - but never actually really did before Java9. So something for sure has changed. And who knows, maybe we all stuck in limbo like about any database example still uses Class.forName although JDBC4 and ServiceLoader is around since Java7 back from 2010.
1 month ago
I did some digging into a src.zip from a jdk8. The resolving of the "path" (or url rather) comes down to some nested class within some sun.misc class which tries to URL.openConnection().getInputStream() and returns null upon IOException. As a directory can't have an InputStream my best guess is that at some internal C code of the VM itself some syscall to something like openFile(".") is made - this fails - causes a ripple of exceptions to bubble back up and ends in the try-catch to return null when the give String points to a directory. This at least explains why "." and ".." return null. As for why the last call returns null: Somewhere in the stack a replace(".","/") is done so "../res/file" becomes "///res/file" which in the end results in a wrong absolute path which causes the aforementioned stack to return null again.
So, my guess is: Class.getResource() isn't really meant to be able to get the current or even the parent directory but to only proceed further down from the current one, at least when try to use relative paths instead of absolute ones.
1 month ago
Although not as helpful, but thanks for crunching through the wall of text and reply anyway.
1 month ago
Just another imformative explanation from you Tim, really impressive.
I hearing this "high-level ASM" for the first time as I always thought that C is already classified as a "high level abstract" and to some degree machine independent language. I guess I'm way to used to Java as it's basically the only language I'm using for the past 15 years.
I also already tried to search up about creating dynamic libraries that can be loaded at runtime, but from what I found how to actually design them differs vastly between writing something for the windows platform or some linux distribution and that even to maintain source-code level compatibility one has to stuff a lot of pre-processor stuff in a source file so at the time the compilers pre-processor runs over it the result somewhat automagically (yes, spelling intended) comes out as something that only consist of platform specific source which then gets compiled - very confusing.
Luckly what I want to implement doesn't seem all that complicated (although I still wonder if it may be possible to cross-compile a windows binary on a linux system as I don'T really want to clutter up my system of several gigabytes of dev stuff just to compile a few lines into a small lib) but still maybe up for some topic on its own:
As Java offers the JNI which also allows full-duplex bi-directional communication I'd like to (if possible) implement a small lib which just takes the string given by the main application - calls some java code to process it - and sends back the result. But, from as far as I already read up: just connecting two applications by a single lib doesn't seem to be that easy straight forward possible as I hope to as the pointer only stored in the memory spaces of the respective processes. One of the techniques to get around this seem to be things like unix domain sockets, regular ip sockets and even memory mapped files and using some sort of os level event bus system to signal the other program that there new data in the memory to process - isn't there a simpler way?
I also once watched a video on youtube showing the very basics of whats actually inside the java bootstrap binary - and I guess this can also be done within the lib loaded by the main application (so it basically runs a VM inside its process sapce). That would be cool by me as I then still can develop my logic in java and just have it run by the vm created by the main application instead of its own instance.
One may see from as how my text turns into getting harder and harder to read I'm getting more and more confused as on how to get started.

Maybe, for anyone still with me and may willing to give me a help in the right direction, I shall give you some more specific information about what I want to implement:

As I currently working on design a modification for the game Arma3 I face the challenge to implement some way to connect to a database. The current way is to use a lib known as "extDB3". It's basically a wrapper for the mysql-connector/c connecting it with the game using its "extension" api: https://community.bistudio.com/wiki/Extensions
They way this is currently achieved seem to be this:
The developer of the extDB3 lib provides two modes of operation: raw SQL and prepared statements defined via an INI loaded at first time the lib gets initialized. As the extension api of arma3 has a limit on about how much data can be send back from the extension to the game engine (currently about 10kB) there can be results bigger than this which has to be transfered in several consecutive calls to the extension. To make this possible the extDB3 extension buffers the result it gets from the database in what looks like a map along with an id which gets returned upon the initial a-synchronous request and it's up to the arma3 code to keep polling for the data until an empty string is returned to mark the end (I guess that's one example of unknown length at runtime which justify an explicit length/size information).

The main issue I currently face is that most of the code I have to deal with is already several years old (the extDB3 lib was last modified back in 2017 and the base for my own new mission is from about 2014-2017) - and in the mean time the arma3 game engine has evolved so my goal is a complete rewrite to take a) advantage of all the new features and b) make it as performant as possible as the current version really shows how slow it all is when you have more than just a few players interacting with each other and the world which, although extDB3 is pooled and multi-threaded, can add up to some lagg as the main game engine itself (and its multiplayer server) is just one big single threaded mess.
To release the main server instance of it's heavy load the arma3 game provides what they call "headless clients". It's basically just another game client but without the graphical overhead - just the logic itself. The benefit one can get from this is to offload lot'S of work from the main server instance to these headless client instances. This way I managed to get down the overall system usage of one single server instance of about 85% to just about 30% with a second client insatnce with about 20%. Not just I got down the usage but also can now take advantage of the two physical cpus the server has to split of the load between them. My goal with all the rewrite of the game mission and the extension and the database stuff is to maybe split the workload even further to take more advantage of the available system resources (2 quad core cpus) and to hopefully increase the performance even if the server fills up with players (currently I set a max of about 175 players - which the engine in fact do can handle (seen it other servers with 150+ players at the same time - as the staff also had a lot of work done on their own it was quite performant)).

Why do I post this hear instead of the game forum? Well, the way I see it this is a programming "problem" which is best solved in a programmers forum. The game forum for arma3 doesn'T go that deep into programming but only into using the provided tools with the game - which ends about the point where a call is made from the game to the extension. So I doubt I can expect much help over there.

To summarize: What I'm looking for is a way to either connect another process with my own JVM via a dynamic library - or, if that'S not possible, how to start up and run a JVM within the space of another programm by implement its startup code in said dynamic library - to, in the end, be able to develop my extension in java and only use the C lib as communication binding as the arma3 game engine only provides this one option to talk to external code.

Any help and advise are appreciated. Thanks in advance.
1 month ago
Hello there,

first of all: I'd like to apologize as I think this topic has been covered enough. I tried to search it up via Google, and got SOME results - but none that really satisfied me. So, if you know some additional references please feel free  to link me to them instead of repeating - it's just something I want to learn about as I seem not to get my head around it.

As I started my "career" into hobbyist programming by some HTML/JavaScript executed in the local browser, then moved along to some PHP and finally ended up stuck to Java for over a decade now, I never had to deal with explicitly providing lengths of fields or data structures - and thank got no allocating or releasing memory or pointer arithmetics. All the languages I used till today do this internally.
But as I currently working on some project actually require me to use some C/++/# I got really confused by the "interface" some "extension" has to provide. It has in its most basic variant three parameters: an output-pointer, some input, and the maximum allowed size for the output-pointer (I'm sorry if I use some terms wrong here - I'm not used to them.). Aside from that really weird order (I would had understand it a lot better if the output buffer and its max length are follow eachother.) why is there a requirement for passing such explicit length/size parameter along in the first place?
Along with that, in the examples, there're a lot of other places where several sizes of input and output buffered are passed along. Not just for strings, which in C are \0 terminated, but for all sorts of things (mostly for those "struct" things - I only understand them this far as they're what I would call a class in java).

My maybe not so simple question is: WHY?
Is C that old that back in the day it was just "cheaper" to pass along a size/length than have it somewhere stored or even computed/checked? I'm so confused by this style of programming it somewhat got me scared - let alone all that stuff possible with all that pointer-arithmetic stuff and all those buffer overflows/underruns. I'm just so used to Java and it does all that for me.
1 month ago
@Tim
Very informative explanation. Thank you sir.
1 month ago

Ron McLeod wrote:Maybe Updating a JAR File is a more common name for the process of modifying the contents of a jar file?


Well, that would be something I would use - at least rather than "patching" a jar.
As said: I don't know much about the other person - only he's rather young but from what I've seen rather talented (compared to me at that age when I just got a dev book about java in my hands for the first time). He used this term for modifying the main game jar of minecraft to alter some launch behaviour which the game itself doesn't do the way he wants to - and referred to that modifying as "patching the main jar of MC".
As for using "update a jar" - well, aside from that's the term when using the jar tool to tinker with those files, I would use that term while developing and actually updating the jar with a new class I just modified and recompiled. As said: I suspect he just used 7zip or winrar (as a jar is in fact just a zip file) instead of jar or some gui provided by some gui - so, in respect to what Paul suggested, I guess it fits that he used that term - as he "cheesy low-level modified the game".
Anyway, nevermind, thanks for the input.
1 month ago
So, one may can guess from the topic: I came accross the term "patching a jar" in a conversation. As I myself never heared or used that term to describe a modification of a jar I replied: "nah, not the term used in Java conventions" - but got the reply "yes, it is". As I don't want to start an argue with the other person (although I neither don't know him long nor well) I do respect him and his work he pulled off in a short amount of time. So, maybe it's just me not used to that term or its use in that case - hence I'm asking here:

Does anyone of you use the term "to patch a jar" when it's about modifying it's content (with most likely something like 7zip or winrar, I guess?)?

I would had just used the term: "I had to modify the jar" or something similar - but "patching a jar" - first time I ever heared it used this way.
Any suggestions?
1 month ago

debs mahap wrote:hello,
can someone please tell me what is the difference between  JAVA and JS ( Java script  ) ?


although not quite correct nor helpful - it's often easier to answer the question: what have Java and JavaScript in common? practical nothing aside from the name - and that JavaSript even got that name (before it was named ActionScript) was caused by it was a) inspired by it b) was a try to implement the java programming language as a scripting language into the browsers and c) in later time when java got its applets because both had a way of direct bi-directional communication.
So, to answer "what's the difference between them": basically anything but the name as it came from the now implied relation between them.
1 month ago

Campbell Ritchie wrote:I don't know why anybody bothers with floats at all. Unless some other code requires a float.


It always bothered me since I learned about floating point numbers in java: what is a legitimate use case for a float when javas base datatype is always a double in the first place?
From what I know when one declares a "float" like 0.0 it's a double right away - one doesn't have to the d suffix. Only when someone explicitly wants to assign a float the f suffix has to be appended: 0.0f
What would a reason for me to design some code require float at all?
1 month ago

John Knox wrote:Currently we stored the file image in the server as CLOB.


That doesn'T sound right - C-LOB is for Character Large OBject - storing an image should be done in a B-LOB - a Binary Large OBject ...
1 month ago
although I don't know anything about the topic I just clicked on it out of curiosity what's it about
unfortunately it's one of those posts hard to read - especially on mobile devices with small screens:

a) coderanch supports the BBCode standard - which one part of it is the code-tag
it also supports common languages like java, c/++ and even c# - this makes it way easier to read code as it gets formatted properly and also syntax highlightet - a moderator may correct it this time for you
b) although images often do help in situations were "it's useful to see what you see", but I don't see it helps on your topic as you just show us some IDE stuff but the issue you described happens outside of the IDE
c) "it does not work" is not a very helpful way of describing the issue - it often helps better if you describe what you expect to happen, what does actually happen, and maybe post some error log you get

as for the issue itself:
do you have any debug-log in your programm? have you tried it running from the commandline instead of double-click on the short cut? does your installer make sure the privileges are set correctly or to place specific files in specific places? does your code has any fail-fast lines in it where it just exists the programm in case if anything fails?

from what I see: you have an empty catch-block:

I can only say from java: never ever do this - what you'Re doing here is you hide any error message that could be printed to log - in java there's Throwable.printStackTrace - in C# it seem to be this:

this way you'll get at least a log output why it failed (I predict some privilege issue here)

//edit - fixed code tag
1 month ago

Zachary Griggs wrote://truncated to avoid full post quote


Although the topic is solved there're several issues to address:
1) As the error message was not "could not find main class" but a classdefnotfound of a dependency the issue was obviously not caused by a missing main-class manifest attribut - so, why even mentoined it? Did you read and understood the problem? Or did you may only jzst copied in some pre-written default text of maybe many?

2) Although building a fat jar often at least "make things work" it's far from an ideal solution. Aside from possible conflicts it can be compared to keep swallow painkillers instead of taking proper meds to cure: you're just tinkering with the symptoms instead of fixing the cause.

3)

This is the easiest and most consistent way to create jar files.


Uhm, no, it isn't. It's neither easy nor consistent and hence shouldn't be seen or used as such.
If you have an external lib within it's own jar don't mess with it but rather correctly reference it in the classpath.
Btw: This may work for a hobbyist dev - but most often licenses deny abusing their covered code that way on distribution. You just can't ship a big fat jar couple 100mb in size.
1 month ago