Building langtools on MacOS fails with ClassReader.java:911: reference to Version is ambiguous

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Dec 9 05:26:01 PST 2010


Hi Jacek,
I think you just ran into one of the most painful JDK_related problems 
on MacOS. The problem is that in almost all distro the library tools.jar 
is _not_ included in the compiler bootclasspath (meaning that the 
compiler won't 'see' by default the classes in this jarfile, among which 
you can find all the compiler classes and, as such also ClassReader). On 
MacOS, tools.jar is typically added in bootclasspath, which means you 
can get weird failures when hacking the compiler, as you have two 
versions of the same class accessible on the classpath.

In this particular case, it seems like JDK 6 has 
com.sun.toools.javac.util.Version, while, on the other hand, neither 
6-open nor 7 do  have such toplevel class.

A simple way out would be to address the problem in the problematic 
source; if the compiler is complaining about an ambiguity, you could 
resort to fully qualified name (or, perhaps, removing star imports) in 
order to get rid of the error message.

Those little changes should allow you to get your build up and running.

Please keep me posted on how this works out for you; if you could come 
up with a patch to ClassReader.java that would allow to build under 
MacOS, I don't see why we shouldn't include that patch as part of the 
'official' repo (provided that changes are sufficiently local).

Thanks
Maurizio



On 08/12/10 21:49, Jacek Laskowski wrote:
> Hi,
>
> After having installed the latest build of OpenJDK 1.7 for Mac OS X
> [1], I've been trying to build langtools as described in [2]. It
> failed with the following errors. It's today's hg clone and Apache Ant
> version 1.8.1. What am I doing wrong?
>
> jacek:~/oss/lambda-langtools/make
> $ ant -Dboot.java.home=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
> -Dtarget.java.home=/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home
> build-all-tools
> Buildfile: /Users/jacek/oss/lambda-langtools/make/build.xml
>
> -def-pcompile:
>
> -def-build-classes:
>
> -def-build-bootstrap-classes:
>
> -def-build-jar:
>
> -def-build-bootstrap-jar:
>
> -def-check:
>
> -check-boot.java.home:
>
> -def-build-tool:
>
> -def-build-bootstrap-tool:
>
> build-bootstrap-javac:
>      [javac] Compiling 297 source files to
> /Users/jacek/oss/lambda-langtools/build/bootstrap/classes
>      [javac] /Users/jacek/oss/lambda-langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java:911:
> reference to Version is ambiguous, both class
> com.sun.tools.javac.jvm.ClassFile.Version in
> com.sun.tools.javac.jvm.ClassFile and class
> com.sun.tools.javac.util.Version in com.sun.tools.javac.util match
>      [javac]         AttributeReader(Name name, Version version,
> Set<AttributeKind>  kinds) {
>      [javac]                                    ^
>      [javac] /Users/jacek/oss/lambda-langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java:924:
> reference to Version is ambiguous, both class
> com.sun.tools.javac.jvm.ClassFile.Version in
> com.sun.tools.javac.jvm.ClassFile and class
> com.sun.tools.javac.util.Version in com.sun.tools.javac.util match
>      [javac]         final Version version;
>      [javac]               ^
>      [javac] 2 errors
>
> BUILD FAILED
> /Users/jacek/oss/lambda-langtools/make/build.xml:413: The following
> error occurred while executing this line:
> /Users/jacek/oss/lambda-langtools/make/build.xml:777: Compile failed;
> see the compiler error output for details.
>
> Total time: 4 seconds
>
> [1] http://code.google.com/p/openjdk-osx-build/
> [2] http://mail.openjdk.java.net/pipermail/lambda-dev/2010-August/002179.html
>
> Jacek
>
>    



More information about the lambda-dev mailing list