ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11630] New: - RMIC-Task moveGeneratedFile(...) StringIndexOutOfBoundsException
Date Mon, 12 Aug 2002 12:49:55 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11630>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11630

RMIC-Task moveGeneratedFile(...) StringIndexOutOfBoundsException

           Summary: RMIC-Task moveGeneratedFile(...)
                    StringIndexOutOfBoundsException
           Product: Ant
           Version: 1.5
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: sebi+bugzilla@tux.wh17.tu-dresden.de


The solution (as introduced in 
src/main/org/apache/tools/ant/taskdefs/Rmic.java rev1.32) to really move 
generated *.java (if sourcebase is specified) from base dir to sourcebase 
creates an StringIndexOutOfBoundsException.

The reason for the exception is line 574:
            String sourceFileName = 
                generatedFiles[i].substring(0, classFileName.length() - 6)

It calculates the index based on the classFileName.  The following case 
doesn't work with this calculation:

Here we have an interface jatek.server.ChapterContainer (classname) or 
jatek.server.ChapterContainer.class (classFileName) respective.
generatedFiles[0] is jatek/server/_ChapterContainer_Tie.class
The sourceFileName (as generated in line 574) gets 
jatek/server/_ChapterContaine.java
As you can see, the '_' in front of the file name causes the 'r' to be left. 
 This is only an error, it doesn't throw the exception because the 
calculated index is 29.  When we go an iteration further, we get 
generatedFiles[1]=jatek/_Chapter_Stub.class.  This string's length is only 
25.  So the calculated index 29 (from classFileName) is to long and 
therefore causes the exception.

I think you can solve the problem with the following patch.  The index is 
calculated each iteration from generatedFiles[i] instead of from the 
interface classname.

---------------------------------------------------------------------------
--- /tmp/Rmic.java.BAK  2002-08-12 12:41:42.000000000 +0200
+++ src/main/org/apache/tools/ant/taskdefs/Rmic.java    2002-08-12 
12:41:52.000000000 +0200
@@ -572,7 +572,7 @@
             }
             
             String sourceFileName = 
-                generatedFiles[i].substring(0, classFileName.length() - 6)
+                generatedFiles[i].substring(0, generatedFiles[i].length() - 
6)
                 + ".java";
 
             File oldFile = new File(baseDir, sourceFileName);
---------------------------------------------------------------------------


Sebastian Klamar

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message