Java 10 - side effect

Daestrum

Expert
Licensed User
Longtime User
Just a quickie post that may be of interest to some people.

I have found that if I compile from the B4J IDE using java 10, I have not found a decompiler (so far) that is able to reproduce the source from the jar, if I add any inline code (even code that does not get executed).

Example, adding the following code upsets the decompiler (it lists the class contents as null).
B4X:
public static void dontDecompileMe(){
       var temp = "hello";     // java 10 allows var  (it's like Object but knows what it is).
}

But the resultant jar runs fine.

Please note. The IDE cannot use the above code as is, as it relies on java source level 10, and will generate an error about source > 1.8. you need to intercept the compile and change the source & target to 10.
 

Daestrum

Expert
Licensed User
Longtime User
Dammit - found one lol.
Oh well it was good while it lasted.

As regard to first post (now I can see what it did)
The compiler actually compiled
B4X:
public static void whatever(){
     var v = "hello";
}
to
B4X:
public static void whatever(){
     String v = "hello";
}

I am gonna get sooooo lazy now lol.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…