What steps will reproduce the problem?
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>
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>
Comment #1
Posted on Jan 30, 2008 by Massive RabbitI have also replicated this problem, using jarjar-1.0rc6.jar with mysql-connector-java-5.1.5.jar.
My ant task is
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.java: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.
Comment #2
Posted on Feb 7, 2008 by Massive PandaDoes 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.
Comment #3
Posted on Feb 7, 2008 by Massive PandaFixed in SVN.
Comment #4
Posted on Mar 3, 2008 by Massive KangarooHow about releasing a new RC that includes this fix? Thanks.
Comment #5
Posted on Mar 24, 2008 by Swift LionI 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.
Comment #6
Posted on May 7, 2008 by Massive BirdThis issue is happening at my company as well. Would be nice to have a RC with the fix, and tests that include Java 6.
Comment #7
Posted on Jul 1, 2008 by Swift ElephantIs 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.
Comment #8
Posted on Jul 25, 2008 by Massive RhinoI'm getting this issue in rc7
Comment #9
Posted on Jul 27, 2008 by Massive RhinoI compiled my classes in jdk 1.5 (OSX) and I still get the EXPAND_FRAMES error.
Comment #10
Posted on Aug 6, 2008 by Grumpy KangarooChange line 53 in DepFind.java to :
.accept(new DepFindVisitor(classes, source, handler),
ClassReader.SKIP_DEBUG ^ ClassReader.EXPAND_FRAMES);
Works for me!!
- DepFind.java 2.29KB
Comment #11
Posted on Aug 6, 2008 by Grumpy KangarooThis off course will only fix the issues for dependency generation.
Comment #12
Posted on Aug 19, 2011 by Swift Giraffewhere do I get the fixed code from. I have version 1.1 and it gives the same error?
Comment #13
Posted on Oct 6, 2011 by Happy WombatThis 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!
Status: Fixed
Labels:
Type-Defect
Priority-Medium