You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using ByteBuddy generate enum Gender, get byte array, de-compile to source. Throw StackOverflowError.
java.lang.StackOverflowError
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadClassFile(TypeMaker.java:1577)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadFieldsAndMethods(TypeMaker.java:1473)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadFieldsAndMethods(TypeMaker.java:1457)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1261)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1298)
at org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker.loadMethodTypes(TypeMaker.java:1269)
...repeat...
My code is:
String enumClassName = "com.zco.lab.jdcore.enums.Gender";
DynamicType.Unloaded<? extends Enum<?>> unloaded = new ByteBuddy(ClassFileVersion.JAVA_V8)
.makeEnumeration("MALE", "FEMALE")
.name(enumClassName)
.make();
// save class
unloaded.saveIn(new File("target/classes"));
byte[] bytes = unloaded.getBytes();
// de-compile
deCompile(enumClassName, bytes);
method deCompile:
private void deCompile(String className, byte[] bytes) throws Exception {
Loader loader = new Loader() {
@Override
public boolean canLoad(String s) {
return true;
}
@Override
public byte[] load(String s) throws LoaderException {
return bytes;
}
};
Printer printer = new Printer() {
protected static final String TAB = " ";
protected static final String NEWLINE = "\n";
protected int indentationCount = 0;
protected final StringBuilder sb = new StringBuilder();
@Override
public String toString() {
return sb.toString();
}
@Override
public void start(int maxLineNumber, int majorVersion, int minorVersion) {
}
@Override
public void end() {
}
@Override
public void printText(String text) {
sb.append(text);
}
@Override
public void printNumericConstant(String constant) {
sb.append(constant);
}
@Override
public void printStringConstant(String constant, String ownerInternalName) {
sb.append(constant);
}
@Override
public void printKeyword(String keyword) {
sb.append(keyword);
}
@Override
public void printDeclaration(int type, String internalTypeName, String name, String descriptor) {
sb.append(name);
}
@Override
public void printReference(int type, String internalTypeName, String name, String descriptor,
String ownerInternalName) {
sb.append(name);
}
@Override
public void indent() {
this.indentationCount++;
}
@Override
public void unindent() {
this.indentationCount--;
}
@Override
public void startLine(int lineNumber) {
for (int i = 0; i < indentationCount; i++) sb.append(TAB);
}
@Override
public void endLine() {
sb.append(NEWLINE);
}
@Override
public void extraLine(int count) {
while (count-- > 0) sb.append(NEWLINE);
}
@Override
public void startMarker(int type) {
}
@Override
public void endMarker(int type) {
}
};
ClassFileToJavaSourceDecompiler decompiler = new ClassFileToJavaSourceDecompiler();
String path = className.replace(".", "/");
decompiler.decompile(loader, printer, path);
String source = printer.toString();
System.out.println(source);
System.out.println();
}
Using ByteBuddy generate enum Gender, get byte array, de-compile to source. Throw StackOverflowError.
My code is:
method deCompile:
Maven dependencies
Open Gender.class in Idea is OK.
Open Gender.class with JD-GUI 1.6.6 (jd-core 1.1.3) is OK.
The text was updated successfully, but these errors were encountered: