johan-kjolhede-magine / jarjar

Automatically exported from code.google.com/p/jarjar
0 stars 0 forks source link

Missing class when using jarjar with Java6 bytecode #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Checkout Guice trunk (http://google-guice.googlecode.com/svn/trunk)
2. Install latest Java6 JDK
(http://java.sun.com/javase/downloads/ea/6u10/6u10rcDownload.jsp#6u10JDKs)
3. build Guice jar with Java6 (ant clean jar)

What is the expected output? What do you see instead?

 The final Guice jar should include the CGLIB Enhancer class, but it
doesn't. This means that the tests (ant test.dist) almost all fail.

What version of the product are you using? On what operating system?

 jarjar-1.0rc8.jar on Windows

Please provide any additional information below.

 When targeting Java5 bytecode (ant.build.javac.target=1.5) the jar does
contain the CGLIB Enhancer class as expected.

Original issue reported on code.google.com by mccu...@gmail.com on 15 Oct 2008 at 3:46

GoogleCodeExporter commented 8 years ago
I've tried with guice trunk (r803) and JDK 6u11 and I cannot reproduce the 
problem 
even after changing source and target in common.xml to "1.6". What am I missing?

Original comment by chris.no...@gmail.com on 11 Jan 2009 at 6:38

GoogleCodeExporter commented 8 years ago
Interesting, I can reproduce the problem with r628 (the version back in 
October) but
as you say the problem doesn't occur with the latest Guice trunk - even when 
you set
the target to 1.6

Original comment by mccu...@gmail.com on 11 Jan 2009 at 6:57

GoogleCodeExporter commented 8 years ago
A similar issue is occured on my desktop.
I've tried to build jarjar.jar itself from the latest source(r127).

# ant -Dcompile.target=1.6
...snip

BUILD SUCCESSFUL

# jar tvf dist/jarjar-snapshot.jar
...snip

     0 Mon Jan 26 17:41:36 JST 2009 com/tonicsystems/jarjar/asm/
     0 Mon Jan 26 17:41:36 JST 2009 com/tonicsystems/jarjar/asm/signature/
     0 Mon Jan 26 17:41:36 JST 2009 com/tonicsystems/jarjar/asm/commons/

It does't contain classes with asm-3.

But when the compile.target to 1.5, I get the jarjar-snapshot.jar containe the 
asm-3
classes.

my environment is:

Gentoo Linux (kernel 2.6.29-rc2 x86_64)

java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b16, mixed mode)

asm-3 binaries compiled with source=1.6 and target=1.6

Original comment by syo...@gmail.com on 26 Jan 2009 at 9:00

GoogleCodeExporter commented 8 years ago
Additionally, I've tryed to test.

first, compile to java5 binaries
# ant -Dcompile.target=1.5

keep java5 binaries
# cp build build.java5
# rm dist/jarjar-snapshot.jar

second, compile to java6 binaries
# ant -Dcompile.target=1.6

keep java6 binaries
# cp -a build build.java6

copy java5ed Main.class
# cp build.java5/main/com/tonicsystems/jarjar/Main.class \
build/main/com/tonicsystems/jarjar
# rm dist/jarjar-snapshot.jar
# ant
OK (asm-3 contained jarjar-snapshot.jar generated)

reverse Main.class
# cp build.java6/main/com/tonicsystems/jarjar/Main.class \
build/main/com/tonicsystems/jarjar

copy java5ed JarJarTask.class
# cp build.java5/main/com/tonicsystems/jarjar/JarJarTask.class \
build/main/com/tonicsystems/jarjar
# rm dist/jarjar-snapshot.jar
# ant
OK (asm-3 contained jarjar-snapshot.jar generated)

reverse JarJarTask.class
# cp build.java6/main/com/tonicsystems/jarjar/JarJarTask.class \
build/main/com/tonicsystems/jarjar

I've noticed that Main.class and JarJarTask.class are specified at <keep> 
directive
in build.xml.
so, I edit the build.xml and comment out the <keep> directives.

# ant
OK (asm-3 contained jarjar-snapshot.jar generated)

I think this issue is around <keep> directive.

Original comment by syo...@gmail.com on 26 Jan 2009 at 6:06

GoogleCodeExporter commented 8 years ago
Seeing this too. Windows 7 64bit, JVM 1.6.0_18. The cglib and asm classes are 
included, 
but not at the com.google.inject.internal level, but at the root level. 
Annoying.

Original comment by mathias....@gmail.com on 12 Feb 2010 at 6:20

GoogleCodeExporter commented 8 years ago
This still appears to be an issue.  I assume since no progress has been made on 
resolving this in 22 months we should not be expecting a fix?

Original comment by m2w...@gmail.com on 9 Aug 2010 at 3:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
hi guys!

If someone is still interested I have a fix for this problem.
Seems problem was really in "keep" task.
Thx for investigation)

I've attached a dead simple patch for r131

Original comment by vsevolod...@gmail.com on 23 Jun 2011 at 2:29

Attachments:

GoogleCodeExporter commented 8 years ago
I also ran into a problem where jarjar drops classes even though there are 
dependencies on them, thus silently producing corrupt output.  I did not check 
if this is related to the bytecode version, but I can confirm that the patch in 
comment 8 fixes it.  However, I would suggest the more comprehensive fix below, 
which also prints exceptions rather than silently swallowing them.

Issue 6 (fixed in revision r114) was very similar; this is just another place 
where EXPAND_FRAMES is missing.

Index: src/main/com/tonicsystems/jarjar/KeepProcessor.java
===================================================================
--- src/main/com/tonicsystems/jarjar/KeepProcessor.java (revision 138)
+++ src/main/com/tonicsystems/jarjar/KeepProcessor.java (working copy)
@@ -67,10 +67,13 @@
                     if (wildcard.matches(name))
                         roots.add(name);
                 depend.put(name, curSet = new HashSet<String>());
-                new ClassReader(new 
ByteArrayInputStream(struct.data)).accept(cv, 0);
+                new ClassReader(new 
ByteArrayInputStream(struct.data)).accept(cv,
+                    ClassReader.EXPAND_FRAMES);
                 curSet.remove(name);
             }
-        } catch (Exception ignore) { }
+        } catch (Exception e) {
+          System.err.println("Error reading " + struct.name + ": " + 
e.getMessage());
+        }
         return true;
     }

Original comment by oh...@google.com on 2 Jul 2012 at 7:59