You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/01 00:37:29 UTC
svn commit: r418401 [28/32] - in /incubator/openjpa/trunk: openjpa-lib/
openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/
openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/
openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-lib/src/...
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MethodInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MethodInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MethodInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MethodInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,21 +12,16 @@
*/
package serp.bytecode;
+import java.io.*;
+import java.lang.reflect.*;
import serp.bytecode.lowlevel.*;
-
import serp.bytecode.visitor.*;
-
import serp.util.*;
-import java.io.*;
-
-import java.lang.reflect.*;
-
-
/**
- * <p>An instruction that invokes a method.</p>
- *
- * @author Abe White
+ * An instruction that invokes a method.
+ *
+ * @author Abe White
*/
public class MethodInstruction extends Instruction {
private int _index = 0;
@@ -39,73 +31,58 @@
}
int getLength() {
- if (getOpcode() == Constants.INVOKEINTERFACE) {
+ if (getOpcode() == Constants.INVOKEINTERFACE)
return super.getLength() + 4;
- }
-
return super.getLength() + 2;
}
public int getLogicalStackChange() {
String ret = getMethodReturnName();
-
- if (ret == null) {
+ if (ret == null)
return 0;
- }
int stack = 0;
// subtract a stack pos for the this ptr
- if (getOpcode() != Constants.INVOKESTATIC) {
+ if (getOpcode() != Constants.INVOKESTATIC)
stack--;
- }
// and for each arg
String[] params = getMethodParamNames();
-
- for (int i = 0; i < params.length; i++)
+ for (int i = 0; i < params.length; i++ )
stack--;
// add for the return value, if any
- if (!void.class.getName().equals(ret)) {
+ if (!void.class.getName().equals(ret))
stack++;
- }
return stack;
}
public int getStackChange() {
String ret = getMethodReturnName();
-
- if (ret == null) {
+ if (ret == null)
return 0;
- }
int stack = 0;
// subtract a stack pos for the this ptr
- if (getOpcode() != Constants.INVOKESTATIC) {
+ if (getOpcode() != Constants.INVOKESTATIC)
stack--;
- }
- // and for each arg (2 for longs, doubles)
+ // and for each arg(2 for longs, doubles)
String[] params = getMethodParamNames();
-
for (int i = 0; i < params.length; i++, stack--)
- if (long.class.getName().equals(params[i]) ||
- double.class.getName().equals(params[i])) {
+ if (long.class.getName().equals(params[i])
+ || double.class.getName().equals(params[i]))
stack--;
- }
// add for the return value, if any
- if (!void.class.getName().equals(ret)) {
+ if (!void.class.getName().equals(ret))
stack++;
- }
-
- if (long.class.getName().equals(ret) ||
- double.class.getName().equals(ret)) {
+ if (long.class.getName().equals(ret)
+ || double.class.getName().equals(ret))
stack++;
- }
return stack;
}
@@ -115,252 +92,218 @@
/////////////////////
/**
- * Return the index in the class {@link ConstantPool} of the
- * {@link ComplexEntry} describing the method to operate on.
+ * Return the index in the class {@link ConstantPool} of the
+ * {@link ComplexEntry} describing the method to operate on.
*/
public int getMethodIndex() {
return _index;
}
/**
- * Set the index in the class {@link ConstantPool} of the
- * {@link ComplexEntry} describing the method to operate on.
- *
- * @return this instruction, for method chaining
+ * Set the index in the class {@link ConstantPool} of the
+ * {@link ComplexEntry} describing the method to operate on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodIndex(int index) {
_index = index;
-
return this;
}
/**
- * Return the method this instruction operates on, or null if not set.
+ * Return the method this instruction operates on, or null if not set.
*/
public BCMethod getMethod() {
String dec = getMethodDeclarerName();
-
- if (dec == null) {
+ if (dec == null)
return null;
- }
BCClass bc = getProject().loadClass(dec, getClassLoader());
- BCMethod[] meths = bc.getMethods(getMethodName(), getMethodParamNames());
+ BCMethod[] meths = bc.getMethods(getMethodName(),
+ getMethodParamNames());
- if (meths.length == 0) {
+ if (meths.length == 0)
return null;
- }
-
return meths[0];
}
/**
- * Set the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(BCMethod method) {
- if (method == null) {
+ if (method == null)
return setMethodIndex(0);
- }
-
return setMethod(method.getDeclarer().getName(), method.getName(),
method.getReturnName(), method.getParamNames());
}
/**
- * Set the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(Method method) {
- if (method == null) {
+ if (method == null)
return setMethodIndex(0);
- }
-
return setMethod(method.getDeclaringClass(), method.getName(),
method.getReturnType(), method.getParameterTypes());
}
/**
- * Set the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(Constructor method) {
- if (method == null) {
+ if (method == null)
return setMethodIndex(0);
- }
setOpcode(Constants.INVOKESPECIAL);
-
- return setMethod(method.getDeclaringClass(), "<init>", void.class,
- method.getParameterTypes());
+ return setMethod(method.getDeclaringClass(), "<init>",
+ void.class, method.getParameterTypes());
}
/**
- * Set the method this instruction operates on.
- *
- * @param dec the full class name of the method's declaring class
- * @param name the method name
- * @param returnType the full class name of the method return type
- * @param param the full class names of the method param types
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on.
+ *
+ * @param dec the full class name of the method's declaring class
+ * @param name the method name
+ * @param returnType the full class name of the method return type
+ * @param param the full class names of the method param types
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(String dec, String name,
String returnType, String[] params) {
- if ((name == null) && (returnType == null) && (dec == null) &&
- ((params == null) || (params.length == 0))) {
+ if (name == null && returnType == null && dec == null
+ && (params == null || params.length == 0))
return setMethodIndex(0);
- }
- if (dec == null) {
+ if (dec == null)
dec = "";
- }
-
- if (name == null) {
+ if (name == null)
name = "";
- }
-
- if (returnType == null) {
+ if (returnType == null)
returnType = "";
- }
-
- if (params == null) {
+ if (params == null)
params = new String[0];
- }
NameCache cache = getProject().getNameCache();
returnType = cache.getInternalForm(returnType, true);
dec = cache.getInternalForm(dec, false);
-
for (int i = 0; i < params.length; i++)
params[i] = cache.getInternalForm(params[i], true);
String desc = cache.getDescriptor(returnType, params);
- if (getOpcode() == Constants.INVOKEINTERFACE) {
- return setMethodIndex(getPool()
- .findInterfaceMethodEntry(dec, name,
- desc, true));
- }
-
- return setMethodIndex(getPool().findMethodEntry(dec, name, desc, true));
+ if (getOpcode() == Constants.INVOKEINTERFACE)
+ return setMethodIndex(getPool().findInterfaceMethodEntry
+ (dec, name, desc, true));
+ return setMethodIndex(getPool().findMethodEntry
+ (dec, name, desc, true));
}
/**
- * Set the method this instruction operates on, for methods that are
- * declared by the current class.
- *
- * @param name the method name
- * @param returnType the full class name of the method return type
- * @param param the full class names of the method param types
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on, for methods that are
+ * declared by the current class.
+ *
+ * @param name the method name
+ * @param returnType the full class name of the method return type
+ * @param param the full class names of the method param types
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(String name, String returnType,
String[] params) {
BCClass owner = getCode().getMethod().getDeclarer();
-
return setMethod(owner.getName(), name, returnType, params);
}
/**
- * Set the method this instruction operates on.
- *
- * @param dec the method's declaring class
- * @param name the method name
- * @param returnType the class of the method return type
- * @param param the class of the method param types
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on.
+ *
+ * @param dec the method's declaring class
+ * @param name the method name
+ * @param returnType the class of the method return type
+ * @param param the class of the method param types
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(Class dec, String name,
Class returnType, Class[] params) {
String decName = (dec == null) ? null : dec.getName();
String returnName = (returnType == null) ? null : returnType.getName();
String[] paramNames = null;
-
if (params != null) {
paramNames = new String[params.length];
-
for (int i = 0; i < params.length; i++)
paramNames[i] = params[i].getName();
}
-
return setMethod(decName, name, returnName, paramNames);
}
/**
- * Set the method this instruction operates on, for methods that are
- * declared by the current class.
- *
- * @param name the method name
- * @param returnType the class of the method return type
- * @param param the class of the method param types
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on, for methods that are
+ * declared by the current class.
+ *
+ * @param name the method name
+ * @param returnType the class of the method return type
+ * @param param the class of the method param types
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(String name, Class returnType,
Class[] params) {
BCClass owner = getCode().getMethod().getDeclarer();
String returnName = (returnType == null) ? null : returnType.getName();
String[] paramNames = null;
-
if (params != null) {
paramNames = new String[params.length];
-
for (int i = 0; i < params.length; i++)
paramNames[i] = params[i].getName();
}
-
return setMethod(owner.getName(), name, returnName, paramNames);
}
/**
- * Set the method this instruction operates on.
- *
- * @param dec the method's declaring class
- * @param name the method name
- * @param returnType the class of the method return type
- * @param param the class of the method param types
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on.
+ *
+ * @param dec the method's declaring class
+ * @param name the method name
+ * @param returnType the class of the method return type
+ * @param param the class of the method param types
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(BCClass dec, String name,
BCClass returnType, BCClass[] params) {
String decName = (dec == null) ? null : dec.getName();
String returnName = (returnType == null) ? null : returnType.getName();
String[] paramNames = null;
-
if (params != null) {
paramNames = new String[params.length];
-
for (int i = 0; i < params.length; i++)
paramNames[i] = params[i].getName();
}
-
return setMethod(decName, name, returnName, paramNames);
}
/**
- * Set the method this instruction operates on, for methods that are
- * declared by the current class.
- *
- * @param name the method name
- * @param returnType the class of the method return type
- * @param param the class of the method param types
- * @return this instruction, for method chaining
+ * Set the method this instruction operates on, for methods that are
+ * declared by the current class.
+ *
+ * @param name the method name
+ * @param returnType the class of the method return type
+ * @param param the class of the method param types
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethod(String name, BCClass returnType,
BCClass[] params) {
BCClass owner = getCode().getMethod().getDeclarer();
String returnName = (returnType == null) ? null : returnType.getName();
String[] paramNames = null;
-
if (params != null) {
paramNames = new String[params.length];
-
for (int i = 0; i < params.length; i++)
paramNames[i] = params[i].getName();
}
-
return setMethod(owner.getName(), name, returnName, paramNames);
}
@@ -369,92 +312,79 @@
/////////////////////////////////////////
/**
- * Return the name of the method this instruction operates on, or null
- * if not set.
+ * Return the name of the method this instruction operates on, or null
+ * if not set.
*/
public String getMethodName() {
int index = getMethodIndex();
-
- if (index == 0) {
+ if (index == 0)
return null;
- }
ComplexEntry entry = (ComplexEntry) getPool().getEntry(index);
String name = entry.getNameAndTypeEntry().getNameEntry().getValue();
-
- if (name.length() == 0) {
+ if (name.length() == 0)
return null;
- }
return name;
}
/**
- * Set the name of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the name of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodName(String name) {
- return setMethod(getMethodDeclarerName(), name, getMethodReturnName(),
- getMethodParamNames());
+ return setMethod(getMethodDeclarerName(), name,
+ getMethodReturnName(), getMethodParamNames());
}
/**
- * Return the return type of the method this instruction operates on,
- * or null if not set.
+ * Return the return type of the method this instruction operates on,
+ * or null if not set.
*/
public String getMethodReturnName() {
int index = getMethodIndex();
-
- if (index == 0) {
+ if (index == 0)
return null;
- }
ComplexEntry entry = (ComplexEntry) getPool().getEntry(index);
- String desc = entry.getNameAndTypeEntry().getDescriptorEntry().getValue();
+ String desc = entry.getNameAndTypeEntry().getDescriptorEntry().
+ getValue();
NameCache cache = getProject().getNameCache();
- String name = cache.getExternalForm(cache.getDescriptorReturnName(desc),
- false);
-
- if (name.length() == 0) {
+ String name = cache.getExternalForm(cache.getDescriptorReturnName
+ (desc), false);
+ if (name.length() == 0)
return null;
- }
return name;
}
/**
- * Return the return type of the method this instruction operates on,
- * or null if not set.
+ * Return the return type of the method this instruction operates on,
+ * or null if not set.
*/
public Class getMethodReturnType() {
String type = getMethodReturnName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return Strings.toClass(type, getClassLoader());
}
/**
- * Return the return type of the method this instruction operates on,
- * or null if not set.
+ * Return the return type of the method this instruction operates on,
+ * or null if not set.
*/
public BCClass getMethodReturnBC() {
String type = getMethodReturnName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return getProject().loadClass(type, getClassLoader());
}
/**
- * Set the return type of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the return type of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodReturn(String type) {
return setMethod(getMethodDeclarerName(), getMethodName(), type,
@@ -462,89 +392,76 @@
}
/**
- * Set the return type of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the return type of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodReturn(Class type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setMethodReturn(name);
}
/**
- * Set the return type of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the return type of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodReturn(BCClass type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setMethodReturn(name);
}
/**
- * Return the param types of the method this instruction operates on,
- * or empty array if none.
+ * Return the param types of the method this instruction operates on,
+ * or empty array if none.
*/
public String[] getMethodParamNames() {
int index = getMethodIndex();
-
- if (index == 0) {
+ if (index == 0)
return null;
- }
ComplexEntry entry = (ComplexEntry) getPool().getEntry(index);
- String desc = entry.getNameAndTypeEntry().getDescriptorEntry().getValue();
+ String desc = entry.getNameAndTypeEntry().getDescriptorEntry().
+ getValue();
NameCache cache = getProject().getNameCache();
String[] names = cache.getDescriptorParamNames(desc);
-
for (int i = 0; i < names.length; i++)
names[i] = cache.getExternalForm(names[i], false);
-
return names;
}
/**
- * Return the param types of the method this instruction operates on,
- * or empty array if none.
+ * Return the param types of the method this instruction operates on,
+ * or empty array if none.
*/
public Class[] getMethodParamTypes() {
String[] paramNames = getMethodParamNames();
Class[] params = new Class[paramNames.length];
-
for (int i = 0; i < paramNames.length; i++)
params[i] = Strings.toClass(paramNames[i], getClassLoader());
-
return params;
}
/**
- * Return the param types of the method this instruction operates on,
- * or empty array if none.
+ * Return the param types of the method this instruction operates on,
+ * or empty array if none.
*/
public BCClass[] getMethodParamBCs() {
String[] paramNames = getMethodParamNames();
BCClass[] params = new BCClass[paramNames.length];
-
for (int i = 0; i < paramNames.length; i++)
params[i] = getProject().loadClass(paramNames[i], getClassLoader());
-
return params;
}
/**
- * Set the param types of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the param types of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodParams(String[] types) {
return setMethod(getMethodDeclarerName(), getMethodName(),
@@ -552,96 +469,80 @@
}
/**
- * Set the param types of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the param types of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public void setMethodParams(Class[] types) {
- if (types == null) {
+ if (types == null)
setMethodParams((String[]) null);
- } else {
+ else {
String[] names = new String[types.length];
-
for (int i = 0; i < types.length; i++)
names[i] = types[i].getName();
-
setMethodParams(names);
}
}
/**
- * Set the param types of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the param types of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public void setMethodParams(BCClass[] types) {
- if (types == null) {
+ if (types == null)
setMethodParams((String[]) null);
- } else {
+ else {
String[] names = new String[types.length];
-
for (int i = 0; i < types.length; i++)
names[i] = types[i].getName();
-
setMethodParams(names);
}
}
/**
- * Return the declaring type of the method this instruction operates on,
- * or null if not set.
+ * Return the declaring type of the method this instruction operates on,
+ * or null if not set.
*/
public String getMethodDeclarerName() {
int index = getMethodIndex();
-
- if (index == 0) {
+ if (index == 0)
return null;
- }
ComplexEntry entry = (ComplexEntry) getPool().getEntry(index);
- String name = getProject().getNameCache()
- .getExternalForm(entry.getClassEntry().getNameEntry()
- .getValue(), false);
-
- if (name.length() == 0) {
+ String name = getProject().getNameCache().getExternalForm
+ (entry.getClassEntry().getNameEntry().getValue(), false);
+ if (name.length() == 0)
return null;
- }
-
return name;
}
/**
- * Return the declaring type of the method this instruction operates on,
- * or null if not set.
+ * Return the declaring type of the method this instruction operates on,
+ * or null if not set.
*/
public Class getMethodDeclarerType() {
String type = getMethodDeclarerName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return Strings.toClass(type, getClassLoader());
}
/**
- * Return the declaring type of the method this instruction operates on,
- * or null if not set.
+ * Return the declaring type of the method this instruction operates on,
+ * or null if not set.
*/
public BCClass getMethodDeclarerBC() {
String type = getMethodDeclarerName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return getProject().loadClass(type, getClassLoader());
}
/**
- * Set the declaring type of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the declaring type of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodDeclarer(String type) {
return setMethod(type, getMethodName(), getMethodReturnName(),
@@ -649,86 +550,65 @@
}
/**
- * Set the declaring type of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the declaring type of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodDeclarer(Class type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setMethodDeclarer(name);
}
/**
- * Set the declaring type of the method this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the declaring type of the method this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public MethodInstruction setMethodDeclarer(BCClass type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setMethodDeclarer(name);
}
/**
- * MethodInstructions are equal if the method they reference is the same,
- * or if the method of either is unset.
+ * MethodInstructions are equal if the method they reference is the same,
+ * or if the method of either is unset.
*/
public boolean equalsInstruction(Instruction other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (!(other instanceof MethodInstruction)) {
+ if (!(other instanceof MethodInstruction))
return false;
- }
-
- if (!super.equalsInstruction(other)) {
+ if (!super.equalsInstruction(other))
return false;
- }
MethodInstruction ins = (MethodInstruction) other;
String s1 = getMethodName();
String s2 = ins.getMethodName();
-
- if (!((s1 == null) || (s2 == null) || s1.equals(s2))) {
+ if (!(s1 == null || s2 == null || s1.equals(s2)))
return false;
- }
s1 = getMethodReturnName();
s2 = ins.getMethodReturnName();
-
- if (!((s1 == null) || (s2 == null) || s1.equals(s2))) {
+ if (!(s1 == null || s2 == null || s1.equals(s2)))
return false;
- }
s1 = getMethodDeclarerName();
s2 = ins.getMethodDeclarerName();
-
- if (!((s1 == null) || (s2 == null) || s1.equals(s2))) {
+ if (!(s1 == null || s2 == null || s1.equals(s2)))
return false;
- }
String[] p1 = getMethodParamNames();
String[] p2 = ins.getMethodParamNames();
-
- if (!((p1.length == 0) || (p2.length == 0) || (p1.length == p2.length))) {
+ if (!(p1.length == 0 || p2.length == 0 || p1.length == p2.length))
return false;
- }
-
for (int i = 0; i < p1.length; i++)
- if (!((p1[i] == null) || (p2[i] == null) || p1[i].equals(p2[i]))) {
+ if (!(p1[i] == null || p2[i] == null || p1[i].equals(p2[i])))
return false;
- }
return true;
}
@@ -740,7 +620,6 @@
void read(Instruction orig) {
super.read(orig);
-
MethodInstruction ins = (MethodInstruction) orig;
setMethod(ins.getMethodDeclarerName(), ins.getMethodName(),
ins.getMethodReturnName(), ins.getMethodParamNames());
@@ -749,7 +628,6 @@
void read(DataInput in) throws IOException {
super.read(in);
setMethodIndex(in.readUnsignedShort());
-
if (getOpcode() == Constants.INVOKEINTERFACE) {
in.readByte();
in.readByte();
@@ -759,16 +637,13 @@
void write(DataOutput out) throws IOException {
super.write(out);
out.writeShort(getMethodIndex());
-
if (getOpcode() == Constants.INVOKEINTERFACE) {
String[] args = getMethodParamNames();
int count = 1;
-
for (int i = 0; i < args.length; i++, count++)
- if (long.class.getName().equals(args[i]) ||
- double.class.getName().equals(args[i])) {
+ if (long.class.getName().equals(args[i])
+ || double.class.getName().equals(args[i]))
count++;
- }
out.writeByte(count);
out.writeByte(0);
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorEnterInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorEnterInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorEnterInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorEnterInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,15 +12,13 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>The <code>monitorenter</code> instruction.</p>
- *
- * @author Abe White
+ * The <code>monitorenter</code> instruction.
+ *
+ * @author Abe White
*/
public class MonitorEnterInstruction extends MonitorInstruction {
MonitorEnterInstruction(Code owner) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorExitInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorExitInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorExitInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorExitInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,11 +14,10 @@
import serp.bytecode.visitor.*;
-
/**
- * <p>The <code>monitorexit</code> instruction.</p>
- *
- * @author Abe White
+ * The <code>monitorexit</code> instruction.
+ *
+ * @author Abe White
*/
public class MonitorExitInstruction extends MonitorInstruction {
MonitorExitInstruction(Code owner) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MonitorInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,11 +12,10 @@
*/
package serp.bytecode;
-
/**
- * <p>A synchronization instruction.</p>
- *
- * @author Abe White
+ * A synchronization instruction.
+ *
+ * @author Abe White
*/
public abstract class MonitorInstruction extends Instruction {
MonitorInstruction(Code owner, int opcode) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MultiANewArrayInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MultiANewArrayInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MultiANewArrayInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/MultiANewArrayInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,16 +12,14 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>The <code>multianewarray</code> instruction, which creates a new
- * multi-dimensional array.</p>
- *
- * @author Abe White
+ * The <code>multianewarray</code> instruction, which creates a new
+ * multi-dimensional array.
+ *
+ * @author Abe White
*/
public class MultiANewArrayInstruction extends ClassInstruction {
private int _dims = -1;
@@ -46,46 +41,38 @@
}
/**
- * Return the dimensions of the array, or -1 if not set.
+ * Return the dimensions of the array, or -1 if not set.
*/
public int getDimensions() {
return _dims;
}
/**
- * Set the dimensions of the array.
- *
- * @return this instruction, for method chaining
+ * Set the dimensions of the array.
+ *
+ * @return this instruction, for method chaining
*/
public MultiANewArrayInstruction setDimensions(int dims) {
_dims = dims;
-
return this;
}
/**
- * Two MultiANewArray instructions are equal if they have the same
- * type and dimensions, or if the type and dimensions of either
- * is unset.
+ * Two MultiANewArray instructions are equal if they have the same
+ * type and dimensions, or if the type and dimensions of either is unset.
*/
public boolean equalsInstruction(Instruction other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (!(other instanceof MultiANewArrayInstruction)) {
+ if (!(other instanceof MultiANewArrayInstruction))
return false;
- }
-
- if (!super.equalsInstruction(other)) {
+ if (!super.equalsInstruction(other))
return false;
- }
MultiANewArrayInstruction ins = (MultiANewArrayInstruction) other;
int dims = getDimensions();
int otherDims = ins.getDimensions();
-
- return (dims == -1) || (otherDims == -1) || (dims == otherDims);
+ return dims == -1 || otherDims == -1 || dims == otherDims;
}
public void acceptVisit(BCVisitor visit) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NameCache.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NameCache.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NameCache.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NameCache.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,24 +14,16 @@
import java.util.*;
-
/**
- * <p>Caching and conversion of names in both internal and external form.</p>
- *
- * @author Abe White
+ * Caching and conversion of names in both internal and external form.
+ *
+ * @author Abe White
*/
public class NameCache {
static final Object[][] _codes = new Object[][] {
- { byte.class, "B" },
- { char.class, "C" },
- { double.class, "D" },
- { float.class, "F" },
- { int.class, "I" },
- { long.class, "J" },
- { short.class, "S" },
- { boolean.class, "Z" },
- { void.class, "V" },
- };
+ { byte.class, "B" }, { char.class, "C" }, { double.class, "D" },
+ { float.class, "F" }, { int.class, "I" }, { long.class, "J" },
+ { short.class, "S" }, { boolean.class, "Z" }, { void.class, "V" }, };
// caches of internal and external forms of strings
private final Map _internal = new HashMap();
@@ -43,39 +32,33 @@
private final Map _externalHuman = new HashMap();
/**
- * Converts the given class name to its internal form.
- *
- * @param className the name to convert
- * @param descriptor true if the name is to be used for a descriptor
- * section -- the difference seems to be that for
- * descriptors, non-primitives are prefixed with 'L'
- * and ended with ';'
+ * Converts the given class name to its internal form.
+ *
+ * @param className the name to convert
+ * @param descriptor true if the name is to be used for a descriptor
+ * section -- the difference seems to be that for
+ * descriptors, non-primitives are prefixed with 'L' and ended with ';'
*/
public String getInternalForm(String className, boolean descriptor) {
- if ((className == null) || (className.length() == 0)) {
+ if (className == null || className.length() == 0)
return className;
- }
Map cache = (descriptor) ? _internalDescriptor : _internal;
String cached = (String) cache.get(className);
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
String ret = getInternalFormInternal(className, descriptor);
cache.put(className, ret);
-
return ret;
}
/**
- * @see #getInternalForm
+ * @see #getInternalForm
*/
private String getInternalFormInternal(String cls, boolean descriptor) {
// handle array types, whether already in internal form or not
StringBuffer prefix = new StringBuffer();
-
while (true) {
if (cls.endsWith("[]")) {
prefix.append("[");
@@ -83,168 +66,139 @@
} else if (cls.startsWith("[")) {
prefix.append("[");
cls = cls.substring(1);
- } else {
+ } else
break;
- }
}
// handle primitive array types
for (int i = 0; i < _codes.length; i++)
- if (cls.equals(_codes[i][1].toString()) ||
- cls.equals(_codes[i][0].toString())) {
+ if (cls.equals(_codes[i][1].toString())
+ || cls.equals(_codes[i][0].toString()))
return prefix.append(_codes[i][1]).toString();
- }
// if in descriptor form, strip leading 'L' and trailing ';'
- if (cls.startsWith("L") && cls.endsWith(";")) {
+ if (cls.startsWith("L") && cls.endsWith(";"))
cls = cls.substring(1, cls.length() - 1);
- }
// non-primitive; make sure we don't prefix method descriptors with 'L'
cls = cls.replace('.', '/');
-
- if ((descriptor || (prefix.length() > 0)) && (cls.charAt(0) != '(')) {
+ if ((descriptor || prefix.length() > 0) && cls.charAt(0) != '(')
return prefix.append("L").append(cls).append(";").toString();
- }
-
return prefix.append(cls).toString();
}
/**
- * Given the internal name of the class, return the 'normal' java name.
- *
- * @param internalName the internal name being used
- * @param humanReadable if the returned name should be in human-readable
- * form, rather than a form suitable for a
- * {@link Class#forName} call -- the difference
- * lies in the handling of arrays
+ * Given the internal name of the class, return the 'normal' java name.
+ *
+ * @param internalName the internal name being used
+ * @param humanReadable if the returned name should be in human-readable
+ * form, rather than a form suitable for a
+ * {@link Class#forName} call -- the difference
+ * lies in the handling of arrays
*/
public String getExternalForm(String internalName, boolean humanReadable) {
- if ((internalName == null) || (internalName.length() == 0)) {
+ if (internalName == null || internalName.length() == 0)
return internalName;
- }
Map cache = (humanReadable) ? _externalHuman : _external;
String cached = (String) cache.get(internalName);
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
String ret = getExternalFormInternal(internalName, humanReadable);
cache.put(internalName, ret);
-
return ret;
}
/**
- * @see #getExternalForm
+ * @see #getExternalForm
*/
private String getExternalFormInternal(String intern, boolean humanReadable) {
if (!humanReadable) {
// check against primitives
for (int i = 0; i < _codes.length; i++) {
- if (intern.equals(_codes[i][1].toString())) {
+ if (intern.equals(_codes[i][1].toString()))
return _codes[i][0].toString();
- }
-
- if (intern.equals(_codes[i][0].toString())) {
+ if (intern.equals(_codes[i][0].toString()))
return intern;
- }
}
intern = getInternalForm(intern, false);
-
return intern.replace('/', '.');
}
// handle arrays
StringBuffer postfix = new StringBuffer(2);
-
while (intern.startsWith("[")) {
intern = intern.substring(1);
postfix.append("[]");
}
// strip off leading 'L' and trailing ';'
- if (intern.endsWith(";")) {
+ if (intern.endsWith(";"))
intern = intern.substring(1, intern.length() - 1);
- }
// check primitives
for (int i = 0; i < _codes.length; i++)
- if (intern.equals(_codes[i][1].toString())) {
+ if (intern.equals(_codes[i][1].toString()))
return _codes[i][0].toString() + postfix;
- }
return intern.replace('/', '.') + postfix;
}
/**
- * Construct a method descriptor from the given return and parameter
- * types, which will be converted to internal form.
+ * Construct a method descriptor from the given return and parameter
+ * types, which will be converted to internal form.
*/
public String getDescriptor(String returnType, String[] paramTypes) {
StringBuffer buf = new StringBuffer();
buf.append("(");
-
if (paramTypes != null) {
for (int i = 0; i < paramTypes.length; i++) {
- if (paramTypes[i] == null) {
- throw new NullPointerException("paramTypes[" + i +
- "] = null");
- }
+ if (paramTypes[i] == null)
+ throw new NullPointerException("paramTypes[" + i
+ + "] = null");
buf.append(getInternalForm(paramTypes[i], true));
}
}
-
buf.append(")");
- if (returnType == null) {
+ if (returnType == null)
throw new NullPointerException("returnType = null");
- }
-
buf.append(getInternalForm(returnType, true));
return buf.toString();
}
/**
- * Return the return type, in internal form, for the given method
- * descriptor string.
+ * Return the return type, in internal form, for the given method
+ * descriptor string.
*/
public String getDescriptorReturnName(String descriptor) {
int index = descriptor.indexOf(')');
-
- if (index == -1) {
+ if (index == -1)
return "";
- }
-
return descriptor.substring(descriptor.indexOf(')') + 1);
}
/**
- * Return the parameter types, in internal form, for the given method
- * descriptor string.
+ * Return the parameter types, in internal form, for the given method
+ * descriptor string.
*/
public String[] getDescriptorParamNames(String descriptor) {
- if ((descriptor == null) || (descriptor.length() == 0)) {
+ if (descriptor == null || descriptor.length() == 0)
return new String[0];
- }
int index = descriptor.indexOf(')');
-
- if (index == -1) {
+ if (index == -1)
return new String[0];
- }
// get rid of the parens and the return type
descriptor = descriptor.substring(1, index);
// break the param string into individual params
List tokens = new LinkedList();
-
while (descriptor.length() > 0) {
index = 0;
@@ -253,39 +207,35 @@
index++;
// non-primitives always start with 'L' and end with ';'
- if (descriptor.charAt(index) == 'L') {
+ if (descriptor.charAt(index) == 'L')
index = descriptor.indexOf(';');
- }
tokens.add(descriptor.substring(0, index + 1));
descriptor = descriptor.substring(index + 1);
}
- return (String[]) tokens.toArray(new String[tokens.size()]);
+ return(String[]) tokens.toArray(new String[tokens.size()]);
}
/**
- * Return the component type name for the given array type, or null
- * if the given string does not represent an array type name. The name
- * given should be in proper {@link Class#forName} form.
+ * Return the component type name for the given array type, or null
+ * if the given string does not represent an array type name. The name
+ * given should be in proper {@link Class#forName} form.
*/
public String getComponentName(String name) {
- if ((name == null) || !name.startsWith("[")) {
+ if (name == null || !name.startsWith("["))
return null;
- }
name = name.substring(1);
-
- if (!name.startsWith("[") && name.endsWith(";")) {
+ if (!name.startsWith("[") && name.endsWith(";"))
name = name.substring(1, name.length() - 1);
- }
// will convert primitive type codes to names
return getExternalForm(name, false);
}
/**
- * Clear the cache.
+ * Clear the cache.
*/
public void clear() {
_internal.clear();
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NewArrayInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NewArrayInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NewArrayInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/NewArrayInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,24 +12,20 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>The <code>newarray</code> instruction, which is used to create new
- * arrays of primitive types.</p>
- *
- * @author Abe White
+ * The <code>newarray</code> instruction, which is used to create new
+ * arrays of primitive types.
+ *
+ * @author Abe White
*/
public class NewArrayInstruction extends TypedInstruction {
private static final Class[][] _mappings = new Class[][] {
- { void.class, int.class },
- { Object.class, int.class },
- };
+ { void.class, int.class }, { Object.class, int.class }, };
+
private int _code = -1;
NewArrayInstruction(Code owner) {
@@ -47,28 +40,20 @@
switch (getTypeCode()) {
case Constants.ARRAY_BOOLEAN:
return boolean.class.getName();
-
case Constants.ARRAY_CHAR:
return char.class.getName();
-
case Constants.ARRAY_FLOAT:
return float.class.getName();
-
case Constants.ARRAY_DOUBLE:
return double.class.getName();
-
case Constants.ARRAY_BYTE:
return byte.class.getName();
-
case Constants.ARRAY_SHORT:
return short.class.getName();
-
case Constants.ARRAY_INT:
return int.class.getName();
-
case Constants.ARRAY_LONG:
return long.class.getName();
-
default:
return null;
}
@@ -76,79 +61,62 @@
public TypedInstruction setType(String type) {
type = mapType(type, _mappings, true);
-
- if (type == null) {
+ if (type == null)
return setTypeCode(-1);
- }
switch (type.charAt(0)) {
case 'b':
-
- if (boolean.class.getName().equals(type)) {
+ if (boolean.class.getName().equals(type))
return setTypeCode(Constants.ARRAY_BOOLEAN);
- }
-
return setTypeCode(Constants.ARRAY_BYTE);
-
case 'c':
return setTypeCode(Constants.ARRAY_CHAR);
-
case 'f':
return setTypeCode(Constants.ARRAY_FLOAT);
-
case 'd':
return setTypeCode(Constants.ARRAY_DOUBLE);
-
case 's':
return setTypeCode(Constants.ARRAY_SHORT);
-
case 'i':
return setTypeCode(Constants.ARRAY_INT);
-
case 'l':
return setTypeCode(Constants.ARRAY_LONG);
-
default:
throw new IllegalStateException();
}
}
/**
- * Return the array code used in the lowlevel bytecode, or -1 if unset.
+ * Return the array code used in the lowlevel bytecode, or -1 if unset.
*/
public int getTypeCode() {
return _code;
}
/**
- * Set the array code used in the lowlevel bytecode.
- *
- * @return this instruction, for method chaining
+ * Set the array code used in the lowlevel bytecode.
+ *
+ * @return this instruction, for method chaining
*/
public NewArrayInstruction setTypeCode(int code) {
_code = code;
-
return this;
}
/**
- * NewArray instructions are equal if the array type is the same,
- * of if the array type of either is unset.
+ * NewArray instructions are equal if the array type is the same,
+ * of if the array type of either is unset.
*/
public boolean equalsInstruction(Instruction other) {
- if (this == other) {
+ if (this == other)
return true;
- }
-
- if (!(other instanceof NewArrayInstruction)) {
+ if (!(other instanceof NewArrayInstruction))
return false;
- }
NewArrayInstruction ins = (NewArrayInstruction) other;
int code = getTypeCode();
int otherCode = ins.getTypeCode();
-
- return (code == -1) || (otherCode == -1) || (code == otherCode);
+ return code == -1 || otherCode == -1 || code == otherCode;
}
public void acceptVisit(BCVisitor visit) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ObjectState.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ObjectState.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ObjectState.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/ObjectState.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,25 +12,25 @@
*/
package serp.bytecode;
-import serp.bytecode.lowlevel.*;
-
import java.util.*;
-
+import serp.bytecode.lowlevel.*;
/**
- * <p>State implementing the behavior of an object type.</p>
- *
- * @author Abe White
+ * State implementing the behavior of an object type.
+ *
+ * @author Abe White
*/
class ObjectState extends State {
private final ConstantPool _pool = new ConstantPool();
private final NameCache _names;
+
private int _index = 0;
private int _superclassIndex = 0;
private int _magic = Constants.VALID_MAGIC;
private int _major = Constants.MAJOR_VERSION;
private int _minor = Constants.MINOR_VERSION;
private int _access = Constants.ACCESS_PUBLIC | Constants.ACCESS_SUPER;
+
private final Collection _interfaces = new HashSet();
private final Collection _fields = new LinkedList();
private final Collection _methods = new LinkedList();
@@ -112,21 +109,17 @@
}
public String getName() {
- if (_index == 0) {
+ if (_index == 0)
return null;
- }
-
- return _names.getExternalForm(((ClassEntry) _pool.getEntry(_index)).getNameEntry()
- .getValue(), false);
+ return _names.getExternalForm(((ClassEntry) _pool.getEntry(_index)).
+ getNameEntry().getValue(), false);
}
public String getSuperclassName() {
- if (_superclassIndex == 0) {
+ if (_superclassIndex == 0)
return null;
- }
-
- return _names.getExternalForm(((ClassEntry) _pool.getEntry(
- _superclassIndex)).getNameEntry().getValue(), false);
+ return _names.getExternalForm(((ClassEntry) _pool.getEntry
+ (_superclassIndex)).getNameEntry().getValue(), false);
}
public String getComponentName() {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PrimitiveState.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PrimitiveState.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PrimitiveState.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PrimitiveState.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,15 +12,13 @@
*/
package serp.bytecode;
-import serp.bytecode.lowlevel.*;
-
import java.util.*;
-
+import serp.bytecode.lowlevel.*;
/**
- * <p>State implementing the behavior of a primitive class.</p>
- *
- * @author Abe White
+ * State implementing the behavior of a primitive class.
+ *
+ * @author Abe White
*/
class PrimitiveState extends State {
private final Class _type;
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Project.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Project.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Project.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Project.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,33 +12,26 @@
*/
package serp.bytecode;
+import java.io.*;
+import java.util.*;
import serp.bytecode.lowlevel.*;
-
import serp.bytecode.visitor.*;
-
import serp.util.*;
-import java.io.*;
-
-import java.util.*;
-
-
/**
- * <p>The Project represents a working set of classes. It caches parsed
- * bytecode and is responsible for bytecode class creation. Currently
- * changes made in one class are <strong>not</strong> reflected in other
- * classes, though this will be an option in the future.</p>
- *
- * <p>Bytecode that has been parsed is held in a cache so that retrieving
- * a class with the same name multiple times always returns the same
- * {@link BCClass} instance.</p>
- *
- * <p>A future goal is to eventually have facilities for traversing jars
- * or directory structures to find classes that meet a given criteria (such
- * as implementing a given interface, etc) and to perform operations on entire
- * projects, similar to aspect-oriented programming.</p>
- *
- * @author Abe White
+ * The Project represents a working set of classes. It caches parsed
+ * bytecode and is responsible for bytecode class creation. Currently
+ * changes made in one class are <strong>not</strong> reflected in other
+ * classes, though this will be an option in the future.
+ * Bytecode that has been parsed is held in a cache so that retrieving
+ * a class with the same name multiple times always returns the same
+ * {@link BCClass} instance.
+ * A future goal is to eventually have facilities for traversing jars
+ * or directory structures to find classes that meet a given criteria(such
+ * as implementing a given interface, etc) and to perform operations on entire
+ * projects, similar to aspect-oriented programming.
+ *
+ * @author Abe White
*/
public class Project implements VisitAcceptor {
private final String _name;
@@ -49,73 +39,68 @@
private final NameCache _names = new NameCache();
/**
- * Default constructor.
+ * Default constructor.
*/
public Project() {
this(null);
}
/**
- * Construct a named project.
+ * Construct a named project.
*/
public Project(String name) {
_name = name;
}
/**
- * Return the project name, or null if unset.
+ * Return the project name, or null if unset.
*/
public String getName() {
return _name;
}
/**
- * Return the name cache, which includes utilities for converting names
- * from internal to external form and vice versa.
+ * Return the name cache, which includes utilities for converting names
+ * from internal to external form and vice versa.
*/
public NameCache getNameCache() {
return _names;
}
/**
- * Load a class with the given name.
- *
- * @see #loadClass(String,ClassLoader)
+ * Load a class with the given name.
+ *
+ * @see #loadClass(String,ClassLoader)
*/
public BCClass loadClass(String name) {
return loadClass(name, null);
}
/**
- * Load the bytecode for the class with the given name.
- * If a {@link BCClass} with the given name already exists in this project,
- * it will be returned. Otherwise, a new {@link BCClass} will be created
- * with the given name and returned. If the name represents an existing
- * type, the returned instance will contain the parsed bytecode for
- * that type. If the name is of a primitive or array type, the returned
- * instance will act accordingly.
- *
- * @param name the name of the class, including package
- * @param loader the class loader to use to search for an existing
- * class with the given name; if null defaults to the
- * context loader of the current thread
- * @throws RuntimeException on parse error
+ * Load the bytecode for the class with the given name.
+ * If a {@link BCClass} with the given name already exists in this project,
+ * it will be returned. Otherwise, a new {@link BCClass} will be created
+ * with the given name and returned. If the name represents an existing
+ * type, the returned instance will contain the parsed bytecode for
+ * that type. If the name is of a primitive or array type, the returned
+ * instance will act accordingly.
+ *
+ * @param name the name of the class, including package
+ * @param loader the class loader to use to search for an existing
+ * class with the given name; if null defaults to the
+ * context loader of the current thread
+ * @throws RuntimeException on parse error
*/
public BCClass loadClass(String name, ClassLoader loader) {
// convert to proper Class.forName() form
name = _names.getExternalForm(name, false);
-
BCClass cached = checkCache(name);
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
// check for existing type
- if (loader == null) {
+ if (loader == null)
loader = Thread.currentThread().getContextClassLoader();
- }
-
try {
return loadClass(Strings.toClass(name, loader));
} catch (Exception e) {
@@ -123,49 +108,42 @@
String componentName = _names.getComponentName(name);
BCClass ret = new BCClass(this);
-
- if (componentName != null) {
+ if (componentName != null)
ret.setState(new ArrayState(name, componentName));
- } else {
+ else {
ret.setState(new ObjectState(_names));
ret.setName(name);
ret.setSuperclass(Object.class);
}
cache(name, ret);
-
return ret;
}
/**
- * Load the bytecode for the given class.
- * If a {@link BCClass} with the name of the given class already exists in
- * this project, it will be returned. Otherwise, the bytecode of the given
- * class will be parsed and returned as a new {@link BCClass}. If the
- * given class is an array or primitive type, the returned instance will
- * act accordingly.
- *
- * @param type the class to parse
- * @throws RuntimeException on parse error
+ * Load the bytecode for the given class.
+ * If a {@link BCClass} with the name of the given class already exists in
+ * this project, it will be returned. Otherwise, the bytecode of the given
+ * class will be parsed and returned as a new {@link BCClass}. If the
+ * given class is an array or primitive type, the returned instance will
+ * act accordingly.
+ *
+ * @param type the class to parse
+ * @throws RuntimeException on parse error
*/
public BCClass loadClass(Class type) {
BCClass cached = checkCache(type.getName());
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
BCClass ret = new BCClass(this);
-
- if (type.isPrimitive()) {
+ if (type.isPrimitive())
ret.setState(new PrimitiveState(type, _names));
- } else if (type.isArray()) {
- ret.setState(new ArrayState(type.getName(),
- _names.getExternalForm(type.getComponentType().getName(),
- false)));
- } else {
+ else if (type.isArray())
+ ret.setState(new ArrayState(type.getName(), _names.
+ getExternalForm(type.getComponentType().getName(), false)));
+ else {
ret.setState(new ObjectState(_names));
-
try {
ret.read(type);
} catch (IOException ioe) {
@@ -174,35 +152,33 @@
}
cache(type.getName(), ret);
-
return ret;
}
/**
- * Load the bytecode from the given class file.
- * If this project already contains the class in the given file, it will
- * be returned. Otherwise a new {@link BCClass} will be created from the
- * given bytecode.
- *
- * @throws RuntimeException on parse error
+ * Load the bytecode from the given class file.
+ * If this project already contains the class in the given file, it will
+ * be returned. Otherwise a new {@link BCClass} will be created from the
+ * given bytecode.
+ *
+ * @throws RuntimeException on parse error
*/
public BCClass loadClass(File classFile) {
return loadClass(classFile, null);
}
/**
- * Load the bytecode from the given class file.
- * If this project already contains the class in the given file, it will
- * be returned. Otherwise a new {@link BCClass} will be created from the
- * given bytecode.
- *
- * @throws RuntimeException on parse error
+ * Load the bytecode from the given class file.
+ * If this project already contains the class in the given file, it will
+ * be returned. Otherwise a new {@link BCClass} will be created from the
+ * given bytecode.
+ *
+ * @throws RuntimeException on parse error
*/
public BCClass loadClass(File classFile, ClassLoader loader) {
// parse the bytecode from the file
BCClass ret = new BCClass(this);
ret.setState(new ObjectState(_names));
-
try {
ret.read(classFile, loader);
} catch (IOException ioe) {
@@ -211,40 +187,36 @@
String name = ret.getName();
BCClass cached = checkCache(name);
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
cache(name, ret);
-
return ret;
}
/**
- * Load the bytecode from the given stream.
- * If this project already contains the class in the given stream,
- * it will be returned. Otherwise a new {@link BCClass} will be created
- * from the given bytecode.
- *
- * @throws RuntimeException on parse error
+ * Load the bytecode from the given stream.
+ * If this project already contains the class in the given stream,
+ * it will be returned. Otherwise a new {@link BCClass} will be created
+ * from the given bytecode.
+ *
+ * @throws RuntimeException on parse error
*/
public BCClass loadClass(InputStream in) {
return loadClass(in, null);
}
/**
- * Load the bytecode from the given stream.
- * If this project already contains the class in the given stream,
- * it will be returned. Otherwise a new {@link BCClass} will be created
- * from the given bytecode.
- *
- * @throws RuntimeException on parse error
+ * Load the bytecode from the given stream.
+ * If this project already contains the class in the given stream,
+ * it will be returned. Otherwise a new {@link BCClass} will be created
+ * from the given bytecode.
+ *
+ * @throws RuntimeException on parse error
*/
public BCClass loadClass(InputStream in, ClassLoader loader) {
BCClass ret = new BCClass(this);
ret.setState(new ObjectState(_names));
-
try {
ret.read(in, loader);
} catch (IOException ioe) {
@@ -253,53 +225,45 @@
String name = ret.getName();
BCClass cached = checkCache(name);
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
cache(name, ret);
-
return ret;
}
/**
- * Import the given bytecode from another project. If a {@link BCClass}
- * with the same name already exists in this project, it will be returned.
- * Otherwise, a new {@link BCClass} will be created from the
- * information in the given class.
+ * Import the given bytecode from another project. If a {@link BCClass}
+ * with the same name already exists in this project, it will be returned.
+ * Otherwise, a new {@link BCClass} will be created from the
+ * information in the given class.
*/
public BCClass loadClass(BCClass bc) {
String name = bc.getName();
BCClass cached = checkCache(name);
-
- if (cached != null) {
+ if (cached != null)
return cached;
- }
BCClass ret = new BCClass(this);
-
- if (bc.isPrimitive()) {
+ if (bc.isPrimitive())
ret.setState(new PrimitiveState(bc.getType(), _names));
- } else if (bc.isArray()) {
+ else if (bc.isArray())
ret.setState(new ArrayState(bc.getName(), bc.getComponentName()));
- } else {
+ else {
ret.setState(new ObjectState(_names));
ret.read(bc);
}
cache(name, ret);
-
return ret;
}
/**
- * Clears all classes from this project.
+ * Clears all classes from this project.
*/
public void clear() {
Collection values = _cache.values();
BCClass bc;
-
for (Iterator itr = values.iterator(); itr.hasNext();) {
bc = (BCClass) itr.next();
itr.remove();
@@ -310,87 +274,76 @@
}
/**
- * Remove a class from this project. After removal, the result of any
- * further operations on the class is undefined.
- *
- * @return true if the class belonged to this project, false
- * otherwise
+ * Remove a class from this project. After removal, the result of any
+ * further operations on the class is undefined.
+ *
+ * @return true if the class belonged to this project, false otherwise
*/
public boolean removeClass(String type) {
return removeClass(checkCache(type));
}
/**
- * Remove a class from this project. After removal, the result of any
- * further operations on the class is undefined.
- *
- * @return true if the class belonged to this project, false
- * otherwise
+ * Remove a class from this project. After removal, the result of any
+ * further operations on the class is undefined.
+ *
+ * @return true if the class belonged to this project, false otherwise
*/
public boolean removeClass(Class type) {
- if (type == null) {
+ if (type == null)
return false;
- }
-
return removeClass(checkCache(type.getName()));
}
/**
- * Remove a class from this project. After removal, the result of any
- * further operations on the class is undefined.
- *
- * @return true if the class belonged to this project, false
- * otherwise
+ * Remove a class from this project. After removal, the result of any
+ * further operations on the class is undefined.
+ *
+ * @return true if the class belonged to this project, false otherwise
*/
public boolean removeClass(BCClass type) {
- if (type == null) {
+ if (type == null)
return false;
- }
-
- if (!removeFromCache(type.getName(), type)) {
+ if (!removeFromCache(type.getName(), type))
return false;
- }
type.invalidate();
-
return true;
}
/**
- * Return all loaded classes in the project.
+ * Return all loaded classes in the project.
*/
public BCClass[] getClasses() {
Collection values = _cache.values();
-
- return (BCClass[]) values.toArray(new BCClass[values.size()]);
+ return(BCClass[]) values.toArray(new BCClass[values.size()]);
}
/**
- * Return true if the project already contains the given class.
+ * Return true if the project already contains the given class.
*/
public boolean containsClass(String type) {
return _cache.containsKey(type);
}
/**
- * Return true if the project already contains the given class.
+ * Return true if the project already contains the given class.
*/
public boolean containsClass(Class type) {
- return (type == null) ? false : containsClass(type.getName());
+ return(type == null) ? false : containsClass(type.getName());
}
/**
- * Return true if the project already contains the given class.
+ * Return true if the project already contains the given class.
*/
public boolean containsClass(BCClass type) {
- return (type == null) ? false : containsClass(type.getName());
+ return(type == null) ? false : containsClass(type.getName());
}
public void acceptVisit(BCVisitor visit) {
visit.enterProject(this);
BCClass[] classes = getClasses();
-
for (int i = 0; i < classes.length; i++)
classes[i].acceptVisit(visit);
@@ -398,54 +351,48 @@
}
/**
- * Renames the given class within this project. Used internally by
- * {@link BCClass} instances when their name is modified.
- *
- * @throws IllegalStateException if a class with the new name already
- * exists
+ * Renames the given class within this project. Used internally by
+ * {@link BCClass} instances when their name is modified.
+ *
+ * @throws IllegalStateException if a class with the new name already exists
*/
void renameClass(String oldName, String newName, BCClass bc) {
- if (oldName.equals(newName)) {
+ if (oldName.equals(newName))
return;
- }
BCClass cached = (BCClass) checkCache(newName);
-
- if (cached != null) {
- throw new IllegalStateException("A class with name " + newName +
- " already exists in this project");
- }
+ if (cached != null)
+ throw new IllegalStateException("A class with name " + newName
+ + " already exists in this project");
removeFromCache(oldName, bc);
cache(newName, bc);
}
/**
- * Check the cache for a loaded type.
+ * Check the cache for a loaded type.
*/
private BCClass checkCache(String name) {
- return (BCClass) _cache.get(name);
+ return(BCClass) _cache.get(name);
}
/**
- * Cache a class.
+ * Cache a class.
*/
private void cache(String name, BCClass bc) {
_cache.put(name, bc);
}
/**
- * Remove a cached class.
+ * Remove a cached class.
*/
private boolean removeFromCache(String name, BCClass bc) {
BCClass rem = (BCClass) checkCache(name);
-
- if (rem != bc) {
+ if (rem != bc)
return false;
- }
_cache.remove(name);
-
return true;
}
}
+
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PutFieldInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PutFieldInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PutFieldInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/PutFieldInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,11 +14,10 @@
import serp.bytecode.visitor.*;
-
/**
- * <p>Stores a value from the stack into a field.</p>
- *
- * @author Abe White
+ * Stores a value from the stack into a field.
+ *
+ * @author Abe White
*/
public class PutFieldInstruction extends FieldInstruction {
PutFieldInstruction(Code owner, int opcode) {
@@ -29,35 +25,24 @@
}
public int getLogicalStackChange() {
- if (getFieldTypeName() == null) {
+ if (getFieldTypeName() == null)
return 0;
- }
-
- if (getOpcode() == Constants.PUTSTATIC) {
+ if (getOpcode() == Constants.PUTSTATIC)
return -1;
- }
-
return -2;
}
public int getStackChange() {
String type = getFieldTypeName();
-
- if (type == null) {
+ if (type == null)
return 0;
- }
int stack = -2;
-
- if (long.class.getName().equals(type) ||
- double.class.getName().equals(type)) {
+ if (long.class.getName().equals(type)
+ || double.class.getName().equals(type))
stack++;
- }
-
- if (getOpcode() == Constants.PUTSTATIC) {
+ if (getOpcode() == Constants.PUTSTATIC)
stack++;
- }
-
return stack;
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/RetInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/RetInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/RetInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/RetInstruction.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,16 +12,13 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>The <code>ret</code> instruction is used in the implementation of
- * finally.</p>
- *
- * @author Abe White
+ * The <code>ret</code> instruction is used in the implementation of finally.
+ *
+ * @author Abe White
*/
public class RetInstruction extends LocalVariableInstruction {
RetInstruction(Code owner) {
@@ -36,14 +30,10 @@
}
public boolean equalsInstruction(Instruction other) {
- if (this == other) {
+ if (this == other)
return true;
- }
-
- if (!(other instanceof RetInstruction)) {
+ if (!(other instanceof RetInstruction))
return false;
- }
-
return super.equalsInstruction(other);
}