Export to GitHub

jarjar - issue #2

Get ArrayIndexOutOfBoundsException when building


Posted on Jul 31, 2007 by Quick Ox

What steps will reproduce the problem?

Unclear. I think the problem may be library-content related. I've attached a stack trace and what seem to be the relevant values from the last two frames. Here was the analogous task:

<target name="project_postjar" depends="project_compile"> <jar jarfile="${dist}/project.jar"> <manifest> <attribute name="Built-By" value="${user.name}" /> <attribute name="Main-Class" value="com.company.group.tools.project.ProjectMain" /> </manifest> <fileset dir="${build}" includes="com/company/group/tools/project/" /> <fileset dir="${build}" includes="com/company/group/tools/cliconfig/" /> <fileset dir="${build}" includes="com/company/group/tools/common/**" /> <zipfileset src="${build}/project.jar" /> </jar> </target>

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

a successfully built jar. a BUILD FAILED, due to the exception.

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

1.0rc5

Please provide any additional information below.

Relevant values from debugging at the exception point (w/o source):

Type.a(null, 0) Type.getElementType(): a == 9, c == 0, d == 72, b[] = [[, L, O, O, K, U, P, ], , L, o, o, k, i, n, g, , f, o, r, , a, , r, e, s, o, u, r, c, e, , f, i, l, e, , o, f, , n, a, m, e, , [, M, E, T, A, -, I, N, F, /, s, e, r, v, i, c, e, s, /, R, E, S, O, U, R, C, E]

jarjar works great in some other situations, but there's something poison in the zipfileset that causes it to croak consistently.

Attachments

Comment #1

Posted on Aug 7, 2007 by Quick Ox

...a bit more info...

Please ignore the Type.a(null, 0) values above, they're wrong (post-exception). The char array (b[]) definitely has the poison value: This value is just a string in a .class. But apparently while doing mapPath(), the type is created as an ARRAY sort, and it's not, it's a string. Then mapType() is called, tries to get the element type descriptor for the internal name, and barfs.

So in a nutshell, having a String in a class that happens to start with "[" and also contains something that looks like a RESOURCE causes the problem.

Comment #2

Posted on Aug 8, 2007 by Helpful Ox

I'm experiencing the same Exception while bundling Objectweb asm-3.0.jar to a jar. Tried 1.0rc3 and 1.0rc5

Comment #3

Posted on Aug 8, 2007 by Quick Ox

FYI, I've temporarily added an ugly hack around the problem in my local com.tonicsystems.jarjar.PackageRemapper.mapPath(). Given the current impl of ASM, it looks like this method is especially dangerous before and after the hack - it could easily still fail: there are an infinite number of poison values that will throw or cause other havoc. I changed this section (look at the original code and it'll be obvious):

        boolean absolute = s.startsWith("/");
        if (absolute)
            s = s.substring(1);
        boolean array = s.startsWith("[");
        if (array)
            s = s.substring(1);
        String after = mapType(s);
        s = after;
        if (array)
            s = "[" + s;
        if (absolute)
            s = "/" + s;

Comment #4

Posted on Aug 9, 2007 by Helpful Ox

The jarjar task is working again after making this change.

Comment #5

Posted on Oct 22, 2007 by Happy Kangaroo

New JarJar release coming soon with this fix in it? JRuby is pushing a release in a couple weeks and we need to update JarJar to handle our annotation-based classes correctly; but we ship ASM.

Comment #6

Posted on Oct 22, 2007 by Happy Kangaroo

FYI, here's the JRuby issue that's prompted us to upgrade JarJar:

http://jira.codehaus.org/browse/JRUBY-1456. Hopefully this is fixed already?

Comment #7

Posted on Oct 22, 2007 by Helpful Camel

This issue also appears when repackaging Rhino 1.6 R7.

Comment #8

Posted on Oct 22, 2007 by Helpful Camel

The hack (downloadable from http://jira.codehaus.org/browse/JRUBY-1456) repackages Rhino 1.6 R7 without failing to build, however, the new version of Rhino still creates class files using the old types. Presumably jarjar would have to change the behaviour of org.mozilla.javascript.optimizer.Codegen as well.

Comment #9

Posted on Nov 7, 2007 by Quick Panda

I had the named problem directly after downloading jarjar and trying to apply it to a project where Groovy (groovy-all-1.0.jar) is involved.

I think that AsmClassGenerator.class causes the problem (the next one expected to be listed but missing in the 'adding'-list below).

The hack provided by psychesy in Comment No 3 seems to have solved it.


[...] [jarjar] adding entry org/codehaus/groovy/bsf/GroovyEngine.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$1.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$2.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$3.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$4.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$5.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$6.class [jarjar] adding entry org/codehaus/groovy/classgen/AsmClassGenerator$7.class

BUILD FAILED D:\Sdegui\build.xml:74: java.lang.ArrayIndexOutOfBoundsException: 20 at org.apache.tools.ant.Task.perform(Task.java:373) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1220) at org.apache.tools.ant.Project.executeTarget(Project.java:1189) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1072) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) Caused by: java.lang.ArrayIndexOutOfBoundsException: 20 at com.tonicsystems.jarjar.asm.Type.a(Unknown Source) at com.tonicsystems.jarjar.asm.Type.getElementType(Unknown Source) at com.tonicsystems.jarjar.asm.commons.Remapper.mapType(Unknown Source) at com.tonicsystems.jarjar.asm.commons.Remapper.mapType(Unknown Source) at com.tonicsystems.jarjar.PackageRemapper.mapPath(PackageRemapper.java:82) at com.tonicsystems.jarjar.PackageRemapper.mapValue(PackageRemapper.java:104) at com.tonicsystems.jarjar.asm.commons.RemappingMethodAdapter.visitLdcInsn(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:35) at com.tonicsystems.jarjar.ext_util.JarProcessorChain.process(JarProcessorChain.java:31) at com.tonicsystems.jarjar.MainProcessor.process(MainProcessor.java:83) at com.tonicsystems.jarjar.ext_util.AntJarProcessor.zipFile(AntJarProcessor.java:55) at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:1146) at org.apache.tools.ant.taskdefs.Zip.addResources(Zip.java:681) at org.apache.tools.ant.taskdefs.Zip.executeMain(Zip.java:481) at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:350) 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.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) ... 10 more --- Nested Exception --- java.lang.ArrayIndexOutOfBoundsException: 20 at com.tonicsystems.jarjar.asm.Type.a(Unknown Source) at com.tonicsystems.jarjar.asm.Type.getElementType(Unknown Source) at com.tonicsystems.jarjar.asm.commons.Remapper.mapType(Unknown Source) at com.tonicsystems.jarjar.asm.commons.Remapper.mapType(Unknown Source) at com.tonicsystems.jarjar.PackageRemapper.mapPath(PackageRemapper.java:82) at com.tonicsystems.jarjar.PackageRemapper.mapValue(PackageRemapper.java:104) at com.tonicsystems.jarjar.asm.commons.RemappingMethodAdapter.visitLdcInsn(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:35) at com.tonicsystems.jarjar.ext_util.JarProcessorChain.process(JarProcessorChain.java:31) at com.tonicsystems.jarjar.MainProcessor.process(MainProcessor.java:83) at com.tonicsystems.jarjar.ext_util.AntJarProcessor.zipFile(AntJarProcessor.java:55) at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:1146) at org.apache.tools.ant.taskdefs.Zip.addResources(Zip.java:681) at org.apache.tools.ant.taskdefs.Zip.executeMain(Zip.java:481) at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:350) 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.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1220) at org.apache.tools.ant.Project.executeTarget(Project.java:1189) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1072) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Comment #10

Posted on Nov 7, 2007 by Massive Panda

Sorry, for some reason I was not getting notification of issues posted here. I'll investigate the problem and get a new release out ASAP.

Comment #11

Posted on Nov 8, 2007 by Massive Panda

Fixes checked into SVN. Please give it a go. I'll put out a new release later this week.

Sorry for the delay! The project was configured to send issue updates to the mailing list but something must have gone wrong.

Status: Fixed

Labels:
Type-Defect Priority-Medium