Reputation: 19676
When I compile an Android project within Eclipse, it doesn't generate any Ant scripts or anything, so I assume it's using the Eclipse compiler to generate the .class files, and using dx
to translate those into .dex. So that's fine, and I'm aware that the Eclipse compiler is different from javac
and can't be changed.
But when I use android
to generate a build.xml
file, I see that it references other Ant files, and eventually I am able to track down the actual invocation to javac
. So I have a few questions about this.
<javac>
Ant command correspond to the javac
referenced by my JAVA_HOME
env variable? Or is it something else?build.xml
file and change the "compile" target?I don't really care that much what compiler I'm using, I'm just curious. The main thing I'm after is to make sure that I'm using a modern compiler and I can expect all the usual optimizations (e.g. the interning of string literals). Am I correct in assuming this?
P.S. Speaking of optimizations, does dx
do anything more fancy than simply translating one bytecode to another?
Upvotes: 2
Views: 4941
Reputation: 40357
With regard to your question about dx, it's not the end of the process. When the application is installed on the device, a lot of local lookups are done to create an optimized dex (ODEX) file unique to the run environment of that device.
Upvotes: 2
Reputation: 23873
To answer question 1, Yes it must be using the one referenced by JAVA_HOME. The evidence being: I can successfully build projects with Ant, my JAVA_HOME is set to c:\dev\tools\JDK6_20. My path includes c:\dev\tools\JDK6_20\bin.
I temporarily set JAVA_HOME to the non existant c:\dev\tools\JDK6_201. When I try an ANt build, I get:
BUILD FAILED C:\dev\projects\Eclipse\AndroidWorkspace\MapProject48\build.xml:390: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\dev\tools\JRE\6_20_64bit"
I don't know where it gets the last line from, I guess it must be my JRE as it appears in the registry.
I think that in answer to your bold question : the compiler is as modern as the javac in your JDK
Upvotes: 3
Reputation: 16038
I'm not 100% sure what you are getting at. However, Android uses a modified form of Java called Dalvik.
Dalvik is register based, which is better for mobile devices.
http://en.wikipedia.org/wiki/Dalvik_(software)
Upvotes: 1