skpal / jarjar

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

StringIndexOutOfBoundsException with wicket-1.3.0-rc2.jar #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the attached Ant build script using "ant -d -f jjdebug.xml" ensuring
that the property setting the path to the wicket-1.3.0-rc2.jar file is
correct for the test system

What is the expected output? What do you see instead?
Should have generated a deps.jar file containing the contents of the wicket
JAR.  Instead, got a "java.lang.StringIndexOutOfBoundsException: String
index out of range: -3" as shown in snippet below.

What version of the product are you using? On what operating system?
Testing jarjar1.0-rc6 on a Win2K, SP4 system with JDK 1.6.0_03

Please provide any additional information below.

Got the following exception trace result in which it appears that during
visiting a field, PackageRemapper.mapPath() calls String.substring() which
throws the exception.

java.lang.StringIndexOutOfBoundsException: String index out of range: -3 at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:115)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java
:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of
range: -3
        at java.lang.String.substring(String.java:1938)
        at
com.tonicsystems.jarjar.PackageRemapper.mapPath(PackageRemapper.java:84)
        at
com.tonicsystems.jarjar.PackageRemapper.mapValue(PackageRemapper.java:101)
        at
com.tonicsystems.jarjar.asm.commons.RemappingClassAdapter.visitField(Unknown
Source)

Original issue reported on code.google.com by jon.for...@gmail.com on 18 Dec 2007 at 2:39

Attachments:

GoogleCodeExporter commented 8 years ago
JarJar was able to work on many of files from the Wicket JAR but always fails 
when
attempting to use org/apache/wicket/validation/validator/StringValidator.class 
from
the Wicket JAR.

Original comment by jon.for...@gmail.com on 18 Dec 2007 at 2:45

GoogleCodeExporter commented 8 years ago
I've also replicated this with wicket-1.3.0 final, JDK 1.5.0_08-b03, WinXP SP2,
jarjar1.0-rc6.

java.lang.StringIndexOutOfBoundsException: String index out of range: -3
    at java.lang.String.substring(String.java:1768)
    at com.tonicsystems.jarjar.PackageRemapper.mapPath(PackageRemapper.java:84)
    at com.tonicsystems.jarjar.PackageRemapper.mapValue(PackageRemapper.java:101)
    at com.tonicsystems.jarjar.asm.commons.RemappingClassAdapter.visitField(

Original comment by matt.r.p...@gmail.com on 28 Jan 2008 at 12:07

GoogleCodeExporter commented 8 years ago
I did a little debugging and found that the Exception is thrown when processing
org.apache.wicket.validation.validator.UrlValidator  

The Exception happens when visiting the VALID_CHARS field.  In UrlValidator the 
field
is defined as

private static final String SPECIAL_CHARS = ";/@&=,.?:+$";
private static final String VALID_CHARS = "[^\\s" + SPECIAL_CHARS + "]";

Inside jarjar, the Exception is thrown from
PackageRemapper.mapPath(PackageRemapper.java:84).  The method is called with a 
path 
value of "[^\s;/@&=,.?:+$]".  When it gets to line 84 it tries to do this

s = s.substring(0, s.length() - RESOURCE_SUFFIX.length()) + end;

Here s = "[L\s;" and RESOURCE_SUFFIX = "RESOURCE", so the code throws
StringIndexOutOfBoundsException.

Original comment by matt.r.p...@gmail.com on 28 Jan 2008 at 2:11

GoogleCodeExporter commented 8 years ago
This is fixed in SVN.

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