Why -XDuseUnsharedTable=true compiler argument is passed automatically by default for JavaCompile type tasks


(Sarab Sandhu) #1

I am compiling my source code and i see that useUnsharedTable flag is set to true by default for my JavaCompile task. Here is command from my java-compiler-args.txt file

-source
1.5
-target
1.5
-d
E:\workspace\code\git\repos\WebServices\classes\java\main
-g:source,lines,vars
-sourcepath
""
-XDuseUnsharedTable=true
-classpath

I have tried to set to this compiler argument to false by using

options.compilerArgs += ["-XDuseUnsharedTable=false"]

but new compiler argument is added as additional compiler argument to javac. Previous one is not overridden with new value. Does anyone know how can i remove this argument from javaCompile task arguments? What this compiler argument mean?


(James Justinic) #2

It’s an internal option for JDK 1.7+ that prevents the compiler from sharing a table that will never be reused. When shared, it can’t be garbage collected, continues to accumulate data, and therefore wastes memory.

Why would you want to remove it (especially if you didn’t know what it meant)? Removing it will only waste memory on Java 7/8 without any benefit.


(Sarab Sandhu) #3

Thank you for your reply James. To answer your question, I am migrating legacy project to gradle. Class files compiled from java source code with ant and gradle differ on binary level. When I am using JAD decompiler ( and javap ) to decompile classes from two different outputs (ant and gradle) , i see some optimizations being done on gradle end. Specific example is importing more specific classes on gradle end instead of * operator on ant end to import all classes in packages. Other example is moving declaration of variables to outer scope on gradle end. ANT does not touch anything in source code in decompiler output. I just want to turn off these optimizations on gradle end. I am not sure what is causing these optimizations. If I get same output on both ends, I will feel more comfortable on migration. Let me know you know anything about turning off optimizations being done in gradle java plugin