Export to GitHub

jarjar - issue #6

IllegalStateException as a result of missing EXPAND_FRAMES flag


Posted on Dec 10, 2007 by Helpful Panda

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>

Comment #1

Posted on Jan 30, 2008 by Massive Rabbit

I 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 Panda

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.

Comment #3

Posted on Feb 7, 2008 by Massive Panda

Fixed in SVN.

Comment #4

Posted on Mar 3, 2008 by Massive Kangaroo

How about releasing a new RC that includes this fix? Thanks.

Comment #5

Posted on Mar 24, 2008 by Swift Lion

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.

Comment #6

Posted on May 7, 2008 by Massive Bird

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.

Comment #7

Posted on Jul 1, 2008 by Swift Elephant

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.

Comment #8

Posted on Jul 25, 2008 by Massive Rhino

I'm getting this issue in rc7

Comment #9

Posted on Jul 27, 2008 by Massive Rhino

I 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 Kangaroo

Change line 53 in DepFind.java to :

                .accept(new DepFindVisitor(classes, source, handler),

ClassReader.SKIP_DEBUG ^ ClassReader.EXPAND_FRAMES);

Works for me!!

Attachments

Comment #11

Posted on Aug 6, 2008 by Grumpy Kangaroo

This off course will only fix the issues for dependency generation.

Comment #12

Posted on Aug 19, 2011 by Swift Giraffe

where 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 Wombat

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!

Status: Fixed

Labels:
Type-Defect Priority-Medium