Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 13932 Details for
Bug 71910
Weird exception handlers ranges with any exception handlers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Apply on HEAD of jdt.core project
patch_exception_handlers.txt (text/plain), 13.48 KB, created by
Olivier Thomann
on 2004-08-12 18:03:54 EDT
(
hide
)
Description:
Apply on HEAD of jdt.core project
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2004-08-12 18:03:54 EDT
Size:
13.48 KB
patch
obsolete
>Index: compiler/org/eclipse/jdt/internal/compiler/ClassFile.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java,v >retrieving revision 1.74 >diff -u -r1.74 ClassFile.java >--- compiler/org/eclipse/jdt/internal/compiler/ClassFile.java 1 Jul 2004 15:11:49 -0000 1.74 >+++ compiler/org/eclipse/jdt/internal/compiler/ClassFile.java 12 Aug 2004 21:05:22 -0000 >@@ -1268,7 +1268,7 @@ > this.contents[codeAttributeOffset + 13] = (byte) code_length; > > // write the exception table >- int exceptionHandlersNumber = codeStream.exceptionHandlersNumber; >+ int exceptionHandlersNumber = codeStream.exceptionHandlersCounter; > ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers; > int exSize = exceptionHandlersNumber * 8 + 2; > if (exSize + localContentsOffset >= this.contents.length) { >@@ -1278,31 +1278,33 @@ > // on the attribute generation > this.contents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8); > this.contents[localContentsOffset++] = (byte) exceptionHandlersNumber; >- for (int i = 0; i < exceptionHandlersNumber; i++) { >+ for (int i = 0, max = codeStream.exceptionHandlersIndex; i < max; i++) { > ExceptionLabel exceptionHandler = exceptionHandlers[i]; >- int start = exceptionHandler.start; >- this.contents[localContentsOffset++] = (byte) (start >> 8); >- this.contents[localContentsOffset++] = (byte) start; >- int end = exceptionHandler.end; >- this.contents[localContentsOffset++] = (byte) (end >> 8); >- this.contents[localContentsOffset++] = (byte) end; >- int handlerPC = exceptionHandler.position; >- this.contents[localContentsOffset++] = (byte) (handlerPC >> 8); >- this.contents[localContentsOffset++] = (byte) handlerPC; >- if (exceptionHandler.exceptionType == null) { >- // any exception handler >- this.contents[localContentsOffset++] = 0; >- this.contents[localContentsOffset++] = 0; >- } else { >- int nameIndex; >- if (exceptionHandler.exceptionType == BaseTypes.NullBinding) { >- /* represents ClassNotFoundException, see class literal access*/ >- nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException(); >+ if (exceptionHandler != null) { >+ int start = exceptionHandler.start; >+ this.contents[localContentsOffset++] = (byte) (start >> 8); >+ this.contents[localContentsOffset++] = (byte) start; >+ int end = exceptionHandler.end; >+ this.contents[localContentsOffset++] = (byte) (end >> 8); >+ this.contents[localContentsOffset++] = (byte) end; >+ int handlerPC = exceptionHandler.position; >+ this.contents[localContentsOffset++] = (byte) (handlerPC >> 8); >+ this.contents[localContentsOffset++] = (byte) handlerPC; >+ if (exceptionHandler.exceptionType == null) { >+ // any exception handler >+ this.contents[localContentsOffset++] = 0; >+ this.contents[localContentsOffset++] = 0; > } else { >- nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType); >+ int nameIndex; >+ if (exceptionHandler.exceptionType == BaseTypes.NullBinding) { >+ /* represents ClassNotFoundException, see class literal access*/ >+ nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException(); >+ } else { >+ nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType); >+ } >+ this.contents[localContentsOffset++] = (byte) (nameIndex >> 8); >+ this.contents[localContentsOffset++] = (byte) nameIndex; > } >- this.contents[localContentsOffset++] = (byte) (nameIndex >> 8); >- this.contents[localContentsOffset++] = (byte) nameIndex; > } > } > // debug attributes >@@ -1578,7 +1580,7 @@ > this.contents[codeAttributeOffset + 13] = (byte) code_length; > > // write the exception table >- int exceptionHandlersNumber = codeStream.exceptionHandlersNumber; >+ int exceptionHandlersNumber = codeStream.exceptionHandlersCounter; > ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers; > int exSize = exceptionHandlersNumber * 8 + 2; > if (exSize + localContentsOffset >= this.contents.length) { >@@ -1588,31 +1590,33 @@ > // on the attribute generation > this.contents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8); > this.contents[localContentsOffset++] = (byte) exceptionHandlersNumber; >- for (int i = 0; i < exceptionHandlersNumber; i++) { >+ for (int i = 0, max = codeStream.exceptionHandlersIndex; i < max; i++) { > ExceptionLabel exceptionHandler = exceptionHandlers[i]; >- int start = exceptionHandler.start; >- this.contents[localContentsOffset++] = (byte) (start >> 8); >- this.contents[localContentsOffset++] = (byte) start; >- int end = exceptionHandler.end; >- this.contents[localContentsOffset++] = (byte) (end >> 8); >- this.contents[localContentsOffset++] = (byte) end; >- int handlerPC = exceptionHandler.position; >- this.contents[localContentsOffset++] = (byte) (handlerPC >> 8); >- this.contents[localContentsOffset++] = (byte) handlerPC; >- if (exceptionHandler.exceptionType == null) { >- // any exception handler >- this.contents[localContentsOffset++] = 0; >- this.contents[localContentsOffset++] = 0; >- } else { >- int nameIndex; >- if (exceptionHandler.exceptionType == BaseTypes.NullBinding) { >- /* represents denote ClassNotFoundException, see class literal access*/ >- nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException(); >+ if (exceptionHandler != null) { >+ int start = exceptionHandler.start; >+ this.contents[localContentsOffset++] = (byte) (start >> 8); >+ this.contents[localContentsOffset++] = (byte) start; >+ int end = exceptionHandler.end; >+ this.contents[localContentsOffset++] = (byte) (end >> 8); >+ this.contents[localContentsOffset++] = (byte) end; >+ int handlerPC = exceptionHandler.position; >+ this.contents[localContentsOffset++] = (byte) (handlerPC >> 8); >+ this.contents[localContentsOffset++] = (byte) handlerPC; >+ if (exceptionHandler.exceptionType == null) { >+ // any exception handler >+ this.contents[localContentsOffset++] = 0; >+ this.contents[localContentsOffset++] = 0; > } else { >- nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType); >+ int nameIndex; >+ if (exceptionHandler.exceptionType == BaseTypes.NullBinding) { >+ /* represents denote ClassNotFoundException, see class literal access*/ >+ nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException(); >+ } else { >+ nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType); >+ } >+ this.contents[localContentsOffset++] = (byte) (nameIndex >> 8); >+ this.contents[localContentsOffset++] = (byte) nameIndex; > } >- this.contents[localContentsOffset++] = (byte) (nameIndex >> 8); >- this.contents[localContentsOffset++] = (byte) nameIndex; > } > } > // debug attributes >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java,v >retrieving revision 1.6 >diff -u -r1.6 SubRoutineStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java 28 Apr 2004 00:21:39 -0000 1.6 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java 12 Aug 2004 21:05:22 -0000 >@@ -44,8 +44,10 @@ > if (currentLabel.start == currentLabel.codeStream.position) { > // discard empty exception handler > this.anyExceptionLabels[--this.anyExceptionLabelsCount] = null; >+ currentLabel.codeStream.removeExceptionHandler(currentLabel); >+ } else { >+ currentLabel.placeEnd(); > } >- currentLabel.placeEnd(); > } > > public void placeAllAnyExceptionHandlers() { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java,v >retrieving revision 1.31 >diff -u -r1.31 SynchronizedStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java 1 Jul 2004 15:11:49 -0000 1.31 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java 12 Aug 2004 21:05:22 -0000 >@@ -71,7 +71,7 @@ > * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream > */ > public void generateCode(BlockScope currentScope, CodeStream codeStream) { >- >+ > if ((bits & IsReachableMASK) == 0) { > return; > } >@@ -82,7 +82,7 @@ > this.anyExceptionLabelsCount = 0; > } > int pc = codeStream.position; >- >+ > // generate the synchronization expression > expression.generateCode(scope, codeStream, true); > if (block.isEmptyBlock()) { >@@ -99,7 +99,7 @@ > // enter the monitor > codeStream.store(synchroVariable, true); > codeStream.monitorenter(); >- >+ > // generate the body of the synchronized block > this.enterAnyExceptionHandler(codeStream); > block.generateCode(scope, codeStream); >@@ -107,16 +107,14 @@ > if (!blockExit) { > codeStream.load(synchroVariable); > codeStream.monitorexit(); >- this.exitAnyExceptionHandler(); > codeStream.goto_(endLabel); >- this.enterAnyExceptionHandler(codeStream); > } > // generate the body of the exception handler >+ this.exitAnyExceptionHandler(); > this.placeAllAnyExceptionHandlers(); > codeStream.incrStackSize(1); > codeStream.load(synchroVariable); > codeStream.monitorexit(); >- this.exitAnyExceptionHandler(); > codeStream.athrow(); > if (!blockExit) { > endLabel.place(); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java,v >retrieving revision 1.74 >diff -u -r1.74 TryStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 1 Jul 2004 15:11:49 -0000 1.74 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 12 Aug 2004 21:05:22 -0000 >@@ -298,9 +298,7 @@ > } > } > } >- if (finallyMode != FINALLY_SUBROUTINE || this.subRoutineStartLabel == null) { >- this.exitAnyExceptionHandler(); >- } >+ this.exitAnyExceptionHandler(); > // extra handler for trailing natural exit (will be fixed up later on when natural exit is generated below) > ExceptionLabel naturalExitExceptionHandler = > finallyMode == FINALLY_SUBROUTINE && requiresNaturalExit ? new ExceptionLabel(codeStream, null) : null; >@@ -319,11 +317,9 @@ > > codeStream.incrStackSize(1); > switch(finallyMode) { >- > case FINALLY_SUBROUTINE : > codeStream.store(anyExceptionVariable, false); > codeStream.jsr(subRoutineStartLabel); >- this.exitAnyExceptionHandler(); > codeStream.load(anyExceptionVariable); > codeStream.athrow(); > subRoutineStartLabel.place(); >Index: compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java,v >retrieving revision 1.78 >diff -u -r1.78 CodeStream.java >--- compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java 1 Jul 2004 09:31:56 -0000 1.78 >+++ compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java 12 Aug 2004 21:05:23 -0000 >@@ -49,7 +49,9 @@ > public AbstractMethodDeclaration methodDeclaration; > public ExceptionLabel[] exceptionHandlers = new ExceptionLabel[LABELS_INCREMENT]; > static ExceptionLabel[] noExceptionHandlers = new ExceptionLabel[LABELS_INCREMENT]; >- public int exceptionHandlersNumber; >+ public int exceptionHandlersIndex; >+ public int exceptionHandlersCounter; >+ > public static FieldBinding[] ImplicitThis = new FieldBinding[] {}; > public boolean generateLineNumberAttributes; > public boolean generateLocalVariableTableAttributes; >@@ -2713,7 +2715,8 @@ > noExceptionHandlers = new ExceptionLabel[length]; > } > System.arraycopy(noExceptionHandlers, 0, exceptionHandlers, 0, length); >- exceptionHandlersNumber = 0; >+ exceptionHandlersIndex = 0; >+ exceptionHandlersCounter = 0; > > length = labels.length; > if (noLabels.length < length) { >@@ -4760,12 +4763,22 @@ > */ > public void registerExceptionHandler(ExceptionLabel anExceptionLabel) { > int length; >- if (exceptionHandlersNumber >= (length = exceptionHandlers.length)) { >+ if (exceptionHandlersIndex >= (length = exceptionHandlers.length)) { > // resize the exception handlers table > System.arraycopy(exceptionHandlers, 0, exceptionHandlers = new ExceptionLabel[length + LABELS_INCREMENT], 0, length); > } > // no need to resize. So just add the new exception label >- exceptionHandlers[exceptionHandlersNumber++] = anExceptionLabel; >+ exceptionHandlers[exceptionHandlersIndex++] = anExceptionLabel; >+ exceptionHandlersCounter++; >+} >+public void removeExceptionHandler(ExceptionLabel exceptionLabel) { >+ for (int i = 0; i < exceptionHandlersIndex; i++) { >+ if (exceptionHandlers[i] == exceptionLabel) { >+ exceptionHandlers[i] = null; >+ exceptionHandlersCounter--; >+ return; >+ } >+ } > } > public final void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) { > // given some flow info, make sure we did not loose some variables initialization
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 71910
:
13931
| 13932 |
13933
|
13934