Skip to main content

Problem building Squawk with OpenJDK 6

5 replies [Last post]
cosmincojocar
Offline
Joined: 2009-09-24
Points: 0

Hello everybody,

I'm trying to build the Squawk VM under Ubuntu 9.04 with OpenJDK 6 but I get the following errors in vm2c:

[building vm2c...]
vm2c/preprocessed/com/sun/squawk/vm2c/Main.java:30: warning: sun.misc.URLClassPath is Sun proprietary API and may be removed in a future release
import sun.misc.URLClassPath;
^
vm2c/preprocessed/com/sun/squawk/vm2c/Converter.java:874: cannot find symbol
symbol : variable tag
location: class com.sun.tools.javac.tree.JCTree
switch (tree.tag) {
^
vm2c/preprocessed/com/sun/squawk/vm2c/MethodConverter.java:432: cannot find symbol
symbol : variable tag
location: class com.sun.tools.javac.tree.JCTree.JCExpression
if (tree.cond.tag == JCTree.PARENS) {
^
vm2c/preprocessed/com/sun/squawk/vm2c/MethodConverter.java:444: cannot find symbol
symbol : variable tag
location: class com.sun.tools.javac.tree.JCTree.JCExpression
if (tree.cond.tag == JCTree.PARENS) {
^
.
.
.

vm2c/preprocessed/com/sun/squawk/vm2c/Main.java:156: warning: sun.misc.URLClassPath is Sun proprietary API and may be removed in a future release
URLClassPath sourcePath = new URLClassPath(URLClassPath.pathToURLs(sourcePathArg));
^
vm2c/preprocessed/com/sun/squawk/vm2c/Main.java:156: warning: sun.misc.URLClassPath is Sun proprietary API and may be removed in a future release
URLClassPath sourcePath = new URLClassPath(URLClassPath.pathToURLs(sourcePathArg));
^
vm2c/preprocessed/com/sun/squawk/vm2c/Main.java:156: warning: sun.misc.URLClassPath is Sun proprietary API and may be removed in a future release
URLClassPath sourcePath = new URLClassPath(URLClassPath.pathToURLs(sourcePathArg));
^

I have the latest revision (458). What is missing? Please could you help me?

Thanks,
- Cosmin

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fraybentos
Offline
Joined: 2007-11-16
Points: 0

The problem is that Vm2c uses unsupported compiler APIs that can and do change between JDK releases. Access to tag is through getTag() in OpenJDK6, whereas tag is accessed directly in JDK6.

There are two fixes to this problem, the first is to change all references to tag to getTag(). The second is to use JDK6.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Maybe we should add some conditional compilation to handle this?

Is there a property somewhere we can use to easily determine which Java we are using?

I dont know how many people use OpenJDK 6 over JDK 6.

cosmincojocar
Offline
Joined: 2009-09-24
Points: 0

Thanks for help. Here's a method to detect which SDK is running.

boolean isOpenJDK() {
boolean isOpenJDKActive = false;
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec("java -version");
p.waitFor();
InputStream processInputStream = p.getErrorStream();
InputStreamReader inputStreamReader = new InputStreamReader(processInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
isOpenJDKActive = line.contains("OpenJDK");
if (isOpenJDKActive)
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return isOpenJDKActive;
}

Using it a compatible MethodConverter class could be chosen for each JDK through a factory pattern. I can provide you a fix if you agree this approach.

-Cosmin

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Thank you for the code snippet.

Be on the lookout very shortly for a fix to this. I think I've found a way to make vm2c build on version 5 and 6 of JDK or OpenJDK. Will report when I've done and tested the fix I am working on.

The basic idea is taken from NB, it turns out NB has the same issue. So they have included a version of javac within NB itself which is independent of the JDK installed. I saw it by accident when I saw the output from a build script that used a jar that was named with the jdk tools.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

As an FYI the jar is/was openjdk-javac-6-b12. Gave me a pretty good hint as to what was going on, especially with the problems I was having :)