You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/09/11 15:54:01 UTC

svn commit: r1702468 - in /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util: BCELFactory.java BCELifier.java

Author: sebb
Date: Fri Sep 11 13:54:01 2015
New Revision: 1702468

URL: http://svn.apache.org/r1702468
Log:
Fix up strings to use the new non-deprecated class name

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELFactory.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELFactory.java?rev=1702468&r1=1702467&r2=1702468&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELFactory.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELFactory.java Fri Sep 11 13:54:01 2015
@@ -65,6 +65,7 @@ import org.apache.commons.bcel6.generic.
  */
 class BCELFactory extends EmptyVisitor {
 
+    private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
     private final MethodGen _mg;
     private final PrintWriter _out;
     private final ConstantPoolGen _cp;
@@ -150,7 +151,7 @@ class BCELFactory extends EmptyVisitor {
         String field_name = i.getFieldName(_cp);
         Type type = i.getFieldType(_cp);
         _out.println("il.append(_factory.createFieldAccess(\"" + class_name + "\", \"" + field_name
-                + "\", " + BCELifier.printType(type) + ", " + "Constants."
+                + "\", " + BCELifier.printType(type) + ", " + CONSTANT_PREFIX
                 + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
     }
 
@@ -164,7 +165,7 @@ class BCELFactory extends EmptyVisitor {
         Type[] arg_types = i.getArgumentTypes(_cp);
         _out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name
                 + "\", " + BCELifier.printType(type) + ", "
-                + BCELifier.printArgumentTypes(arg_types) + ", " + "Constants."
+                + BCELifier.printArgumentTypes(arg_types) + ", " + CONSTANT_PREFIX
                 + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
     }
 
@@ -298,7 +299,7 @@ class BCELFactory extends EmptyVisitor {
                 target = "null";
             }
             _out.println("    BranchInstruction " + name + " = _factory.createBranchInstruction("
-                    + "Constants." + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target
+                    + CONSTANT_PREFIX + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target
                     + ");");
         }
         if (bh.hasTargeters()) {

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java?rev=1702468&r1=1702467&r2=1702468&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java Fri Sep 11 13:54:01 2015
@@ -55,8 +55,11 @@ public class BCELifier extends org.apach
         METHOD,
     };
 
-    // The base package name for imports; assumes Constants is at the top level
+    // The base package name for imports; assumes Const is at the top level
+    // N.B we use the class so renames will be detected by the compiler/IDE
     private static final String BASE_PACKAGE = Const.class.getPackage().getName();
+    private static final String CONSTANT_PREFIX = Const.class.getSimpleName()+".";
+
     private final JavaClass _clazz;
     private final PrintWriter _out;
     private final ConstantPoolGen _cp;
@@ -95,7 +98,7 @@ public class BCELifier extends org.apach
         _out.println("import " + BASE_PACKAGE + ".*;");
         _out.println("import java.io.*;");
         _out.println();
-        _out.println("public class " + class_name + "Creator implements Constants {");
+        _out.println("public class " + class_name + "Creator {");
         _out.println("  private InstructionFactory _factory;");
         _out.println("  private ConstantPoolGen    _cp;");
         _out.println("  private ClassGen           _cg;");
@@ -212,16 +215,16 @@ public class BCELifier extends org.apach
         for (int i = 0, pow = 1; pow <= Const.MAX_ACC_FLAG; i++) {
             if ((flags & pow) != 0) {
                 if ((pow == Const.ACC_SYNCHRONIZED) && (location == FLAGS.CLASS)) {
-                    buf.append("ACC_SUPER | ");
+                    buf.append(CONSTANT_PREFIX+"ACC_SUPER | ");
                 } else if ((pow == Const.ACC_VOLATILE) && (location == FLAGS.METHOD)) {
-                    buf.append("ACC_BRIDGE | ");
+                    buf.append(CONSTANT_PREFIX+"ACC_BRIDGE | ");
                 } else if ((pow == Const.ACC_TRANSIENT) && (location == FLAGS.METHOD)) {
-                    buf.append("ACC_VARARGS | ");
+                    buf.append(CONSTANT_PREFIX+"ACC_VARARGS | ");
                 } else {
                     if (i < Const.ACCESS_NAMES_LENGTH) {
-                        buf.append("ACC_").append(Const.getAccessName(i).toUpperCase(Locale.ENGLISH)).append( " | ");
+                        buf.append(CONSTANT_PREFIX+"ACC_").append(Const.getAccessName(i).toUpperCase(Locale.ENGLISH)).append( " | ");
                     } else {
-                        buf.append(String.format ("ACC_BIT %x | ", pow));
+                        buf.append(String.format (CONSTANT_PREFIX+"ACC_BIT %x | ", pow));
                     }
                 }
             }