decompiler: extracted <init> and <clinit> to constants

This commit is contained in:
Egor.Ushakov
2015-01-22 12:30:12 +03:00
parent 9ba9af5425
commit effbed6727
9 changed files with 33 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package org.jetbrains.java.decompiler.main.rels;
import org.jetbrains.java.decompiler.code.CodeConstants;
import org.jetbrains.java.decompiler.code.InstructionSequence;
import org.jetbrains.java.decompiler.code.cfg.ControlFlowGraph;
import org.jetbrains.java.decompiler.main.DecompilerContext;
@@ -78,7 +79,7 @@ public class MethodProcessorRunnable implements Runnable {
public static RootStatement codeToJava(StructMethod mt, VarProcessor varProc) throws IOException {
StructClass cl = mt.getClassStruct();
boolean isInitializer = "<clinit>".equals(mt.getName()); // for now static initializer only
boolean isInitializer = CodeConstants.CLINIT_NAME.equals(mt.getName()); // for now static initializer only
mt.expandData();
InstructionSequence seq = mt.getInstructionSequence();

View File

@@ -427,7 +427,7 @@ public class NestedClassProcessor {
for (Entry<String, List<VarFieldPair>> entmt : entcl.getValue().entrySet()) {
mergeListSignatures(entmt.getValue(), intrPairMask, false);
MethodWrapper meth = nestedNode.getWrapper().getMethodWrapper("<init>", entmt.getKey());
MethodWrapper meth = nestedNode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, entmt.getKey());
meth.signatureFields = new ArrayList<VarVersionPair>();
for (VarFieldPair pair : entmt.getValue()) {
@@ -577,7 +577,7 @@ public class NestedClassProcessor {
}
}
if (child.type == ClassNode.CLASS_ANONYMOUS && "<init>".equals(meth.methodStruct.getName())
if (child.type == ClassNode.CLASS_ANONYMOUS && CodeConstants.INIT_NAME.equals(meth.methodStruct.getName())
&& exprent.type == Exprent.EXPRENT_INVOCATION) {
InvocationExprent invexpr = (InvocationExprent)exprent;
if (invexpr.getFunctype() == InvocationExprent.TYP_INIT) {
@@ -646,11 +646,11 @@ public class NestedClassProcessor {
// iterate over constructors
for (StructMethod mt : cl.getMethods()) {
if ("<init>".equals(mt.getName())) {
if (CodeConstants.INIT_NAME.equals(mt.getName())) {
MethodDescriptor md = MethodDescriptor.parseDescriptor(mt.getDescriptor());
MethodWrapper meth = wrapper.getMethodWrapper("<init>", mt.getDescriptor());
MethodWrapper meth = wrapper.getMethodWrapper(CodeConstants.INIT_NAME, mt.getDescriptor());
DirectGraph graph = meth.getOrBuildGraph();
if (graph != null) { // something gone wrong, should not be null