< prev index next > test/hotspot/jtreg/gc/stress/gcbasher/Decompiler.java
Print this page
/*
! * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
/*
! * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
class Decompiler {
private ByteCursor cursor;
private ClassInfo ci;
! public Decompiler(byte[] classData) {
cursor = new ByteCursor(classData);
int magicNumber = cursor.readInt();
if (magicNumber != 0xCAFEBABE) {
throw new IllegalArgumentException("Bad magic number " + magicNumber);
class Decompiler {
private ByteCursor cursor;
private ClassInfo ci;
! public Decompiler(Byte[] classData) {
cursor = new ByteCursor(classData);
int magicNumber = cursor.readInt();
if (magicNumber != 0xCAFEBABE) {
throw new IllegalArgumentException("Bad magic number " + magicNumber);
private boolean isDependency(String name, String className) {
return !name.equals(className) && !name.startsWith("[");
}
private void addDependency(MethodInfo m, String name) {
! Dependency d = new Dependency(m.getName(), m.getDescriptor(), name);
ci.addResolutionDep(d);
}
private String resolveName(ConstantPoolEntry[] constantPool, int cpi) {
int nameIndex = constantPool[cpi].getNameIndex();
private boolean isDependency(String name, String className) {
return !name.equals(className) && !name.startsWith("[");
}
private void addDependency(MethodInfo m, String name) {
! Dependency d = new Dependency(m.name(), m.descriptor(), name);
ci.addResolutionDep(d);
}
private String resolveName(ConstantPoolEntry[] constantPool, int cpi) {
int nameIndex = constantPool[cpi].getNameIndex();
}
private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[] constantPool) {
for (int i = 0; i < methods.length; i++) {
MethodInfo m = methods[i];
! final int stopCheck = m.getCodeStart() + m.getCodeLength();
! int byteCodeIndex = m.getCodeStart();
while (byteCodeIndex < stopCheck) {
int bc = cursor.readUnsignedByteAt(byteCodeIndex);
switch (bc) {
// These opcodes cause name resolution or initialization
}
private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[] constantPool) {
for (int i = 0; i < methods.length; i++) {
MethodInfo m = methods[i];
! final int stopCheck = m.codeStart() + m.codeLength();
! int byteCodeIndex = m.codeStart();
while (byteCodeIndex < stopCheck) {
int bc = cursor.readUnsignedByteAt(byteCodeIndex);
switch (bc) {
// These opcodes cause name resolution or initialization
break;
}
case Bytecode.LOOKUPSWITCH: {
byteCodeIndex++;
! int offset = byteCodeIndex - m.getCodeStart();
while (offset % 4 != 0) {
offset++;
byteCodeIndex++;
}
break;
}
case Bytecode.LOOKUPSWITCH: {
byteCodeIndex++;
! int offset = byteCodeIndex - m.codeStart();
while (offset % 4 != 0) {
offset++;
byteCodeIndex++;
}
continue;
}
case Bytecode.TABLESWITCH: {
byteCodeIndex++;
! int offset = byteCodeIndex - m.getCodeStart();
while (offset % 4 != 0) {
offset++;
byteCodeIndex++;
}
continue;
}
case Bytecode.TABLESWITCH: {
byteCodeIndex++;
! int offset = byteCodeIndex - m.codeStart();
while (offset % 4 != 0) {
offset++;
byteCodeIndex++;
}
byteCodeIndex += Bytecode.getLength(bc);
}
if (byteCodeIndex - stopCheck > 1) {
! String err = "bad finish for method " + m.getName() +
"End + " + (byteCodeIndex - stopCheck);
throw new IllegalArgumentException(err);
}
}
}
byteCodeIndex += Bytecode.getLength(bc);
}
if (byteCodeIndex - stopCheck > 1) {
! String err = "bad finish for method " + m.name() +
"End + " + (byteCodeIndex - stopCheck);
throw new IllegalArgumentException(err);
}
}
}
cursor.readUnsignedShort(); // access flags
String name = constantPool[cursor.readUnsignedShort()].getValue();
String descriptor = constantPool[cursor.readUnsignedShort()].getValue();
! int codeLength = 0;
! int codeStart = 0;
int numAttributes = cursor.readUnsignedShort(); // attributes count
for (int j = 0; j < numAttributes; j++) {
int type = cursor.readUnsignedShort(); // attrib nameIndex
int aLen = cursor.readInt(); // attrib length
cursor.readUnsignedShort(); // access flags
String name = constantPool[cursor.readUnsignedShort()].getValue();
String descriptor = constantPool[cursor.readUnsignedShort()].getValue();
! Integer codeLength = 0;
! Integer codeStart = 0;
int numAttributes = cursor.readUnsignedShort(); // attributes count
for (int j = 0; j < numAttributes; j++) {
int type = cursor.readUnsignedShort(); // attrib nameIndex
int aLen = cursor.readInt(); // attrib length
< prev index next >