[fpc-devel] JVM: Question regarding converted Java code

Sven Barth pascaldragon at googlemail.com
Wed Dec 28 23:28:51 CET 2011


Hello Jonas!

Today I've converted a third party jar file using javapp, which went 
without problems so far (I only need to convert another jar file, 
because there is a dependency).
When compiling I noticed a few warnings though:

=== output ===

...
bukkit.inc(1668,5) Warning: Constructor should be public
bukkit.inc(1669,5) Warning: Constructor should be public
bukkit.inc(1749,14) Warning: An inherited method is hidden by "procedure 
clone:OBLocation;"
bukkit.inc(1751,14) Warning: An inherited method is hidden by "procedure 
clone:JLObject;"
bukkit.inc(2006,5) Warning: Constructor should be public
bukkit.inc(2007,5) Warning: Constructor should be public
bukkit.inc(2046,14) Warning: An inherited method is hidden by "procedure 
next:JLObject;"
...

=== output ===

1) as it seems to be a rather usual practice in Java, would it be 
possible to disable the "Constructor should be public" warnings if the 
target cpu is the JVM?
2) in the code I converted the classes often seem to "reintroduce" 
methods that are available in parent classes or implemented interfaces 
with different result types without declaring the original method though.

E.g.:

=== Java source begin ===

public class Location implements Cloneable {

     ...

     @Override
     public Location clone() {
         ....
     }

     ...

}

=== Java source end ===

is converted to

=== Pascal source begin ===

   OBLocation = class external 'org.bukkit' name 'Location' (JLObject, 
JLCloneable)
   public
     ...
     function clone(): OBLocation; overload; virtual;
     ... // <= other functions between
     function clone(): JLObject; overload; virtual;  // throws 
java.lang.CloneNotSupportedException
   end;

=== Pascal source end ===

Is this indeed correct? Does the compiler (or the JVM) indeed call the 
correct function in the end (in this case org.bukkit.Location.clone)?

[I have not tested what the compiler or the JVM does, I'm just curious 
at the moment regarding the warnings I get]

Regards,
Sven



More information about the fpc-devel mailing list