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 279655 Details for
Bug 544943
[13][codegen] Exception while codegen for multi-nested switch expression with try
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Debugging Notes
file_544943.txt (text/plain), 6.91 KB, created by
Manoj N Palat
on 2019-08-21 23:26:04 EDT
(
hide
)
Description:
Debugging Notes
Filename:
MIME Type:
Creator:
Manoj N Palat
Created:
2019-08-21 23:26:04 EDT
Size:
6.91 KB
patch
obsolete
>Debugging notes: >For the following code snippet, > > public static int foo(int i) throws Exception { > int v = switch (i) { > case 0 -> switch (i) { > case 0 -> 0; > default -> throw new Exception(); > }; > default -> 0; > }; > return v; > } > >The code generated is shown below: >// Method descriptor #15 (I)I > // Stack: 3, Locals: 1 > public static int foo(int arg0) throws java.lang.Exception; > 0 new java.lang.Error [23] > 3 dup > 4 ldc <String "Unresolved compilation problem: \n"> [25] > 6 invokespecial java.lang.Error(java.lang.String) [27] > 9 athrow > Line numbers: > [pc: 0, line: 3] > >The message at runtime is of course given by the line 4 ldc <String "Unresolved compilation problem: \n"> which is inserted into the code stream by the following st (debug breakpoint): >ClassFile.addProblemMethod(AbstractMethodDeclaration, MethodBinding, CategorizedProblem[]) line: 914 >ClassFile.addProblemMethod(AbstractMethodDeclaration, MethodBinding, CategorizedProblem[], int) line: 952 >MethodDeclaration(AbstractMethodDeclaration).generateCode(ClassScope, ClassFile) line: 317 >TypeDeclaration.generateCode(ClassFile) line: 583 >TypeDeclaration.generateCode(CompilationUnitScope) line: 653 >CompilationUnitDeclaration.generateCode() line: 410 >CompilationUnitResolver.resolve(CompilationUnitDeclaration, ICompilationUnit, NodeSearcher, boolean, boolean, boolean) line: 1249 >CompilationUnitResolver.resolve(ICompilationUnit, IJavaProject, List, NodeSearcher, Map, WorkingCopyOwner, int, IProgressMonitor) line: 714 >ASTParser.internalCreateAST(IProgressMonitor) line: 1221 >ASTParser.createAST(IProgressMonitor) line: 836 >CoreASTProvider$1.run() line: 271 >This code path is taken due to Boolean check on abort (a Boolean variable) at MethodDeclaration(AbstractMethodDeclaration).generateCode(ClassScope, ClassFile) line: 317 > >The variable abort is true because of a throw of AbortMethod at: >ClassFile.traverse(MethodBinding, int, byte[], int, int, Map, boolean) line: 5842 >ClassFile.generateStackMapTableAttribute(MethodBinding, int, int, int, boolean) line: 4804 >ClassFile.completeCodeAttribute(int) line: 1513 >MethodDeclaration(AbstractMethodDeclaration).generateCode(ClassFile) line: 357 >MethodDeclaration(AbstractMethodDeclaration).generateCode(ClassScope, ClassFile) line: 281 >TypeDeclaration.generateCode(ClassFile) line: 583 >TypeDeclaration.generateCode(CompilationUnitScope) line: 653 >CompilationUnitDeclaration.generateCode() line: 410 >CompilationUnitProblemFinder(Compiler).resolve(CompilationUnitDeclaration, ICompilationUnit, boolean, boolean, boolean) line: 1070 >CompilationUnitProblemFinder(Compiler).resolve(ICompilationUnit, boolean, boolean, boolean) line: 1106 >CompilationUnitProblemFinder.process(CompilationUnit, SourceElementParser, WorkingCopyOwner, HashMap, boolean, int, IProgressMonitor) line: 280 >CompilationUnitProblemFinder.process(CompilationUnit, WorkingCopyOwner, HashMap, boolean, int, IProgressMonitor) line: 346 >Interesting variables at generateStackMapTableAttribute call â maxLocals:2 >Variable values/opcodes: > >frame added (total : 1) >106: iload_3 >107: tableswitch >frame added (total : 2) > >125: iload_3 >[pc : -1 locals: 1 stack items: 1 >locals: [I,top] >stack: [I] >] > > >126: tableswitch >[pc : -1 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >] > > >Frame added: - frames: >{-1=[pc : -1 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >], 20=[pc : 20 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >], 40=[pc : 40 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >]} > > >145: iconst_0 >[pc : -1 locals: 1 stack items: 1 >locals: [I,top] >stack: [I] >] > >[pc : -1 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >] >146: goto >realjumpTarget: [-1, 52, 20, 53, 40, 44] > > >149: new >[pc : -1 locals: 1 stack items: 1 >locals: [I,top] >stack: [uninitialized(java/lang/Exception)] >] > > >152: dup >[pc : -1 locals: 1 stack items: 2 >locals: [I,top] >stack: [uninitialized(java/lang/Exception),uninitialized(java/lang/Exception)] >] > >153: invokespecial >(init) >[pc : -1 locals: 1 stack items: 1 >locals: [I,top] >stack: [java/lang/Exception] >] > >156: throw >[pc : -1 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >] >realJumpTarget: [-1, 52, 20, 53, 40, 44] > >frames: {-1=[pc : -1 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >], 20=[pc : 20 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >], 40=[pc : 40 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >], 44=[pc : 44 locals: 1 stack items: 0 >locals: [I,top] >stack: [] >]} > >for frame = >[pc : -1 locals: 1 stack items: -1 >locals: [I,top] >stack: [] >] >then at the st: >StackMapFrame.duplicate() line: 129 >ClassFile.traverse(MethodBinding, int, byte[], int, int, Map, boolean) line: 5955 >ClassFile.generateStackMapTableAttribute(MethodBinding, int, int, int, boolean) line: 4804 >ClassFile.completeCodeAttribute(int) line: 1513 >MethodDeclaration(AbstractMethodDeclaration).generateCode(ClassFile) line: 357 >MethodDeclaration(AbstractMethodDeclaration).generateCode(ClassScope, ClassFile) line: 281 >TypeDeclaration.generateCode(ClassFile) line: 583 >TypeDeclaration.generateCode(CompilationUnitScope) line: 653 >CompilationUnitDeclaration.generateCode() line: 410 > > length = this.numberOfStackItems; > if (length != 0) { >the length is -1 is here > >and an allocation of an array of negative size, causes NegativeArraySizeException which causes the abort >106: iload_3 >107: tableswitch >125: iload_3 >126: tableswitch >145: iconst_0 >146: goto >149: new >152: dup >153: invokespecial >156: throw => At this point, the error occurs > >Javac13 generated code â [disassembled by javap13 -p -c -v] > public static int foo(int) throws java.lang.Exception; > descriptor: (I)I > flags: (0x0009) ACC_PUBLIC, ACC_STATIC > Code: > stack=2, locals=2, args_size=1 > 0: iload_0 > 1: lookupswitch { // 1 > 0: 20 > default: 52 > } > 20: iload_0 > 21: lookupswitch { // 1 > 0: 40 > default: 44 > } > 40: iconst_0 > 41: goto 53 > 44: new #7 // class java/lang/Exception > 47: dup > 48: invokespecial #9 // Method java/lang/Exception."<init>":()V > 51: athrow > 52: iconst_0 > 53: istore_1 > 54: iload_1 > 55: ireturn > LineNumberTable: > line 4: 0 > line 5: 20 > line 6: 40 > line 7: 44 > line 9: 52 > line 11: 54 > StackMapTable: number_of_entries = 5 > frame_type = 20 /* same */ > frame_type = 19 /* same */ > frame_type = 3 /* same */ > frame_type = 7 /* same */ > frame_type = 64 /* same_locals_1_stack_item */ > stack = [ int ] > Exceptions: > throws java.lang.Exception >
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 Raw
Actions:
View
Attachments on
bug 544943
:
277728
| 279655