runt18 / jarjar

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

IllegalStateException as a result of missing EXPAND_FRAMES flag #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Create an Ant build script with a task as follows:
<target name="dist" description="Build the distributable JAR" depends="build">
    <mkdir dir="${dist.dir}" />
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${lib.ant.dir}/${jar.jarjar}" />
    <jarjar jarfile="${dist.dir}/${project.name}.jar">
        <manifest>
            <attribute name="Manifest-Version" value="1.0" />
            <attribute name="Main-Class" value="com.example.program.Runner" />
        </manifest>
        <fileset dir="${build.dir}"/>
        <zipfileset src="${lib.dir}/mysql-connector-java-5.1.5-bin.jar"/>
        <zipfileset src="${lib.dir}/commons-lang-2.3.jar" />
        <rule pattern="com.mysql.**" result="com.example.mysql.@1" />
        <rule pattern="org.gjt.**" result="com.example.gjt.@1" />
        <rule pattern="org.apache.**" result="com.example.apache.@1" />
    </jarjar>
</target>

2. Run the above target: "ant dist"

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

Expect a properly constructed JAR but receive instead the following error:
BUILD FAILED
/home/sean/workspace/CascadeDbCollator/build.xml:70:
java.lang.IllegalStateException: ClassReader.accept() should be called with
EXPAND_FRAMES flag

Line 70 in my script is:
<jarjar jarfile="${dist.dir}/${project.name}.jar">

What version of the product are you using? On what operating system?
1.0 RC6 on Ubuntu Linux 7.10

Please provide any additional information below.

Using Java 1.5, output from java -version is:
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Server VM (build 1.5.0_13-b05, mixed mode)

Using Ant 1.7, output from ant -versoin is:
Apache Ant version 1.7.0 compiled on August 29 2007

Build task is as follows:
<target name="build" description="Compile main source tree java files">
    <mkdir dir="${build.dir}" />
    <javac destdir="${build.dir}" debug="true" deprecation="false"
optimize="false" failonerror="true">
        <src path="${src.dir}" />
        <classpath refid="master-classpath" />
    </javac>
</target>

Running the above as a normal <jar/> task succeeds using the following:
<target name="dist" description="Build the distributable JAR" depends="build">
    <mkdir dir="${dist.dir}" />
    <jar jarfile="${dist.dir}/${project.name}.jar">
        <manifest>
            <attribute name="Manifest-Version" value="1.0" />
            <attribute name="Main-Class"
value="com.hannonhill.cascade.collator.Runner" />
        </manifest>
        <fileset dir="${build.dir}"/>
        <zipfileset src="${lib.dir}/mysql-connector-java-5.1.5-bin.jar"/>
        <zipfileset src="${lib.dir}/commons-lang-2.3.jar" />
    </jar>
</target>

Original issue reported on code.google.com by seancsaw...@gmail.com on 10 Dec 2007 at 2:23

GoogleCodeExporter commented 8 years ago
I have also replicated this problem, using jarjar-1.0rc6.jar with
mysql-connector-java-5.1.5.jar.

My ant task is

<jarjar jarfile="out.jar">
    <zipfileset src="mysql-connector-java-5.1.5.jar"/>
</jarjar>

This always fails with an IllegalStateException

java.lang.IllegalStateException: ClassReader.accept() should be called with
EXPAND_FRAMES flag
        at
com.tonicsystems.jarjar.asm.commons.LocalVariablesSorter.visitFrame(Unknown 
Source)
        at
com.tonicsystems.jarjar.asm.commons.RemappingMethodAdapter.visitFrame(Unknown 
Source)
        at com.tonicsystems.jarjar.asm.ClassReader.accept(Unknown Source)
        at com.tonicsystems.jarjar.asm.ClassReader.accept(Unknown Source)
        at
com.tonicsystems.jarjar.ext_util.JarTransformer.process(JarTransformer.java:39)
        at
com.tonicsystems.jarjar.ext_util.JarProcessorChain.process(JarProcessorChain.jav
a:31)
        at com.tonicsystems.jarjar.MainProcessor.process(MainProcessor.java:82)
        at
com.tonicsystems.jarjar.ext_util.AntJarProcessor.zipFile(AntJarProcessor.java:55
)
        at org.apache.tools.ant.taskdefs.Zip.addResources(Zip.java:585)
        at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:415)
        at
com.tonicsystems.jarjar.ext_util.AntJarProcessor.execute(AntJarProcessor.java:42
)
        at com.tonicsystems.jarjar.JarJarTask.execute(JarJarTask.java:50)
        at org.apache.tools.ant.Task.perform(Task.java:341)

I added some debugging into the jarjar task and found that the error occurs when
JarTransformer.process() is called with an EntryStruct representing the class
JDBC4Connection.class found in the mysql jar file.

com/mysql/jdbc/JDBC4Connection.class

I'm afraid I don't know much about asm and haven't been able to debug further, 
to see
what the actual problem is with processing this class.

Original comment by matt.r.p...@gmail.com on 30 Jan 2008 at 10:25

GoogleCodeExporter commented 8 years ago
Does the mysql-connector-java-5.1.5.jar contain classes compiled for Java 1.6? 
Can
you attach it? There is an easy fix but it will hurt performance.

Original comment by chris.no...@gmail.com on 7 Feb 2008 at 1:38

GoogleCodeExporter commented 8 years ago
Fixed in SVN.

Original comment by chris.no...@gmail.com on 7 Feb 2008 at 1:54

GoogleCodeExporter commented 8 years ago
How about releasing a new RC that includes this fix? Thanks.

Original comment by fullung@gmail.com on 3 Mar 2008 at 10:37

GoogleCodeExporter commented 8 years ago
I am getting this same exception when I am trying to find dependencies between 
the jars.

java -jar jarjar-1.0rc7.jar find jar activation-1.0.2.jar [very big long 
classpath]

It doesn't do it all the time, but does appear to do it when there are java 6
compiled classes.

Original comment by jason...@gmail.com on 24 Mar 2008 at 7:32

GoogleCodeExporter commented 8 years ago
This issue is happening at my company as well.
Would be nice to have a RC with the fix, and tests that include Java 6.

Original comment by naa...@gmail.com on 7 May 2008 at 2:32

GoogleCodeExporter commented 8 years ago
Is this issue supposedly fixed in rc7? I have just started getting this (using 
rc7). 

I tried a fresh build from svn (checked out 06/31/08), but that had other 
problems
and didn't get far enough to tell if this issue still existed.

Original comment by pdgro...@gmail.com on 1 Jul 2008 at 3:17

GoogleCodeExporter commented 8 years ago
I'm getting this issue in rc7

Original comment by dennis.p...@gmail.com on 25 Jul 2008 at 8:35

GoogleCodeExporter commented 8 years ago
I compiled my classes in jdk 1.5 (OSX) and I still get the EXPAND_FRAMES error.

Original comment by dennis.p...@gmail.com on 27 Jul 2008 at 1:39

GoogleCodeExporter commented 8 years ago
Change line 53 in DepFind.java to :

                    .accept(new DepFindVisitor(classes, source, handler),
ClassReader.SKIP_DEBUG ^ ClassReader.EXPAND_FRAMES);

Works for me!!

Original comment by tommymcg...@gmail.com on 6 Aug 2008 at 1:37

Attachments:

GoogleCodeExporter commented 8 years ago
This off course will only fix the issues for dependency generation. 

Original comment by tommymcg...@gmail.com on 6 Aug 2008 at 1:44

GoogleCodeExporter commented 8 years ago
where do I get the fixed code from.  I have version 1.1 and it gives the same 
error?

Original comment by carl.rob...@gmail.com on 19 Aug 2011 at 4:25

GoogleCodeExporter commented 8 years ago
This is issue is NOT fixed in trunk!

Line 65 of src/main/com/tonicsystems/jarjar/DepFind.java needs to be changed 
from:

                      ClassReader.SKIP_DEBUG);

to:

                      ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);

Please apply this change!

Original comment by pan...@gmail.com on 6 Oct 2011 at 6:42