cirothedesertwind / jarjar

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

Get ArrayIndexOutOfBoundsException when building #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by psych...@gmail.com on 31 Jul 2007 at 12:35

Attachments:

GoogleCodeExporter commented 8 years ago
...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.

Original comment by psych...@gmail.com on 7 Aug 2007 at 1:53

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

Original comment by toom...@gmail.com on 8 Aug 2007 at 8:52

GoogleCodeExporter commented 8 years ago
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;

Original comment by psych...@gmail.com on 8 Aug 2007 at 5:53

GoogleCodeExporter commented 8 years ago
The jarjar task is working again after making this change.

Original comment by toom...@gmail.com on 9 Aug 2007 at 6:51

GoogleCodeExporter commented 8 years ago
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.

Original comment by head...@gmail.com on 22 Oct 2007 at 1:25

GoogleCodeExporter commented 8 years ago
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?

Original comment by head...@gmail.com on 22 Oct 2007 at 1:29

GoogleCodeExporter commented 8 years ago
This issue also appears when repackaging Rhino 1.6 R7.

Original comment by christop...@gmail.com on 22 Oct 2007 at 10:16

GoogleCodeExporter commented 8 years ago
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.

Original comment by christop...@gmail.com on 22 Oct 2007 at 10:28

GoogleCodeExporter commented 8 years ago
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.jav
a: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.jav
a: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)

Original comment by dirk.det...@googlemail.com on 7 Nov 2007 at 11:21

GoogleCodeExporter commented 8 years ago
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.

Original comment by chris.no...@gmail.com on 7 Nov 2007 at 8:57

GoogleCodeExporter commented 8 years ago
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.

Original comment by chris.no...@gmail.com on 8 Nov 2007 at 6:21