Skip to content

Instantly share code, notes, and snippets.

@rednaxelafx
Created May 9, 2012 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rednaxelafx/2643784 to your computer and use it in GitHub Desktop.
Save rednaxelafx/2643784 to your computer and use it in GitHub Desktop.
example of verifying class files with the Maxine verifier
D:\code\hg\maxine>mx --cp-pfx . verify "^Foo^"
WARNING: Could not create platform from native properties - using default platform
instead: linux-amd64, isa=AMD64, 64-bit, little endian, 64-byte aligned cache, page size=8192
Initializing verifier system...
Initialized verifier system
Finding specified methods...
Found 2 methods
Verifying Foo.<init>() via type-checking
Verifying Foo.bar(int) via type-checking
D:\code\hg\maxine>mx --cp-pfx . verify -verbose "^Foo^"
WARNING: Could not create platform from native properties - using default platform
instead: linux-amd64, isa=AMD64, 64-bit, little endian, 64-byte aligned cache, page size=8192
Initializing verifier system...
Initialized verifier system
Finding specified methods...
Found 2 methods
[Verifying Foo.<init>() via type-checking]
Input bytecode:
Stack=1, Locals=1
[1] 0: aload_0 | 42
[1] 1: invokespecial java.lang.Object.<init>():void | 183 0 1
[1] 4: return | 177
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Descriptor Generic-signature
0 5 0 this LFoo;
StackMapTable frames:
0: local[0] = uninitializedThis
Interpreting bytecode:
local[0] = uninitializedThis
0: aload_0
stack[0] = uninitializedThis
local[0] = uninitializedThis
1: invokespecial
local[0] = Foo
4: return
[Verifying Foo.bar(int) via type-checking]
Input bytecode:
Stack=1, Locals=3
[3] 0: iconst_0 | 3
[3] 1: istore_2 | 61
[4] 2: iload_1 | 27
[4] 3: tableswitch default:50 low:0 high:3 0:32 1:37 2:39 3:44 | 170 0 0 0 47 0 0 0 0 0 0 0 3 0 0 0 29 0 0 0 34 0 0 0 36 0 0 0 41
[5] 32: iconst_0 | 3
[5] 33: istore_2 | 61
[5] 34: goto 52 | 167 0 18
[6] 37: iconst_2 | 5
[6] 38: istore_2 | 61
[7] 39: iconst_4 | 7
[7] 40: istore_2 | 61
[7] 41: goto 52 | 167 0 11
[8] 44: bipush 8 | 16 8
[8] 46: istore_2 | 61
[8] 47: goto 52 | 167 0 5
[9] 50: iconst_m1 | 2
[9] 51: istore_2 | 61
[11] 52: return | 177
StackMapTable: number of entries = 6
32: frame_type = 252 /* append_frame */
offset_delta = 32
locals = [ int ]
37: frame_type = 4 /* same_frame */
offset_delta = 4 /* implicit */
39: frame_type = 1 /* same_frame */
offset_delta = 1 /* implicit */
44: frame_type = 4 /* same_frame */
offset_delta = 4 /* implicit */
50: frame_type = 5 /* same_frame */
offset_delta = 5 /* implicit */
52: frame_type = 1 /* same_frame */
offset_delta = 1 /* implicit */
LineNumberTable:
line 3: 0
line 4: 2
line 5: 32
line 6: 37
line 7: 39
line 8: 44
line 9: 50
line 11: 52
LocalVariableTable:
Start Length Slot Name Descriptor Generic-signature
0 53 0 this LFoo;
0 53 1 i I
2 51 2 j I
StackMapTable frames:
0: local[0] = Foo
[1] = int
32: local[0] = Foo
[1] = int
[2] = int
37: local[0] = Foo
[1] = int
[2] = int
39: local[0] = Foo
[1] = int
[2] = int
44: local[0] = Foo
[1] = int
[2] = int
50: local[0] = Foo
[1] = int
[2] = int
52: local[0] = Foo
[1] = int
[2] = int
Interpreting bytecode:
local[0] = Foo
[1] = int
0: iconst_0
stack[0] = int
local[0] = Foo
[1] = int
1: istore_2
local[0] = Foo
[1] = int
[2] = int
2: iload_1
stack[0] = int
local[0] = Foo
[1] = int
[2] = int
3: tableswitch
local[0] = Foo
[1] = int
[2] = int
32: iconst_0
stack[0] = int
local[0] = Foo
[1] = int
[2] = int
33: istore_2
local[0] = Foo
[1] = int
[2] = int
34: goto
local[0] = Foo
[1] = int
[2] = int
37: iconst_2
stack[0] = int
local[0] = Foo
[1] = int
[2] = int
38: istore_2
local[0] = Foo
[1] = int
[2] = int
39: iconst_4
stack[0] = int
local[0] = Foo
[1] = int
[2] = int
40: istore_2
local[0] = Foo
[1] = int
[2] = int
41: goto
local[0] = Foo
[1] = int
[2] = int
44: bipush
stack[0] = int
local[0] = Foo
[1] = int
[2] = int
46: istore_2
local[0] = Foo
[1] = int
[2] = int
47: goto
local[0] = Foo
[1] = int
[2] = int
50: iconst_m1
stack[0] = int
local[0] = Foo
[1] = int
[2] = int
51: istore_2
local[0] = Foo
[1] = int
[2] = int
52: return
D:\code\hg\maxine>
public class Foo {
public void bar(int i) {
int j = 0;
switch (i) {
case 0: j = 0; break;
case 1: j = 2;
case 2: j = 4; break;
case 3: j = 8; break;
default: j = -1; break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment