diff --git a/src/org/jetbrains/java/decompiler/code/CodeConstants.java b/src/org/jetbrains/java/decompiler/code/CodeConstants.java index 4a7ef0f..18d1ddb 100644 --- a/src/org/jetbrains/java/decompiler/code/CodeConstants.java +++ b/src/org/jetbrains/java/decompiler/code/CodeConstants.java @@ -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. @@ -367,4 +367,8 @@ public interface CodeConstants { int opc_ifnonnull = 199; int opc_goto_w = 200; int opc_jsr_w = 201; + + @SuppressWarnings("SpellCheckingInspection") + String CLINIT_NAME = ""; + String INIT_NAME = ""; } diff --git a/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java b/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java index b97accf..adce2b7 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java +++ b/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java @@ -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. @@ -58,7 +58,7 @@ public class ClassReference14Processor { VarType.VARTYPE_CLASS, null); InvocationExprent constr = new InvocationExprent(); - constr.setName(""); + constr.setName(CodeConstants.INIT_NAME); constr.setClassname("java/lang/NoClassDefFoundError"); constr.setStringDescriptor("()V"); constr.setFunctype(InvocationExprent.TYP_INIT); diff --git a/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/src/org/jetbrains/java/decompiler/main/ClassWriter.java index 6c08ef8..35aaaa6 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -590,7 +590,7 @@ public class ClassWriter { if ((flags & CodeConstants.ACC_NATIVE) != 0) { flags &= ~CodeConstants.ACC_STRICT; // compiler bug: a strictfp class sets all methods to strictfp } - if ("".equals(mt.getName())) { + if (CodeConstants.CLINIT_NAME.equals(mt.getName())) { flags &= CodeConstants.ACC_STATIC; // ignore all modifiers except 'static' in a static initializer } @@ -624,7 +624,7 @@ public class ClassWriter { } String name = mt.getName(); - if ("".equals(name)) { + if (CodeConstants.INIT_NAME.equals(name)) { if (node.type == ClassNode.CLASS_ANONYMOUS) { name = ""; dinit = true; @@ -634,7 +634,7 @@ public class ClassWriter { init = true; } } - else if ("".equals(name)) { + else if (CodeConstants.CLINIT_NAME.equals(name)) { name = ""; clinit = true; } @@ -903,7 +903,7 @@ public class ClassWriter { int count = 0; for (StructMethod mt : wrapper.getClassStruct().getMethods()) { - if ("".equals(mt.getName())) { + if (CodeConstants.INIT_NAME.equals(mt.getName())) { if (++count > 1) { return false; } diff --git a/src/org/jetbrains/java/decompiler/main/EnumProcessor.java b/src/org/jetbrains/java/decompiler/main/EnumProcessor.java index d3a0db1..37a3384 100644 --- a/src/org/jetbrains/java/decompiler/main/EnumProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/EnumProcessor.java @@ -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; +import org.jetbrains.java.decompiler.code.CodeConstants; import org.jetbrains.java.decompiler.main.rels.ClassWrapper; import org.jetbrains.java.decompiler.main.rels.MethodWrapper; import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; @@ -48,7 +49,7 @@ public class EnumProcessor { wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(name, descriptor)); } } - else if ("".equals(name)) { + else if (CodeConstants.INIT_NAME.equals(name)) { Statement firstData = findFirstData(method.root); if (firstData != null && !firstData.getExprents().isEmpty()) { Exprent exprent = firstData.getExprents().get(0); diff --git a/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java b/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java index d85e754..d9a0a3d 100644 --- a/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java @@ -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. @@ -36,7 +36,7 @@ public class InitializerProcessor { public static void extractInitializers(ClassWrapper wrapper) { - MethodWrapper meth = wrapper.getMethodWrapper("", "()V"); + MethodWrapper meth = wrapper.getMethodWrapper(CodeConstants.CLINIT_NAME, "()V"); if (meth != null && meth.root != null) { // successfully decompiled static constructor extractStaticInitializers(wrapper, meth); } @@ -56,7 +56,7 @@ public class InitializerProcessor { private static void liftConstructor(ClassWrapper wrapper) { for (MethodWrapper meth : wrapper.getMethods()) { - if ("".equals(meth.methodStruct.getName()) && meth.root != null) { + if (CodeConstants.INIT_NAME.equals(meth.methodStruct.getName()) && meth.root != null) { Statement firstdata = findFirstData(meth.root); if (firstdata == null) { return; @@ -103,7 +103,7 @@ public class InitializerProcessor { private static void hideEmptySuper(ClassWrapper wrapper) { for (MethodWrapper meth : wrapper.getMethods()) { - if ("".equals(meth.methodStruct.getName()) && meth.root != null) { + if (CodeConstants.INIT_NAME.equals(meth.methodStruct.getName()) && meth.root != null) { Statement firstdata = findFirstData(meth.root); if (firstdata == null || firstdata.getExprents().isEmpty()) { return; @@ -169,7 +169,7 @@ public class InitializerProcessor { List lstMethWrappers = new ArrayList(); for (MethodWrapper meth : wrapper.getMethods()) { - if ("".equals(meth.methodStruct.getName()) && meth.root != null) { // successfully decompiled constructor + if (CodeConstants.INIT_NAME.equals(meth.methodStruct.getName()) && meth.root != null) { // successfully decompiled constructor Statement firstdata = findFirstData(meth.root); if (firstdata == null || firstdata.getExprents().isEmpty()) { return; diff --git a/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java b/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java index 786babf..f3fba85 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java +++ b/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java @@ -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 = "".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(); diff --git a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java index 3739979..798010e 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java @@ -427,7 +427,7 @@ public class NestedClassProcessor { for (Entry> entmt : entcl.getValue().entrySet()) { mergeListSignatures(entmt.getValue(), intrPairMask, false); - MethodWrapper meth = nestedNode.getWrapper().getMethodWrapper("", entmt.getKey()); + MethodWrapper meth = nestedNode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, entmt.getKey()); meth.signatureFields = new ArrayList(); for (VarFieldPair pair : entmt.getValue()) { @@ -577,7 +577,7 @@ public class NestedClassProcessor { } } - if (child.type == ClassNode.CLASS_ANONYMOUS && "".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 ("".equals(mt.getName())) { + if (CodeConstants.INIT_NAME.equals(mt.getName())) { MethodDescriptor md = MethodDescriptor.parseDescriptor(mt.getDescriptor()); - MethodWrapper meth = wrapper.getMethodWrapper("", 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 diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java index 2effc82..001e428 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java @@ -92,10 +92,10 @@ public class InvocationExprent extends Exprent { invokeDynamicClassSuffix = "##Lambda_" + cn.index1 + "_" + cn.index2; } - if ("".equals(name)) { + if (CodeConstants.INIT_NAME.equals(name)) { functype = TYP_INIT; } - else if ("".equals(name)) { + else if (CodeConstants.CLINIT_NAME.equals(name)) { functype = TYP_CLINIT; } @@ -307,7 +307,7 @@ public class InvocationExprent extends Exprent { break; case TYP_CLINIT: - throw new RuntimeException("Explicit invocation of "); + throw new RuntimeException("Explicit invocation of " + CodeConstants.CLINIT_NAME); case TYP_INIT: if (super_qualifier != null) { buf.append("super("); @@ -316,7 +316,7 @@ public class InvocationExprent extends Exprent { buf.append("this("); } else { - throw new RuntimeException("Unrecognized invocation of "); + throw new RuntimeException("Unrecognized invocation of " + CodeConstants.INIT_NAME); } } @@ -327,7 +327,7 @@ public class InvocationExprent extends Exprent { if (newNode != null) { // own class if (newNode.getWrapper() != null) { - sigFields = newNode.getWrapper().getMethodWrapper("", stringDescriptor).signatureFields; + sigFields = newNode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, stringDescriptor).signatureFields; } else { if (newNode.type == ClassNode.CLASS_MEMBER && (newNode.access & CodeConstants.ACC_STATIC) == 0) { // non-static member class diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java index 5fe944d..91cc24e 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java @@ -177,7 +177,7 @@ public class NewExprent extends Exprent { List sigFields = null; if (newnode != null) { // own class if (newnode.getWrapper() != null) { - sigFields = newnode.getWrapper().getMethodWrapper("", invsuper.getStringDescriptor()).signatureFields; + sigFields = newnode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, invsuper.getStringDescriptor()).signatureFields; } else { if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && @@ -287,7 +287,7 @@ public class NewExprent extends Exprent { List sigFields = null; if (newnode != null) { // own class if (newnode.getWrapper() != null) { - sigFields = newnode.getWrapper().getMethodWrapper("", constructor.getStringDescriptor()).signatureFields; + sigFields = newnode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, constructor.getStringDescriptor()).signatureFields; } else { if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 &&