Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 436636 - sys-devel/gcc-{4.5,4.6,4.7?}: gcj fails to compile java source code on ia64 (hardened) - Exception in thread "main" java.lang.ClassFormatError: org.eclipse.jdt.internal.compiler.batch.Main (Premature end of data)
Summary: sys-devel/gcc-{4.5,4.6,4.7?}: gcj fails to compile java source code on ia64 (...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Java (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-30 10:20 UTC by Dennis Schridde
Modified: 2015-07-11 11:05 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log and emerge --info (build.log,7.19 KB, text/plain)
2012-09-30 10:20 UTC, Dennis Schridde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Schridde 2012-09-30 10:20:28 UTC
dev-java/ecj-gcj-3.6 fails to build on my ia64 system:

bootstrapping ecj with /usr/ia64-unknown-linux-gnu/gcc-bin/4.6.3/gcj -C --encoding=ISO-8859-1 ...
Exception in thread "main" java.lang.ClassFormatError: org.eclipse.jdt.internal.compiler.batch.Main (Premature end of data)
   at java.lang.VMClassLoader.defineClass(libgcj.so.12)
   at java.lang.ClassLoader.defineClass(libgcj.so.12)
   at java.security.SecureClassLoader.defineClass(libgcj.so.12)
   at java.net.URLClassLoader.findClass(libgcj.so.12)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.VMClassLoader.defineClass(libgcj.so.12)
   at java.lang.ClassLoader.defineClass(libgcj.so.12)
   at java.security.SecureClassLoader.defineClass(libgcj.so.12)
   at java.net.URLClassLoader.findClass(libgcj.so.12)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at gnu.java.lang.MainThread.run(libgcj.so.12)

The same happens with gcj from sys-devel/gcc-4.6.3.
emerge --info and build.log attached.

Reproducible: Always
Comment 1 Dennis Schridde 2012-09-30 10:20:56 UTC
Created attachment 325362 [details]
build.log and emerge --info
Comment 2 Dennis Schridde 2012-09-30 10:26:19 UTC
Same results for dev-java/ecj-gcj-3.5.2-r2 and sys-devel/gcc-4.5.3-r2. I had that version compiled on 20101202 (still have a binpkg), so the issue did not exist back then.
Comment 3 Dennis Schridde 2012-09-30 10:33:11 UTC
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/libexec", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/libexec/gcc", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/libexec/gcc/ia64-unknown-linux-gnu", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/libexec/gcc/ia64-unknown-linux-gnu/4.5.3", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/libexec/gcc/ia64-unknown-linux-gnu/4.5.3/ecj1", {st_mode=S_IFREG|0755, st_size=7656, ...}) = 0
munmap(0x20000000003dc000, 8200)        = 0
munmap(0x20000000003e0000, 8200)        = 0
access("/usr/libexec/gcc/ia64-unknown-linux-gnu/4.5.3/ecj1", X_OK) = 0
clone(child_stack=0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 31250
wait4(31250, Exception in thread "main" java.lang.ClassFormatError: org.eclipse.jdt.internal.compiler.batch.Main (Premature end of data)

Could it be, that gcj tries to use ecj to build, but that does not yet exist, because we are just builting the package?
Comment 4 Dennis Schridde 2012-09-30 10:47:22 UTC
/usr/libexec/gcc/ia64-unknown-linux-gnu/4.5.3/ecj1 specifies a classpath (seen in the output of strings) pointing to /usr/share/gcc-data/ia64-unknown-linux-gnu/4.5.3/java/ecj.jar. I looked into that file for the class gcj complained about:
# ll org/eclipse/jdt/internal/compiler/batch/Main.class
-rw-r--r-- 1 root root 60743 Sep 11  2009 org/eclipse/jdt/internal/compiler/batch/Main.class
# file org/eclipse/jdt/internal/compiler/batch/Main.class
org/eclipse/jdt/internal/compiler/batch/Main.class: compiled Java class data, version 46.0 (Java 1.2)

I then tried to execute that class on another (x86) computer, and it worked:

$ java org/eclipse/jdt/internal/compiler/batch/Main                                                                         
Eclipse Java Compiler 0.972_R35x, 3.5.1 release
Copyright IBM Corp 2000, 2009. All rights reserved.

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.4) (6b24-1.11.4-1ubuntu0.12.04.1)
OpenJDK Server VM (build 20.0-b12, mixed mode)

No idea what that means. Maybe gcj is broken and cannot load classes at all? Or the ecj.jar is broken in some weird way that only becomes visible on my ia64 machine?
Comment 5 Ralph Sennhauser (RETIRED) gentoo-dev 2012-10-11 09:00:17 UTC
ecj-gcj is basically eclipse-ecj minus the bits that wont compile using gcj. The main purpose is having a "javac" ebuild that doesn't depend on a jdk.

gcj internally bundles/reuses ecj but that has nothing to do with the ecj-gcj ebuild. From the looks of it gcj is broken on ia64.

java.lang.ClassFormatError means either the class files don't adhere to the vm spec or the verifier code is broken/segfaults/whatever. From your comments it seems more likely to be the latter.

Please try to compile HelloWorld using gcj -C and report back.
Comment 6 Dennis Schridde 2012-10-13 16:22:24 UTC
(In reply to comment #5)
> Please try to compile HelloWorld using gcj -C and report back.

# cat helloworld.java 
class HelloWorld {
        public static void main(String []args) {
                System.out.println("Hello World");
        }
}
# gcj --version | head -n1
gcj (Gentoo Hardened 4.5.3-r2 p1.6, pie-0.4.7) 4.5.3
# gcj -C helloworld.java 
Exception in thread "main" java.lang.ClassFormatError: org.eclipse.jdt.internal.compiler.batch.Main (Premature end of data)
   at java.lang.VMClassLoader.defineClass(libgcj.so.12)
   at java.lang.ClassLoader.defineClass(libgcj.so.12)
   at java.security.SecureClassLoader.defineClass(libgcj.so.12)
   at java.net.URLClassLoader.findClass(libgcj.so.12)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.VMClassLoader.defineClass(libgcj.so.12)
   at java.lang.ClassLoader.defineClass(libgcj.so.12)
   at java.security.SecureClassLoader.defineClass(libgcj.so.12)
   at java.net.URLClassLoader.findClass(libgcj.so.12)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at gnu.java.lang.MainThread.run(libgcj.so.12)

# gcj-4.6.3 --version
gcj-4.6.3 (Gentoo Hardened 4.6.3 p1.7, pie-0.5.2) 4.6.3
# gcj-4.6.3 -C helloworld.java 
Exception in thread "main" java.lang.ClassFormatError: org.eclipse.jdt.internal.compiler.batch.Main (Premature end of data)
   at java.lang.VMClassLoader.defineClass(libgcj.so.12)
   at java.lang.ClassLoader.defineClass(libgcj.so.12)
   at java.security.SecureClassLoader.defineClass(libgcj.so.12)
   at java.net.URLClassLoader.findClass(libgcj.so.12)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.VMClassLoader.defineClass(libgcj.so.12)
   at java.lang.ClassLoader.defineClass(libgcj.so.12)
   at java.security.SecureClassLoader.defineClass(libgcj.so.12)
   at java.net.URLClassLoader.findClass(libgcj.so.12)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at java.lang.ClassLoader.loadClass(libgcj.so.12)
   at gnu.java.lang.MainThread.run(libgcj.so.12)


On an **x86-64** machine this code compiles and runs cleanly:
# gcj --version | head -n1
gcj (Gentoo 4.7.2 p1.0, pie-0.5.3) 4.7.2
# java -version
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (Gentoo build 1.7.0_07-b30)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
Comment 7 Ralph Sennhauser (RETIRED) gentoo-dev 2012-12-14 07:48:00 UTC
Thanks for the detailed answer. Assigning to toolchain.
Comment 8 Ralph Sennhauser (RETIRED) gentoo-dev 2012-12-14 08:15:05 UTC
bug 389763 is probably related, this time x86 tho. As if something goes wrong with linking on non amd64 platforms.
Comment 9 Dennis Schridde 2013-04-05 17:11:38 UTC
Out of a sudden this works:
# gcj --version
gcj (Gentoo Hardened 4.6.3 p1.11, pie-0.5.2) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# gcj -C helloworld.java 

gcj-jdk (and thus ecj-gcj) compiled without problems.
Comment 10 Dennis Schridde 2013-04-05 17:12:19 UTC
P.S: If someone else is able to reproduce this (i.e. the fact that it works now), I think we can close it.
Comment 11 James Le Cuirot gentoo-dev 2015-07-11 11:05:46 UTC
Closing this as fixed since Dennis says it works and we just dropped java on ia64 anyway.