This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push: new ad1562df Replace use of deprecated code in examples ad1562df is described below commit ad1562df05fbb89afbdd75197025956b82b025ac Author: Gary David Gregory (Code signing key) <ggreg...@apache.org> AuthorDate: Fri Oct 7 14:15:37 2022 -0400 Replace use of deprecated code in examples Format tweaks --- src/examples/JasminVisitor.java | 4 ++-- src/examples/Mini/ASCII_CharStream.java | 3 +-- src/examples/Mini/ASTExpr.java | 5 ++--- src/examples/Mini/ASTFunAppl.java | 3 +-- src/examples/Mini/ASTFunDecl.java | 3 +-- src/examples/Mini/ASTIfExpr.java | 9 ++++----- src/examples/Mini/ASTLetExpr.java | 3 +-- src/examples/Mini/ASTProgram.java | 3 +-- src/examples/Mini/Environment.java | 1 - src/examples/Mini/Function.java | 3 +-- src/examples/Mini/Token.java | 1 - src/examples/Mini/Variable.java | 1 - src/examples/helloify.java | 3 +-- 13 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java index a2a7e6e1..c4ed2aba 100644 --- a/src/examples/JasminVisitor.java +++ b/src/examples/JasminVisitor.java @@ -24,7 +24,7 @@ import java.util.Date; import java.util.Hashtable; import java.util.StringTokenizer; -import org.apache.bcel.Constants; +import org.apache.bcel.Const; import org.apache.bcel.Repository; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.ClassParser; @@ -241,7 +241,7 @@ public class JasminVisitor extends org.apache.bcel.classfile.EmptyVisitor { final BranchInstruction bi = (BranchInstruction) inst; ih = bi.getTarget(); str = get(ih); - out.println("\t" + Constants.OPCODE_NAMES[bi.getOpcode()] + " " + str); + out.println("\t" + Const.getOpcodeName(bi.getOpcode()) + " " + str); } } else { out.println("\t" + inst.toString(cp.getConstantPool())); diff --git a/src/examples/Mini/ASCII_CharStream.java b/src/examples/Mini/ASCII_CharStream.java index a0413a2e..0f004d55 100644 --- a/src/examples/Mini/ASCII_CharStream.java +++ b/src/examples/Mini/ASCII_CharStream.java @@ -22,9 +22,8 @@ import java.io.IOException; /** * An implementation of interface CharStream, where the stream is assumed to contain only ASCII characters (without - * unicode processing). + * Unicode processing). */ - public final class ASCII_CharStream { public static final boolean staticFlag = true; static int bufsize; diff --git a/src/examples/Mini/ASTExpr.java b/src/examples/Mini/ASTExpr.java index 7fcff2ce..b568dea1 100644 --- a/src/examples/Mini/ASTExpr.java +++ b/src/examples/Mini/ASTExpr.java @@ -21,7 +21,6 @@ package Mini; import org.apache.bcel.Const; -import org.apache.bcel.Constants; import org.apache.bcel.generic.BranchHandle; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.GOTO; @@ -324,7 +323,7 @@ public class ASTExpr extends SimpleNode implements MiniParserConstants, MiniPars if (t != childType) { MiniC.addError(expr.getLine(), expr.getColumn(), - "Expression has not expected type " + Constants.TYPE_NAMES[childType] + " but " + Constants.TYPE_NAMES[t] + "."); + "Expression has not expected type " + Const.getTypeName(childType) + " but " + Const.getTypeName(t) + "."); } is_simple = is_simple && expr.isSimple(); @@ -395,7 +394,7 @@ public class ASTExpr extends SimpleNode implements MiniParserConstants, MiniPars op = tokenImage[kind]; } - return jjtNodeName[id] + "(" + op + ")[" + len + "]<" + Constants.TYPE_NAMES[type] + "> @" + line + ", " + column; + return jjtNodeName[id] + "(" + op + ")[" + len + "]<" + Const.getTypeName(type) + "> @" + line + ", " + column; } /** diff --git a/src/examples/Mini/ASTFunAppl.java b/src/examples/Mini/ASTFunAppl.java index b6034fed..fb38c270 100644 --- a/src/examples/Mini/ASTFunAppl.java +++ b/src/examples/Mini/ASTFunAppl.java @@ -21,7 +21,6 @@ package Mini; import org.apache.bcel.Const; -import org.apache.bcel.Constants; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.INVOKESTATIC; import org.apache.bcel.generic.InstructionList; @@ -175,7 +174,7 @@ public class ASTFunAppl extends ASTExpr { if (expect != Const.T_UNKNOWN && t_e != expect) { MiniC.addError(exprs[i].getLine(), exprs[i].getColumn(), "Argument " + (i + 1) + " in application of " + fname + " is not of type " - + Constants.TYPE_NAMES[expect] + " but " + Constants.TYPE_NAMES[t_e]); + + Const.getTypeName(expect) + " but " + Const.getTypeName(t_e)); } else { args[i].setType(t_e); // Update, may be identical } diff --git a/src/examples/Mini/ASTFunDecl.java b/src/examples/Mini/ASTFunDecl.java index adb76869..1f1123c2 100644 --- a/src/examples/Mini/ASTFunDecl.java +++ b/src/examples/Mini/ASTFunDecl.java @@ -24,7 +24,6 @@ import java.io.PrintWriter; import java.util.Iterator; import org.apache.bcel.Const; -import org.apache.bcel.Constants; import org.apache.bcel.generic.ALOAD; import org.apache.bcel.generic.ASTORE; import org.apache.bcel.generic.ArrayType; @@ -368,7 +367,7 @@ public class ASTFunDecl extends SimpleNode implements MiniParserTreeConstants { if (expected != Const.T_UNKNOWN && type != expected) { MiniC.addError(line, column, - "Function f ist not of type " + Constants.TYPE_NAMES[expected] + " as previously assumed, but " + Constants.TYPE_NAMES[type]); + "Function f ist not of type " + Const.getTypeName(expected) + " as previously assumed, but " + Const.getTypeName(type)); } name.setType(type); diff --git a/src/examples/Mini/ASTIfExpr.java b/src/examples/Mini/ASTIfExpr.java index 7983a38d..61ff62fd 100644 --- a/src/examples/Mini/ASTIfExpr.java +++ b/src/examples/Mini/ASTIfExpr.java @@ -21,7 +21,6 @@ package Mini; import org.apache.bcel.Const; -import org.apache.bcel.Constants; import org.apache.bcel.generic.BranchHandle; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.GOTO; @@ -127,14 +126,14 @@ public class ASTIfExpr extends ASTExpr { int thenType, elseType, ifType; if ((ifType = if_expr.eval(Const.T_BOOLEAN)) != Const.T_BOOLEAN) { - MiniC.addError(if_expr.getLine(), if_expr.getColumn(), "IF expression is not of type boolean, but " + Constants.TYPE_NAMES[ifType] + "."); + MiniC.addError(if_expr.getLine(), if_expr.getColumn(), "IF expression is not of type boolean, but " + Const.getTypeName(ifType) + "."); } thenType = then_expr.eval(expected); if (expected != Const.T_UNKNOWN && thenType != expected) { MiniC.addError(then_expr.getLine(), then_expr.getColumn(), - "THEN expression is not of expected type " + Constants.TYPE_NAMES[expected] + " but " + Constants.TYPE_NAMES[thenType] + "."); + "THEN expression is not of expected type " + Const.getTypeName(expected) + " but " + Const.getTypeName(thenType) + "."); } if (else_expr != null) { @@ -142,7 +141,7 @@ public class ASTIfExpr extends ASTExpr { if (expected != Const.T_UNKNOWN && elseType != expected) { MiniC.addError(else_expr.getLine(), else_expr.getColumn(), - "ELSE expression is not of expected type " + Constants.TYPE_NAMES[expected] + " but " + Constants.TYPE_NAMES[elseType] + "."); + "ELSE expression is not of expected type " + Const.getTypeName(expected) + " but " + Const.getTypeName(elseType) + "."); } else if (thenType == Const.T_UNKNOWN) { thenType = elseType; then_expr.setType(elseType); @@ -153,7 +152,7 @@ public class ASTIfExpr extends ASTExpr { } if (thenType != elseType) { - MiniC.addError(line, column, "Type mismatch in THEN-ELSE: " + Constants.TYPE_NAMES[thenType] + " vs. " + Constants.TYPE_NAMES[elseType] + "."); + MiniC.addError(line, column, "Type mismatch in THEN-ELSE: " + Const.getTypeName(thenType) + " vs. " + Const.getTypeName(elseType) + "."); } type = thenType; diff --git a/src/examples/Mini/ASTLetExpr.java b/src/examples/Mini/ASTLetExpr.java index 9ed50743..b49198e0 100644 --- a/src/examples/Mini/ASTLetExpr.java +++ b/src/examples/Mini/ASTLetExpr.java @@ -21,7 +21,6 @@ package Mini; import org.apache.bcel.Const; -import org.apache.bcel.Constants; import org.apache.bcel.generic.BasicType; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.ISTORE; @@ -122,7 +121,7 @@ public class ASTLetExpr extends ASTExpr { */ exprs[i].code(buf); - buf.append(" " + Constants.TYPE_NAMES[t] + " " + ident + " = " + ASTFunDecl.pop() + ";\n"); + buf.append(" " + Const.getTypeName(t) + " " + ident + " = " + ASTFunDecl.pop() + ";\n"); } body.code(buf); diff --git a/src/examples/Mini/ASTProgram.java b/src/examples/Mini/ASTProgram.java index 038130f0..60f45fcd 100644 --- a/src/examples/Mini/ASTProgram.java +++ b/src/examples/Mini/ASTProgram.java @@ -42,8 +42,7 @@ import org.apache.bcel.generic.RETURN; import org.apache.bcel.generic.Type; /** - * Root node of everything, direct children are nodes of type FunDecl - * + * Root node of everything, direct children are nodes of type FunDecl. */ public class ASTProgram extends SimpleNode implements MiniParserConstants, MiniParserTreeConstants { public static Node jjtCreate(final MiniParser p, final int id) { diff --git a/src/examples/Mini/Environment.java b/src/examples/Mini/Environment.java index 42b0a6ed..83211900 100644 --- a/src/examples/Mini/Environment.java +++ b/src/examples/Mini/Environment.java @@ -27,7 +27,6 @@ import java.util.Vector; * * The table consists of `SIZE' fields which have `SLOTS' subfields. Thus the maximum number of storable items is * `SLOTS' * `SIZE'. - * */ public class Environment implements Cloneable { private static final int SIZE = 127; // Prime number large enough for most cases diff --git a/src/examples/Mini/Function.java b/src/examples/Mini/Function.java index b70c4275..ca5ca07b 100644 --- a/src/examples/Mini/Function.java +++ b/src/examples/Mini/Function.java @@ -19,9 +19,8 @@ package Mini; /** * Represents a function declaration and its arguments. Type information is contained in the ASTIdent fields. - * */ -public class Function implements org.apache.bcel.Constants, EnvEntry { +public class Function implements EnvEntry { private final ASTIdent name; // Reference to the original declaration private ASTIdent[] args; // Reference to argument identifiers // private ASTExpr body; // Reference to function expression body diff --git a/src/examples/Mini/Token.java b/src/examples/Mini/Token.java index 71450a60..21c539bb 100644 --- a/src/examples/Mini/Token.java +++ b/src/examples/Mini/Token.java @@ -21,7 +21,6 @@ package Mini; /** * Describes the input token stream. */ - public class Token { /** diff --git a/src/examples/Mini/Variable.java b/src/examples/Mini/Variable.java index 1dfa69d1..58dfc040 100644 --- a/src/examples/Mini/Variable.java +++ b/src/examples/Mini/Variable.java @@ -21,7 +21,6 @@ import org.apache.bcel.generic.LocalVariableGen; /** * Represents a variable declared in a LET expression or a FUN declaration. - * */ public class Variable implements EnvEntry { private final ASTIdent name; // Reference to the original declaration diff --git a/src/examples/helloify.java b/src/examples/helloify.java index c8aba59f..5b834ade 100644 --- a/src/examples/helloify.java +++ b/src/examples/helloify.java @@ -16,7 +16,6 @@ * */ -import org.apache.bcel.Constants; import org.apache.bcel.classfile.ClassParser; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantClass; @@ -39,7 +38,7 @@ import org.apache.bcel.generic.PUSH; * anything else. * */ -public final class helloify implements Constants { +public final class helloify { private static String className; private static ConstantPoolGen cp;