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 73145 Details for
Bug 195317
[compiler] java.lang.ClassFormatError: Invalid pc in LineNumberTable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_195317.txt (text/plain), 5.39 KB, created by
Olivier Thomann
on 2007-07-05 13:52:28 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-07-05 13:52:28 EDT
Size:
5.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java,v >retrieving revision 1.3 >diff -u -r1.3 ForStatementTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java 27 Apr 2007 15:57:14 -0000 1.3 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java 5 Jul 2007 17:51:56 -0000 >@@ -233,7 +233,70 @@ > assertTrue(false); > } > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471 - variation >+public void test005() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " int mode = 1;\n" + >+ " loop: for (;;) {\n" + >+ " switch (mode) {\n" + >+ " case 2 :\n" + >+ " return;\n" + >+ " case 1:\n" + >+ " mode = 2;\n" + >+ " continue loop;\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }, >+ ""); > >+ String expectedOutput = >+ " // Method descriptor #15 ([Ljava/lang/String;)V\n" + >+ " // Stack: 1, Locals: 2\n" + >+ " public static void main(java.lang.String[] args);\n" + >+ " 0 iconst_1\n" + >+ " 1 istore_1 [mode]\n" + >+ " 2 iload_1 [mode]\n" + >+ " 3 tableswitch default: 27\n" + >+ " case 1: 25\n" + >+ " case 2: 24\n" + >+ " 24 return\n" + >+ " 25 iconst_2\n" + >+ " 26 istore_1 [mode]\n" + >+ " 27 goto 2\n" + >+ " Line numbers:\n" + >+ " [pc: 0, line: 3]\n" + >+ " [pc: 2, line: 5]\n" + >+ " [pc: 24, line: 7]\n" + >+ " [pc: 25, line: 9]\n" + >+ " [pc: 27, line: 4]\n" + >+ " Local variable table:\n" + >+ " [pc: 0, pc: 30] local: args index: 0 type: java.lang.String[]\n" + >+ " [pc: 2, pc: 30] local: mode index: 1 type: int\n"; >+ >+ try { >+ File f = new File(OUTPUT_DIR + File.separator + "X.class"); >+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); >+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); >+ int index = result.indexOf(expectedOutput); >+ if (index == -1 || expectedOutput.length() == 0) { >+ System.out.println(Util.displayString(result, 3)); >+ } >+ if (index == -1) { >+ assertEquals("Wrong contents", expectedOutput, result); >+ } >+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) { >+ assertTrue(false); >+ } catch (IOException e) { >+ assertTrue(false); >+ } >+} > public static Class testClass() { > return ForStatementTest.class; > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java,v >retrieving revision 1.152 >diff -u -r1.152 CodeStream.java >--- compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java 26 Apr 2007 02:51:05 -0000 1.152 >+++ compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java 5 Jul 2007 17:51:57 -0000 >@@ -5872,6 +5872,16 @@ > } > } > } >+/** >+ * Remove all entries in pcToSourceMap table that are beyond this.position >+ */ >+public void removeUnusedPcToSourceMapEntries() { >+ if (this.pcToSourceMapSize != 0) { >+ while (pcToSourceMap[pcToSourceMapSize - 2] > this.position) { >+ this.pcToSourceMapSize -= 2; >+ } >+ } >+} > public void removeVariable(LocalVariableBinding localBinding) { > if (localBinding == null) return; > if (localBinding.initializationCount > 0) { >Index: compiler/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java,v >retrieving revision 1.9 >diff -u -r1.9 BranchLabel.java >--- compiler/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java 21 Nov 2006 15:42:02 -0000 1.9 >+++ compiler/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java 5 Jul 2007 17:51:57 -0000 >@@ -205,14 +205,6 @@ > this.codeStream.position = (this.position -= 3); > this.codeStream.classFileOffset -= 3; > this.forwardReferenceCount--; >- // also update the PCs in the related debug attributes >- /* OLD CODE >- int index = codeStream.pcToSourceMapSize - 1; >- while ((index >= 0) && (codeStream.pcToSourceMap[index][1] == oldPosition)) { >- codeStream.pcToSourceMap[index--][1] = position; >- } >- */ >- // Beginning of new code > if (this.codeStream.lastEntryPC == oldPosition) { > this.codeStream.lastEntryPC = this.position; > } >@@ -233,6 +225,10 @@ > } > } > } >+ if ((this.codeStream.generateAttributes & ClassFileConstants.ATTR_LINES) != 0) { >+ // we need to remove all entries that is beyond this.position inside the pcToSourcerMap table >+ this.codeStream.removeUnusedPcToSourceMapEntries(); >+ } > } > } > for (int i = 0; i < this.forwardReferenceCount; i++) {
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 195317
:
72990
|
73144
| 73145