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 [26/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/FieldInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/FieldInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/FieldInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/FieldInstruction.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,23 +12,17 @@
*/
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>Instruction that takes as an argument a field to operate
- * on. Examples include <code>getfield, getstatic, setfield,
- * setstatic</code>.</p>
- *
- * @author Abe White
+ * Instruction that takes as an argument a field to operate
+ * on. Examples include <code>getfield, getstatic, setfield, setstatic</code>.
+ *
+ * @author Abe White
*/
public abstract class FieldInstruction extends Instruction {
private int _index = 0;
@@ -49,175 +40,155 @@
////////////////////
/**
- * Return the index in the class {@link ConstantPool} of the
- * {@link ComplexEntry} describing the field to operate on.
+ * Return the index in the class {@link ConstantPool} of the
+ * {@link ComplexEntry} describing the field to operate on.
*/
public int getFieldIndex() {
return _index;
}
/**
- * Set the index in the class {@link ConstantPool} of the
- * {@link ComplexEntry} describing the field to operate on.
- *
- * @return this instruction, for method chaining
+ * Set the index in the class {@link ConstantPool} of the
+ * {@link ComplexEntry} describing the field to operate on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldIndex(int index) {
_index = index;
-
return this;
}
/**
- * Return the field this instruction operates on, or null if not set.
+ * Return the field this instruction operates on, or null if not set.
*/
public BCField getField() {
String dec = getFieldDeclarerName();
-
- if (dec == null) {
+ if (dec == null)
return null;
- }
BCClass bc = getProject().loadClass(dec, getClassLoader());
BCField[] fields = bc.getFields(getFieldName());
- if (fields.length == 0) {
+ if (fields.length == 0)
return null;
- }
-
return fields[0];
}
/**
- * Set the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(BCField field) {
- if (field == null) {
+ if (field == null)
return setFieldIndex(0);
- }
-
return setField(field.getDeclarer().getName(), field.getName(),
field.getTypeName());
}
/**
- * Set the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(Field field) {
- if (field == null) {
+ if (field == null)
return setFieldIndex(0);
- }
-
return setField(field.getDeclaringClass(), field.getName(),
field.getType());
}
/**
- * Set the field this instruction operates on.
- *
- * @param dec the full class name of the field's declaring class
- * @param name the field name
- * @param type the full class name of the field type
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on.
+ *
+ * @param dec the full class name of the field's declaring class
+ * @param name the field name
+ * @param type the full class name of the field type
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(String dec, String name, String type) {
- if ((dec == null) && (name == null) && (type == null)) {
+ if (dec == null && name == null && type == null)
return setFieldIndex(0);
- }
- if (dec == null) {
+ if (dec == null)
dec = "";
- }
-
- if (name == null) {
+ if (name == null)
name = "";
- }
-
- if (type == null) {
+ if (type == null)
type = "";
- }
dec = getProject().getNameCache().getInternalForm(dec, false);
type = getProject().getNameCache().getInternalForm(type, true);
- return setFieldIndex(getPool().findFieldEntry(dec, name, type, true));
+ return setFieldIndex(getPool().findFieldEntry (dec, name, type, true));
}
/**
- * Set the field this instruction operates on, for fields that are
- * declared by the current class.
- *
- * @param name the field name
- * @param type the full class name of the field type
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on, for fields that are
+ * declared by the current class.
+ *
+ * @param name the field name
+ * @param type the full class name of the field type
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(String name, String type) {
BCClass owner = getCode().getMethod().getDeclarer();
-
return setField(owner.getName(), name, type);
}
/**
- * Set the field this instruction operates on.
- *
- * @param dec the field's declaring class
- * @param name the field name
- * @param type the class of the field type
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on.
+ *
+ * @param dec the field's declaring class
+ * @param name the field name
+ * @param type the class of the field type
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(Class dec, String name, Class type) {
String decName = (dec == null) ? null : dec.getName();
String typeName = (type == null) ? null : type.getName();
-
return setField(decName, name, typeName);
}
/**
- * Set the field this instruction operates on, for fields that are
- * declared by the current class.
- *
- * @param name the field name
- * @param type the class of the field type
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on, for fields that are
+ * declared by the current class.
+ *
+ * @param name the field name
+ * @param type the class of the field type
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(String name, Class type) {
BCClass owner = getCode().getMethod().getDeclarer();
String typeName = (type == null) ? null : type.getName();
-
return setField(owner.getName(), name, typeName);
}
/**
- * Set the field this instruction operates on.
- *
- * @param dec the field's declaring class
- * @param name the field name
- * @param type the class of the field type
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on.
+ *
+ * @param dec the field's declaring class
+ * @param name the field name
+ * @param type the class of the field type
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(BCClass dec, String name, BCClass type) {
String decName = (dec == null) ? null : dec.getName();
String typeName = (type == null) ? null : type.getName();
-
return setField(decName, name, typeName);
}
/**
- * Set the field this instruction operates on, for fields that are
- * declared by the current class.
- *
- * @param name the field name
- * @param type the class of the field type
- * @return this instruction, for method chaining
+ * Set the field this instruction operates on, for fields that are
+ * declared by the current class.
+ *
+ * @param name the field name
+ * @param type the class of the field type
+ * @return this instruction, for method chaining
*/
public FieldInstruction setField(String name, BCClass type) {
BCClass owner = getCode().getMethod().getDeclarer();
String typeName = (type == null) ? null : type.getName();
-
return setField(owner.getName(), name, typeName);
}
@@ -226,262 +197,208 @@
////////////////////////////////
/**
- * Return the name of the field this instruction operates on, or null
- * if not set.
+ * Return the name of the field this instruction operates on, or null
+ * if not set.
*/
public String getFieldName() {
int index = getFieldIndex();
-
- 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 field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the name of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldName(String name) {
return setField(getFieldDeclarerName(), name, getFieldTypeName());
}
/**
- * Return the type of the field this instruction operates on, or null
- * if not set.
+ * Return the type of the field this instruction operates on, or null
+ * if not set.
*/
public String getFieldTypeName() {
int index = getFieldIndex();
-
- if (index == 0) {
+ if (index == 0)
return null;
- }
ComplexEntry entry = (ComplexEntry) getPool().getEntry(index);
- String name = getProject().getNameCache()
- .getExternalForm(entry.getNameAndTypeEntry()
- .getDescriptorEntry().getValue(),
- false);
-
- if (name.length() == 0) {
+ String name = getProject().getNameCache().getExternalForm(entry.
+ getNameAndTypeEntry().getDescriptorEntry().getValue(), false);
+ if (name.length() == 0)
return null;
- }
-
return name;
}
/**
- * Return the type of the field this instruction operates on, or null
- * if not set.
+ * Return the type of the field this instruction operates on, or null
+ * if not set.
*/
public Class getFieldType() {
String type = getFieldTypeName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return Strings.toClass(type, getClassLoader());
}
/**
- * Return the type of the field this instruction operates on, or null
- * if not set.
+ * Return the type of the field this instruction operates on, or null
+ * if not set.
*/
public BCClass getFieldTypeBC() {
String type = getFieldTypeName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return getProject().loadClass(type, getClassLoader());
}
/**
- * Set the type of the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the type of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldType(String type) {
return setField(getFieldDeclarerName(), getFieldName(), type);
}
/**
- * Set the type of the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the type of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldType(Class type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setFieldType(name);
}
/**
- * Set the type of the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the type of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldType(BCClass type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setFieldType(name);
}
/**
- * Return the declaring class of the field this instruction operates on,
- * or null if not set.
+ * Return the declaring class of the field this instruction operates on,
+ * or null if not set.
*/
public String getFieldDeclarerName() {
int index = getFieldIndex();
-
- 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 class of the field this instruction operates on,
- * or null if not set.
+ * Return the declaring class of the field this instruction operates on,
+ * or null if not set.
*/
public Class getFieldDeclarerType() {
String type = getFieldDeclarerName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return Strings.toClass(type, getClassLoader());
}
/**
- * Return the declaring class of the field this instruction operates on,
- * or null if not set.
+ * Return the declaring class of the field this instruction operates on,
+ * or null if not set.
*/
public BCClass getFieldDeclarerBC() {
String type = getFieldDeclarerName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return getProject().loadClass(type, getClassLoader());
}
/**
- * Set the declaring class of the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the declaring class of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldDeclarer(String type) {
return setField(type, getFieldName(), getFieldTypeName());
}
/**
- * Set the declaring class of the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the declaring class of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldDeclarer(Class type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setFieldDeclarer(name);
}
/**
- * Set the declaring class of the field this instruction operates on.
- *
- * @return this instruction, for method chaining
+ * Set the declaring class of the field this instruction operates on.
+ *
+ * @return this instruction, for method chaining
*/
public FieldInstruction setFieldDeclarer(BCClass type) {
String name = null;
-
- if (type != null) {
+ if (type != null)
name = type.getName();
- }
-
return setFieldDeclarer(name);
}
/**
- * FieldInstructions are equal if the field they reference is the same,
- * or if the field of either is unset.
+ * FieldInstructions are equal if the field they reference is the same,
+ * or if the field of either is unset.
*/
public boolean equalsInstruction(Instruction other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (!(other instanceof FieldInstruction)) {
+ if (!(other instanceof FieldInstruction))
return false;
- }
-
- if (!super.equalsInstruction(other)) {
+ if (!super.equalsInstruction(other))
return false;
- }
FieldInstruction ins = (FieldInstruction) other;
String s1 = getFieldName();
String s2 = ins.getFieldName();
-
- if (!((s1 == null) || (s2 == null) || s1.equals(s2))) {
+ if (!(s1 == null || s2 == null || s1.equals(s2)))
return false;
- }
s1 = getFieldTypeName();
s2 = ins.getFieldTypeName();
-
- if (!((s1 == null) || (s2 == null) || s1.equals(s2))) {
+ if (!(s1 == null || s2 == null || s1.equals(s2)))
return false;
- }
s1 = getFieldDeclarerName();
s2 = ins.getFieldDeclarerName();
-
- if (!((s1 == null) || (s2 == null) || s1.equals(s2))) {
+ if (!(s1 == null || s2 == null || s1.equals(s2)))
return false;
- }
return true;
}
void read(Instruction orig) {
super.read(orig);
-
FieldInstruction ins = (FieldInstruction) orig;
setField(ins.getFieldDeclarerName(), ins.getFieldName(),
ins.getFieldTypeName());
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/GetFieldInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/GetFieldInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/GetFieldInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/GetFieldInstruction.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>Loads a value from a field onto the stack.</p>
- *
- * @author Abe White
+ * Loads a value from a field onto the stack.
+ *
+ * @author Abe White
*/
public class GetFieldInstruction extends FieldInstruction {
GetFieldInstruction(Code owner, int opcode) {
@@ -29,31 +25,22 @@
}
public int getLogicalStackChange() {
- if (getOpcode() == Constants.GETSTATIC) {
+ if (getOpcode() == Constants.GETSTATIC)
return 1;
- }
-
return 0;
}
public int getStackChange() {
String type = getFieldTypeName();
-
- if (type == null) {
+ if (type == null)
return 0;
- }
int stack = 0;
-
- 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.GETSTATIC) {
+ if (getOpcode() == Constants.GETSTATIC)
stack++;
- }
-
return stack;
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IIncInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IIncInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IIncInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IIncInstruction.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>iinc</code> instruction.</p>
- *
- * @author Abe White
+ * The <code>iinc</code> instruction.
+ *
+ * @author Abe White
*/
public class IIncInstruction extends LocalVariableInstruction {
private int _inc = 0;
@@ -37,40 +32,33 @@
}
/**
- * Return the increment for this IINC instruction.
- */
+ * Return the increment for this IINC instruction.
+ */
public int getIncrement() {
return _inc;
}
/**
- * Set the increment on this IINC instruction.
- *
- * @return this Instruction, for method chaining
+ * Set the increment on this IINC instruction.
+ *
+ * @return this Instruction, for method chaining
*/
public IIncInstruction setIncrement(int val) {
_inc = val;
-
return this;
}
public boolean equalsInstruction(Instruction other) {
- if (this == other) {
+ if (this == other)
return true;
- }
-
- if (!(other instanceof IIncInstruction)) {
+ if (!(other instanceof IIncInstruction))
return false;
- }
-
- if (!super.equalsInstruction(other)) {
+ if (!super.equalsInstruction(other))
return false;
- }
IIncInstruction ins = (IIncInstruction) other;
-
- return ((getIncrement() == 0) || (ins.getIncrement() == 0) ||
- (getIncrement() == ins.getIncrement()));
+ return(getIncrement() == 0 || ins.getIncrement() == 0
+ || getIncrement() == ins.getIncrement());
}
public void acceptVisit(BCVisitor visit) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IfInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IfInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IfInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/IfInstruction.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
@@ -16,14 +13,12 @@
package serp.bytecode;
import serp.bytecode.lowlevel.*;
-
import serp.bytecode.visitor.*;
-
/**
- * <p>An if instruction such as <code>ifnull, ifeq</code>, etc.</p>
- *
- * @author Abe White
+ * An if instruction such as <code>ifnull, ifeq</code>, etc.
+ *
+ * @author Abe White
*/
public class IfInstruction extends JumpInstruction {
IfInstruction(Code owner, int opcode) {
@@ -45,7 +40,6 @@
case Constants.IFICMPLE:
case Constants.IFICMPGE:
return -2;
-
case Constants.IFEQ:
case Constants.IFNE:
case Constants.IFLT:
@@ -55,7 +49,6 @@
case Constants.IFNULL:
case Constants.IFNONNULL:
return -1;
-
default:
return super.getStackChange();
}
@@ -68,7 +61,6 @@
case Constants.IFNULL:
case Constants.IFNONNULL:
return "java.lang.Object";
-
default:
return "I";
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClass.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClass.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClass.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClass.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,26 +12,23 @@
*/
package serp.bytecode;
+import java.io.*;
import serp.bytecode.lowlevel.*;
-
import serp.bytecode.visitor.*;
-
import serp.util.*;
-import java.io.*;
-
-
/**
- * <p>Any referenced class that is not a package member is represented by
- * this structure. This includes member classes and interfaces.</p>
- *
- * @author Abe White
+ * Any referenced class that is not a package member is represented by
+ * this structure. This includes member classes and interfaces.
+ *
+ * @author Abe White
*/
public class InnerClass implements BCEntity, VisitAcceptor {
private int _index = 0;
private int _nameIndex = 0;
private int _ownerIndex = 0;
private int _access = Constants.ACCESS_PRIVATE;
+
private InnerClasses _owner = null;
InnerClass(InnerClasses owner) {
@@ -42,7 +36,7 @@
}
/**
- * Inner classes are stored in an {@link InnerClasses} attribute.
+ * Inner classes are stored in an {@link InnerClasses} attribute.
*/
public InnerClasses getOwner() {
return _owner;
@@ -57,28 +51,28 @@
/////////////////////
/**
- * Return the access flags of the inner class.
+ * Return the access flags of the inner class.
*/
public int getAccessFlags() {
return _access;
}
/**
- * Set the access flags of the inner class.
+ * Set the access flags of the inner class.
*/
public void setAccessFlags(int accessFlags) {
_access = accessFlags;
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public boolean isPublic() {
- return (getAccessFlags() & Constants.ACCESS_PUBLIC) > 0;
+ return(getAccessFlags() & Constants.ACCESS_PUBLIC) > 0;
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public void makePublic() {
setAccessFlags(getAccessFlags() | Constants.ACCESS_PUBLIC);
@@ -87,14 +81,14 @@
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public boolean isProtected() {
- return (getAccessFlags() & Constants.ACCESS_PROTECTED) > 0;
+ return(getAccessFlags() & Constants.ACCESS_PROTECTED) > 0;
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public void makeProtected() {
setAccessFlags(getAccessFlags() & ~Constants.ACCESS_PUBLIC);
@@ -103,14 +97,14 @@
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public boolean isPrivate() {
- return (getAccessFlags() & Constants.ACCESS_PRIVATE) > 0;
+ return(getAccessFlags() & Constants.ACCESS_PRIVATE) > 0;
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public void makePrivate() {
setAccessFlags(getAccessFlags() & ~Constants.ACCESS_PUBLIC);
@@ -119,76 +113,72 @@
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public boolean isFinal() {
- return (getAccessFlags() & Constants.ACCESS_FINAL) > 0;
+ return(getAccessFlags() & Constants.ACCESS_FINAL) > 0;
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public void setFinal(boolean on) {
- if (on) {
+ if (on)
setAccessFlags(getAccessFlags() | Constants.ACCESS_FINAL);
- } else {
+ else
setAccessFlags(getAccessFlags() & ~Constants.ACCESS_FINAL);
- }
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public boolean isStatic() {
- return (getAccessFlags() & Constants.ACCESS_STATIC) > 0;
+ return(getAccessFlags() & Constants.ACCESS_STATIC) > 0;
}
/**
- * Manipulate the inner class access flags.
+ * Manipulate the inner class access flags.
*/
public void setStatic(boolean on) {
- if (on) {
+ if (on)
setAccessFlags(getAccessFlags() | Constants.ACCESS_STATIC);
- } else {
+ else
setAccessFlags(getAccessFlags() & ~Constants.ACCESS_STATIC);
- }
}
/**
- * Manipulate the class access flags.
+ * Manipulate the class access flags.
*/
public boolean isInterface() {
- return (getAccessFlags() & Constants.ACCESS_INTERFACE) > 0;
+ return(getAccessFlags() & Constants.ACCESS_INTERFACE) > 0;
}
/**
- * Manipulate the class access flags.
+ * Manipulate the class access flags.
*/
public void setInterface(boolean on) {
if (on) {
setAccessFlags(getAccessFlags() | Constants.ACCESS_INTERFACE);
setAbstract(true);
- } else {
+ } else
setAccessFlags(getAccessFlags() & ~Constants.ACCESS_INTERFACE);
- }
}
/**
- * Manipulate the class access flags.
+ * Manipulate the class access flags.
*/
public boolean isAbstract() {
- return (getAccessFlags() & Constants.ACCESS_ABSTRACT) > 0;
+ return(getAccessFlags() & Constants.ACCESS_ABSTRACT) > 0;
}
/**
- * Manipulate the class access flags.
+ * Manipulate the class access flags.
*/
public void setAbstract(boolean on) {
- if (on) {
+ if (on)
setAccessFlags(getAccessFlags() | Constants.ACCESS_INTERFACE);
- } else {
+ else
setAccessFlags(getAccessFlags() & ~Constants.ACCESS_INTERFACE);
- }
}
////////////////////////////////
@@ -196,236 +186,213 @@
////////////////////////////////
/**
- * Return the {@link ConstantPool} index of the {@link UTF8Entry} that
- * describes the simple name this class is referred to in source, or
- * 0 for anonymous classes.
+ * Return the {@link ConstantPool} index of the {@link UTF8Entry} that
+ * describes the simple name this class is referred to in source, or
+ * 0 for anonymous classes.
*/
public int getNameIndex() {
return _nameIndex;
}
/**
- * Set the {@link ConstantPool} index of the {@link UTF8Entry} that
- * describes the simple name this class is referred to in source, or
- * 0 for anonymous classes.
+ * Set the {@link ConstantPool} index of the {@link UTF8Entry} that
+ * describes the simple name this class is referred to in source, or
+ * 0 for anonymous classes.
*/
public void setNameIndex(int nameIndex) {
_nameIndex = nameIndex;
}
/**
- * Return the simple name of this inner class, or null if anonymous.
+ * Return the simple name of this inner class, or null if anonymous.
*/
public String getName() {
- if (getNameIndex() == 0) {
+ if (getNameIndex() == 0)
return null;
- }
-
- return ((UTF8Entry) getPool().getEntry(getNameIndex())).getValue();
+ return((UTF8Entry) getPool().getEntry(getNameIndex())).getValue();
}
/**
- * Set the simple name of this inner class.
+ * Set the simple name of this inner class.
*/
public void setName(String name) {
- if (name == null) {
+ if (name == null)
setNameIndex(0);
- } else {
+ else
setNameIndex(getPool().findUTF8Entry(name, true));
- }
}
/**
- * Return the {@link ConstantPool} index of the {@link ClassEntry} that
- * describes this class, or 0 if none.
+ * Return the {@link ConstantPool} index of the {@link ClassEntry} that
+ * describes this class, or 0 if none.
*/
public int getTypeIndex() {
return _index;
}
/**
- * Set the {@link ConstantPool} index of the {@link ClassEntry} that
- * describes this class.
+ * Set the {@link ConstantPool} index of the {@link ClassEntry} that
+ * describes this class.
*/
public void setTypeIndex(int index) {
_index = index;
}
/**
- * Return the full name of the inner class, or null if unset.
+ * Return the full name of the inner class, or null if unset.
*/
public String getTypeName() {
- if (getTypeIndex() == 0) {
+ if (getTypeIndex() == 0)
return null;
- }
- ClassEntry entry = (ClassEntry) getPool()
- .getEntry(getTypeIndex());
-
- return getProject().getNameCache()
- .getExternalForm(entry.getNameEntry().getValue(), false);
+ ClassEntry entry = (ClassEntry) getPool().getEntry(getTypeIndex());
+ return getProject().getNameCache().getExternalForm
+ (entry.getNameEntry().getValue(), false);
}
/**
- * Return the type of the inner class.
- * If the type has not been set, this method will return null.
+ * Return the type of the inner class.
+ * If the type has not been set, this method will return null.
*/
public Class getType() {
String type = getTypeName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return Strings.toClass(type, getClassLoader());
}
/**
- * Return the type for this instruction.
- * If the type has not been set, this method will return null.
+ * Return the type for this instruction.
+ * If the type has not been set, this method will return null.
*/
public BCClass getTypeBC() {
String type = getTypeName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return getProject().loadClass(type, getClassLoader());
}
/**
- * Set the type of this inner class.
+ * Set the type of this inner class.
*/
public void setType(String type) {
- if (type == null) {
+ if (type == null)
setTypeIndex(0);
- } else {
+ else {
type = getProject().getNameCache().getInternalForm(type, false);
setTypeIndex(getPool().findClassEntry(type, true));
}
}
/**
- * Set the type of this inner class.
+ * Set the type of this inner class.
*/
public void setType(Class type) {
- if (type == null) {
+ if (type == null)
setType((String) null);
- } else {
+ else
setType(type.getName());
- }
}
/**
- * Set the type of this inner class.
+ * Set the type of this inner class.
*/
public void setType(BCClass type) {
- if (type == null) {
+ if (type == null)
setType((String) null);
- } else {
+ else
setType(type.getName());
- }
}
/**
- * Return the {@link ConstantPool} index of the {@link ClassEntry} that
- * describes the declaring class, or 0 if this class is not a member class.
+ * Return the {@link ConstantPool} index of the {@link ClassEntry} that
+ * describes the declaring class, or 0 if this class is not a member class.
*/
public int getDeclarerIndex() {
return _ownerIndex;
}
/**
- * Set the {@link ConstantPool} index of the {@link ClassEntry} that
- * describes the declaring class, or 0 if this class is not a member class.
+ * Set the {@link ConstantPool} index of the {@link ClassEntry} that
+ * describes the declaring class, or 0 if this class is not a member class.
*/
public void setDeclarerIndex(int ownerIndex) {
_ownerIndex = ownerIndex;
}
/**
- * Return the full name of the declaring class, or null if unset/not a
- * member.
+ * Return the full name of the declaring class, or null if unset/not a
+ * member.
*/
public String getDeclarerName() {
- if (getDeclarerIndex() == 0) {
+ if (getDeclarerIndex() == 0)
return null;
- }
- ClassEntry entry = (ClassEntry) getPool().getEntry(getDeclarerIndex());
-
- return getProject().getNameCache()
- .getExternalForm(entry.getNameEntry().getValue(), false);
+ ClassEntry entry = (ClassEntry) getPool().getEntry (getDeclarerIndex());
+ return getProject().getNameCache().getExternalForm
+ (entry.getNameEntry().getValue(), false);
}
/**
- * Return the type of the declaring class.
- * If the type has not been set or the class is not a member, this method
- * will return null.
+ * Return the type of the declaring class.
+ * If the type has not been set or the class is not a member, this method
+ * will return null.
*/
public Class getDeclarerType() {
String type = getDeclarerName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return Strings.toClass(type, getClassLoader());
}
/**
- * Return the type for this instruction.
- * If the type has not been set or the class is not a member, this method
- * will return null.
+ * Return the type for this instruction.
+ * If the type has not been set or the class is not a member, this method
+ * will return null.
*/
public BCClass getDeclarerBC() {
String type = getDeclarerName();
-
- if (type == null) {
+ if (type == null)
return null;
- }
-
return getProject().loadClass(type, getClassLoader());
}
/**
- * Set the type of this declaring class.
+ * Set the type of this declaring class.
*/
public void setDeclarer(String type) {
- if (type == null) {
+ if (type == null)
setDeclarerIndex(0);
- } else {
+ else {
type = getProject().getNameCache().getInternalForm(type, false);
setDeclarerIndex(getPool().findClassEntry(type, true));
}
}
/**
- * Set the type of this declaring class.
+ * Set the type of this declaring class.
*/
public void setDeclarer(Class type) {
- if (type == null) {
+ if (type == null)
setDeclarer((String) null);
- } else {
+ else
setDeclarer(type.getName());
- }
}
/**
- * Set the type of this declaring class.
+ * Set the type of this declaring class.
*/
public void setDeclarer(BCClass type) {
- if (type == null) {
+ if (type == null)
setDeclarer((String) null);
- } else {
+ else
setDeclarer(type.getName());
- }
}
///////////////////////////
// BCEntity implementation
///////////////////////////
+
public Project getProject() {
return _owner.getProject();
}
@@ -450,6 +417,7 @@
//////////////////
// I/O operations
//////////////////
+
void read(DataInput in) throws IOException {
setTypeIndex(in.readUnsignedShort());
setDeclarerIndex(in.readUnsignedShort());
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClasses.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClasses.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClasses.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InnerClasses.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,18 +12,15 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>Attribute describing all referenced classes that are not package
- * members. This includes all member interfaces and classes.</p>
- *
- * @author Abe White
+ * Attribute describing all referenced classes that are not package
+ * members. This includes all member interfaces and classes.
+ *
+ * @author Abe White
*/
public class InnerClasses extends Attribute {
private List _innerClasses = new LinkedList();
@@ -36,141 +30,126 @@
}
/**
- * Return all referenced inner classes, or empty array if none.
+ * Return all referenced inner classes, or empty array if none.
*/
public InnerClass[] getInnerClasses() {
- return (InnerClass[]) _innerClasses.toArray(new InnerClass[_innerClasses.size()]);
+ return(InnerClass[]) _innerClasses.toArray
+ (new InnerClass[_innerClasses.size()]);
}
/**
- * Return the inner class with the given name. If multiple inner classes
- * share the name, which is returned is undefined. Use null to retrieve
- * anonymous classes.
+ * Return the inner class with the given name. If multiple inner classes
+ * share the name, which is returned is undefined. Use null to retrieve
+ * anonymous classes.
*/
public InnerClass getInnerClass(String name) {
InnerClass[] inners = getInnerClasses();
String inner;
-
for (int i = 0; i < inners.length; i++) {
inner = inners[i].getName();
-
- if (((inner == null) && (name == null)) ||
- ((inner != null) && inner.equals(name))) {
+ if ((inner == null && name == null)
+ || (inner != null && inner.equals(name)))
return inners[i];
- }
}
-
return null;
}
/**
- * Return all inner classes with the given name, or empty array if none.
- * Use null to retrieve anonymous classes.
+ * Return all inner classes with the given name, or empty array if none.
+ * Use null to retrieve anonymous classes.
*/
public InnerClass[] getInnerClasses(String name) {
List matches = new LinkedList();
InnerClass[] inners = getInnerClasses();
String inner;
-
for (int i = 0; i < inners.length; i++) {
inner = inners[i].getName();
-
- if (((inner == null) && (name == null)) ||
- ((inner != null) && inner.equals(name))) {
+ if ((inner == null && name == null)
+ || (inner != null && inner.equals(name)))
matches.add(inners[i]);
- }
}
-
- return (InnerClass[]) matches.toArray(new InnerClass[matches.size()]);
+ return(InnerClass[]) matches.toArray(new InnerClass[matches.size()]);
}
/**
- * Set the inner class references for this class. This method is
- * useful when importing inner class references from another class.
+ * Set the inner class references for this class. This method is
+ * useful when importing inner class references from another class.
*/
public void setInnerClasses(InnerClass[] inners) {
clear();
-
- if (inners != null) {
+ if (inners != null)
for (int i = 0; i < inners.length; i++)
addInnerClass(inners[i]);
- }
}
/**
- * Import an inner class from another entity, or make a copy of one
- * on this entity.
- *
- * @return the newly added inner class
+ * Import an inner class from another entity, or make a copy of one
+ * on this entity.
+ *
+ * @return the newly added inner class
*/
public InnerClass addInnerClass(InnerClass inner) {
- InnerClass newInner = addInnerClass(inner.getName(),
- inner.getTypeName(), inner.getDeclarerName());
+ InnerClass newInner = addInnerClass
+ (inner.getName(), inner.getTypeName(), inner.getDeclarerName());
newInner.setAccessFlags(inner.getAccessFlags());
-
return newInner;
}
/**
- * Add an inner class.
+ * Add an inner class.
*/
public InnerClass addInnerClass() {
InnerClass inner = new InnerClass(this);
_innerClasses.add(inner);
-
return inner;
}
/**
- * Add an inner class.
- *
- * @param name the simple name of the class, or null if anonymous
- * @param type the full class name of the inner class
- * @param owner the declaring class, or null if not a member class
+ * Add an inner class.
+ *
+ * @param name the simple name of the class, or null if anonymous
+ * @param type the full class name of the inner class
+ * @param owner the declaring class, or null if not a member class
*/
public InnerClass addInnerClass(String name, String type, String owner) {
InnerClass inner = addInnerClass();
inner.setName(name);
inner.setType(type);
inner.setDeclarer(owner);
-
return inner;
}
/**
- * Add an inner class.
- *
- * @param name the simple name of the class, or null if anonymous
- * @param type the class of the inner class
- * @param owner the declaring class, or null if not a member class
+ * Add an inner class.
+ *
+ * @param name the simple name of the class, or null if anonymous
+ * @param type the class of the inner class
+ * @param owner the declaring class, or null if not a member class
*/
public InnerClass addInnerClass(String name, Class type, Class owner) {
String typeName = (type == null) ? null : type.getName();
String ownerName = (owner == null) ? null : owner.getName();
-
return addInnerClass(name, typeName, ownerName);
}
/**
- * Add an inner class.
- *
- * @param name the simple name of the class, or null if anonymous
- * @param type the class of the inner class
- * @param owner the declaring class, or null if not a member class
+ * Add an inner class.
+ *
+ * @param name the simple name of the class, or null if anonymous
+ * @param type the class of the inner class
+ * @param owner the declaring class, or null if not a member class
*/
public InnerClass addInnerClass(String name, BCClass type, BCClass owner) {
String typeName = (type == null) ? null : type.getName();
String ownerName = (owner == null) ? null : owner.getName();
-
return addInnerClass(name, typeName, ownerName);
}
/**
- * Clear all inner classes from this entity.
+ * Clear all inner classes from this entity.
*/
public void clear() {
InnerClass inner;
-
for (Iterator itr = _innerClasses.iterator(); itr.hasNext();) {
inner = (InnerClass) itr.next();
itr.remove();
@@ -179,28 +158,26 @@
}
/**
- * Remove the inner class with the given name. Use null for anonymous
- * classes.
- *
- * @return true if an inner class was removed, false otherwise
+ * Remove the inner class with the given name. Use null for anonymous
+ * classes.
+ *
+ * @return true if an inner class was removed, false otherwise
*/
public boolean removeInnerClass(String name) {
return removeInnerClass(getInnerClass(name));
}
/**
- * Remove the given inner class. After being removed, the given inner
- * class is invalid, and the result of any operations on it are undefined.
- *
- * @return true if the inner class was removed, false otherwise
+ * Remove the given inner class. After being removed, the given inner
+ * class is invalid, and the result of any operations on it are undefined.
+ *
+ * @return true if the inner class was removed, false otherwise
*/
public boolean removeInnerClass(InnerClass innerClass) {
- if ((innerClass == null) || !_innerClasses.remove(innerClass)) {
+ if (innerClass == null || !_innerClasses.remove(innerClass))
return false;
- }
innerClass.invalidate();
-
return true;
}
@@ -208,7 +185,6 @@
visit.enterInnerClasses(this);
InnerClass[] inners = getInnerClasses();
-
for (int i = 0; i < inners.length; i++)
inners[i].acceptVisit(visit);
@@ -216,7 +192,7 @@
}
int getLength() {
- return 2 + (8 * _innerClasses.size());
+ return 2 + 8 * _innerClasses.size();
}
void read(Attribute other) {
@@ -225,11 +201,9 @@
void read(DataInput in, int length) throws IOException {
clear();
-
int numInnerClasses = in.readUnsignedShort();
InnerClass innerClass;
-
for (int i = 0; i < numInnerClasses; i++) {
innerClass = addInnerClass();
innerClass.read(in);
@@ -239,7 +213,6 @@
void write(DataOutput out, int length) throws IOException {
InnerClass[] inners = getInnerClasses();
out.writeShort(inners.length);
-
for (int i = 0; i < inners.length; i++)
inners[i].write(out);
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Instruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Instruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Instruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/Instruction.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,19 +12,15 @@
*/
package serp.bytecode;
-import serp.bytecode.lowlevel.*;
-
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.lowlevel.*;
+import serp.bytecode.visitor.*;
/**
- * <p>An opcode in a method of a class.</p>
- *
- * @author Abe White
+ * An opcode in a method of a class.
+ *
+ * @author Abe White
*/
public class Instruction extends CodeEntry implements BCEntity, VisitAcceptor {
private Code _owner = null;
@@ -43,106 +36,98 @@
}
/**
- * Return the code block that owns this instruction.
+ * Return the code block that owns this instruction.
*/
public Code getCode() {
return _owner;
}
/**
- * Return the name of this instruction.
+ * Return the name of this instruction.
*/
public String getName() {
return Constants.OPCODE_NAMES[_opcode];
}
/**
- * Return the opcode this instruction represents.
+ * Return the opcode this instruction represents.
*/
public int getOpcode() {
return _opcode;
}
/**
- * Set the opcode this instruction represents. For internal use only.
- *
- * @return this instruction, for method chaining
+ * Set the opcode this instruction represents. For internal use only.
+ *
+ * @return this instruction, for method chaining
*/
Instruction setOpcode(int opcode) {
_opcode = opcode;
-
return this;
}
/**
- * Return the index in the method code byte block at which this opcode
- * starts. Note that this information may be out of date if the code
- * block has been modified since last read/written.
+ * Return the index in the method code byte block at which this opcode
+ * starts. Note that this information may be out of date if the code
+ * block has been modified since last read/written.
*/
public int getByteIndex() {
- if (_owner != null) {
+ if (_owner != null)
return _owner.getByteIndex(this);
- }
-
return 0;
}
/**
- * Return the line number of this instruction, or null if none. This
- * method is subject to the validity constraints of {@link #getByteIndex}.
- *
- * @see LineNumberTable#getLineNumber(Instruction)
+ * Return the line number of this instruction, or null if none. This
+ * method is subject to the validity constraints of {@link #getByteIndex}.
+ *
+ * @see LineNumberTable#getLineNumber(Instruction)
*/
public LineNumber getLineNumber() {
LineNumberTable table = _owner.getLineNumberTable(false);
-
- if (table == null) {
+ if (table == null)
return null;
- }
-
return table.getLineNumber(this);
}
/**
- * Return the length in bytes of this opcode, including all arguments.
- * For many opcodes this method relies on an up-to-date byte index.
+ * Return the length in bytes of this opcode, including all arguments.
+ * For many opcodes this method relies on an up-to-date byte index.
*/
int getLength() {
return 1;
}
/**
- * Return the logical number of stack positions changed by this
- * instruction. In other words, ignore weirdness with longs and doubles
- * taking two stack positions.
+ * Return the logical number of stack positions changed by this
+ * instruction. In other words, ignore weirdness with longs and doubles
+ * taking two stack positions.
*/
public int getLogicalStackChange() {
return getStackChange();
}
/**
- * Return the number of stack positions this instruction pushes
- * or pops during its execution.
- *
- * @return 0 if the stack is not affected by this instruction, a
- * positive number if it pushes onto the stack, and a negative
- * number if it pops from the stack
+ * Return the number of stack positions this instruction pushes
+ * or pops during its execution.
+ *
+ * @return 0 if the stack is not affected by this instruction, a
+ * positive number if it pushes onto the stack, and a negative
+ * number if it pops from the stack
*/
public int getStackChange() {
return 0;
}
/**
- * Instructions are equal if their opcodes are the same. Subclasses
- * should override this method to perform a template comparison:
- * instructions should compare equal to other instructions of the same
- * type where the data is either the same or the data is unset.
+ * Instructions are equal if their opcodes are the same. Subclasses
+ * should override this method to perform a template comparison:
+ * instructions should compare equal to other instructions of the same
+ * type where the data is either the same or the data is unset.
*/
public boolean equalsInstruction(Instruction other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
return other.getOpcode() == getOpcode();
}
@@ -170,21 +155,21 @@
}
/**
- * Copy the given instruction data.
+ * Copy the given instruction data.
*/
void read(Instruction orig) {
}
/**
- * Read the arguments for this opcode from the given stream.
- * This method should be overridden by opcodes that take arguments.
+ * Read the arguments for this opcode from the given stream.
+ * This method should be overridden by opcodes that take arguments.
*/
void read(DataInput in) throws IOException {
}
/**
- * Write the arguments for this opcode to the given stream.
- * This method should be overridden by opcodes that take arguments.
+ * Write the arguments for this opcode to the given stream.
+ * This method should be overridden by opcodes that take arguments.
*/
void write(DataOutput out) throws IOException {
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtr.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtr.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtr.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtr.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,32 +14,31 @@
import java.util.*;
-
/**
- * <p>An entity that maintains ptrs to instructions in a code block.</p>
- *
- * @author Abe White
+ * An entity that maintains ptrs to instructions in a code block.
+ *
+ * @author Abe White
*/
public interface InstructionPtr {
/**
- * Use the byte indexes read from the class file to calculate and
- * set references to the target instruction(s) for this ptr.
- * This method will be called after the byte code
- * has been read in for the first time and before it is written after
- * modification.
+ * Use the byte indexes read from the class file to calculate and
+ * set references to the target instruction(s) for this ptr.
+ * This method will be called after the byte code
+ * has been read in for the first time and before it is written after
+ * modification.
*/
public void updateTargets();
/**
- * Replace the given old, likely invalid, target with a new target. The
- * new target Instruction is guaranteed to be in the same code
- * block as this InstructionPtr.
+ * Replace the given old, likely invalid, target with a new target. The
+ * new target Instruction is guaranteed to be in the same code
+ * block as this InstructionPtr.
*/
public void replaceTarget(Instruction oldTarget, Instruction newTarget);
/**
- * Returns the Code block that owns the Instruction(s) this
- * InstructionPtr points to.
+ * Returns the Code block that owns the Instruction(s) this
+ * InstructionPtr points to.
*/
public Code getCode();
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtrStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtrStrategy.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtrStrategy.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/InstructionPtrStrategy.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,14 @@
*/
package serp.bytecode;
-
/**
- * <p>InstructionPtrStrategy handles the different strategies for finding the
- * Instructions that InstructionPtrs point to. These strategies include,
- * from least desirable to most desirable, using byte indexes,
- * and storing a reference to the target Instruction proper.</p>
- *
- * @author Eric Lindauer
- * @date 2002.7.26
+ * InstructionPtrStrategy handles the different strategies for finding the
+ * Instructions that InstructionPtrs point to. These strategies include,
+ * from least desirable to most desirable, using byte indexes,
+ * and storing a reference to the target Instruction proper.
+ *
+ * @author Eric Lindauer
+ * @date 2002.7.26
*/
class InstructionPtrStrategy implements InstructionPtr {
// the Instruction doing the targetting
@@ -44,74 +40,66 @@
}
/**
- * Sets the byteIndex where the target Instruction can be found.
- * This target will now be using byte indices as its target finding
- * strategy, which is the least robust option. Changing the Code block
- * or importing it into another Method may result in an invalid target.
+ * Sets the byteIndex where the target Instruction can be found.
+ * This target will now be using byte indices as its target finding
+ * strategy, which is the least robust option. Changing the Code block
+ * or importing it into another Method may result in an invalid target.
*/
public void setByteIndex(int index) {
- if ((index < 0) && (index != -1)) {
+ if (index < 0 && index != -1)
throw new IllegalArgumentException(String.valueOf(index));
- }
_byteIndex = index;
_target = null;
}
/**
- * Changes the target Instruction. The target is in the best state
- * possible and should maintain this information even in the face
- * of Code imports and Code changes.
+ * Changes the target Instruction. The target is in the best state
+ * possible and should maintain this information even in the face
+ * of Code imports and Code changes.
*/
public void setTargetInstruction(Instruction ins) {
- if (ins.getCode() != getCode()) {
- throw new IllegalArgumentException("Instruction pointers and " +
- "targets must be part of the same code block.");
- }
+ if (ins.getCode() != getCode())
+ throw new IllegalArgumentException("Instruction pointers and "
+ + "targets must be part of the same code block.");
_target = ins;
_byteIndex = -1;
}
/**
- * Returns the Instruction this Target is targetting. This request
- * does not change the targetting strategy for this Target.
+ * Returns the Instruction this Target is targetting. This request
+ * does not change the targetting strategy for this Target.
*/
public Instruction getTargetInstruction() {
- if (_target != null) {
+ if (_target != null)
return _target;
- }
-
return getCode().getInstruction(_byteIndex);
}
/**
- * Returns the byteIndex at which the target instruction can be found.
- * This call does not change the Target strategy.
+ * Returns the byteIndex at which the target instruction can be found.
+ * This call does not change the Target strategy.
*/
public int getByteIndex() {
- if (_target == null) {
+ if (_target == null)
return _byteIndex;
- }
-
return _target.getByteIndex();
}
/**
- * Same as getInstruction, but this method alters the Target strategy
- * to use the returned Instruction. This method alters the Target
- * strategy (and Instruction) iff it was previously using byte indexes.
+ * Same as getInstruction, but this method alters the Target strategy
+ * to use the returned Instruction. This method alters the Target
+ * strategy(and Instruction) iff it was previously using byte indexes.
*/
public void updateTargets() {
- if (_target == null) {
+ if (_target == null)
_target = getCode().getInstruction(_byteIndex);
- }
}
public void replaceTarget(Instruction oldTarget, Instruction newTarget) {
- if (getTargetInstruction() == oldTarget) {
+ if (getTargetInstruction() == oldTarget)
setTargetInstruction(newTarget);
- }
}
public Code getCode() {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/JumpInstruction.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/JumpInstruction.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/JumpInstruction.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/JumpInstruction.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,18 +12,15 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>An instruction that specifies a position in the code block to jump to.
- * Examples include <code>go2, jsr</code>, etc.</p>
- *
- * @author Abe White
+ * An instruction that specifies a position in the code block to jump to.
+ * Examples include <code>go2, jsr</code>, etc.
+ *
+ * @author Abe White
*/
public class JumpInstruction extends Instruction implements InstructionPtr {
private InstructionPtrStrategy _target = new InstructionPtrStrategy(this);
@@ -40,10 +34,8 @@
}
public int getStackChange() {
- if (getOpcode() == Constants.JSR) {
+ if (getOpcode() == Constants.JSR)
return 1;
- }
-
return 0;
}
@@ -52,49 +44,42 @@
case Constants.GOTOW:
case Constants.JSRW:
return super.getLength() + 4;
-
default:
return super.getLength() + 2;
}
}
/**
- * Get the current target instruction to jump to, if it has been set.
+ * Get the current target instruction to jump to, if it has been set.
*/
public Instruction getTarget() {
return _target.getTargetInstruction();
}
/**
- * Set the instruction to jump to; the instruction must already be
- * added to the code block.
- *
- * @return this instruction, for method chaining
+ * Set the instruction to jump to; the instruction must already be
+ * added to the code block.
+ *
+ * @return this instruction, for method chaining
*/
public JumpInstruction setTarget(Instruction instruction) {
_target.setTargetInstruction(instruction);
-
return this;
}
/**
- * JumpInstructions are equal if they represent the same operation and
- * the instruction they jump to is the
- * same, or if the jump Instruction of either is unset.
+ * JumpInstructions are equal if they represent the same operation and
+ * the instruction they jump to is the
+ * same, or if the jump Instruction of either is unset.
*/
public boolean equalsInstruction(Instruction other) {
- if (this == other) {
+ if (this == other)
return true;
- }
-
- if (!super.equalsInstruction(other)) {
+ if (!super.equalsInstruction(other))
return false;
- }
Instruction target = ((JumpInstruction) other).getTarget();
-
- return ((target == null) || (getTarget() == null) ||
- (target == getTarget()));
+ return(target == null || getTarget() == null || target == getTarget());
}
public void updateTargets() {
@@ -122,9 +107,7 @@
case Constants.GOTOW:
case Constants.JSRW:
setOffset(in.readInt());
-
break;
-
default:
setOffset(in.readShort());
}
@@ -137,9 +120,7 @@
case Constants.GOTOW:
case Constants.JSRW:
out.writeInt(getOffset());
-
break;
-
default:
out.writeShort(getOffset());
}
@@ -147,30 +128,22 @@
void calculateOpcode() {
int offset;
-
switch (getOpcode()) {
case Constants.GOTO:
case Constants.GOTOW:
offset = getOffset();
-
- if (offset < (2 << 16)) {
+ if (offset < (2 << 16))
setOpcode(Constants.GOTO);
- } else {
+ else
setOpcode(Constants.GOTOW);
- }
-
break;
-
case Constants.JSR:
case Constants.JSRW:
offset = getOffset();
-
- if (offset < (2 << 16)) {
+ if (offset < (2 << 16))
setOpcode(Constants.JSR);
- } else {
+ else
setOpcode(Constants.JSRW);
- }
-
break;
}
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumber.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumber.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumber.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumber.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,22 @@
*/
package serp.bytecode;
-import serp.bytecode.lowlevel.*;
-
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.lowlevel.*;
+import serp.bytecode.visitor.*;
/**
- * <p>A line number corresponds to a sequence of opcodes that map logically
- * to a line of source code.</p>
- *
- * @author Abe White
+ * A line number corresponds to a sequence of opcodes that map logically
+ * to a line of source code.
+ *
+ * @author Abe White
*/
-public class LineNumber implements Comparable, InstructionPtr, BCEntity,
- VisitAcceptor {
+public class LineNumber
+ implements Comparable, InstructionPtr, BCEntity, VisitAcceptor {
private int _line = 0;
private LineNumberTable _owner = null;
+
InstructionPtrStrategy _target = new InstructionPtrStrategy(this);
LineNumber(LineNumberTable owner) {
@@ -46,7 +40,7 @@
}
/**
- * Line numbers are stored in a {@link LineNumberTable}.
+ * Line numbers are stored in a {@link LineNumberTable}.
*/
public LineNumberTable getTable() {
return _owner;
@@ -57,43 +51,43 @@
}
/**
- * Return source line number.
+ * Return source line number.
*/
public int getLine() {
return _line;
}
/**
- * Set the source line number.
+ * Set the source line number.
*/
public void setLine(int lineNumber) {
_line = lineNumber;
}
/**
- * Return the instruction marking the beginning of this line.
+ * Return the instruction marking the beginning of this line.
*/
public Instruction getStart() {
return _target.getTargetInstruction();
}
/**
- * Return the index into the code byte array at which this line starts.
+ * Return the index into the code byte array at which this line starts.
*/
public int getStartPc() {
return _target.getByteIndex();
}
/**
- * Set the index into the code byte array at which this line starts.
+ * Set the index into the code byte array at which this line starts.
*/
public void setStartPc(int startPc) {
_target.setByteIndex(startPc);
}
/**
- * Set the {@link Instruction} marking the beginning this line.
- * The instruction must already be a part of the method.
+ * Set the {@link Instruction} marking the beginning this line.
+ * The instruction must already be a part of the method.
*/
public void setStart(Instruction instruction) {
_target.setTargetInstruction(instruction);
@@ -129,20 +123,14 @@
}
public int compareTo(Object other) {
- if (!(other instanceof LineNumber)) {
+ if (!(other instanceof LineNumber))
return -1;
- }
LineNumber ln = (LineNumber) other;
-
- if (getStartPc() == ln.getStartPc()) {
+ if (getStartPc() == ln.getStartPc())
return 0;
- }
-
- if (getStartPc() < ln.getStartPc()) {
+ if (getStartPc() < ln.getStartPc())
return -1;
- }
-
return 1;
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumberTable.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumberTable.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumberTable.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/LineNumberTable.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,20 +12,17 @@
*/
package serp.bytecode;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>Code blocks compiled from source have line number tables mapping
- * opcodes to source lines. This table automatically maintains line
- * numbers in ascending order by their start program counter position
- * at all times.</p>
- *
- * @author Abe White
+ * Code blocks compiled from source have line number tables mapping
+ * opcodes to source lines. This table automatically maintains line
+ * numbers in ascending order by their start program counter position
+ * at all times.
+ *
+ * @author Abe White
*/
public class LineNumberTable extends Attribute implements InstructionPtr {
private List _lineNumbers = new ArrayList();
@@ -38,133 +32,121 @@
}
/**
- * Return the line numbers held in this table.
+ * Return the line numbers held in this table.
*/
public LineNumber[] getLineNumbers() {
Collections.sort(_lineNumbers);
-
- return (LineNumber[]) _lineNumbers.toArray(new LineNumber[_lineNumbers.size()]);
+ return(LineNumber[]) _lineNumbers.toArray
+ (new LineNumber[_lineNumbers.size()]);
}
/**
- * Return the line number for the given program counter, or null if none.
+ * Return the line number for the given program counter, or null if none.
*/
public LineNumber getLineNumber(int pc) {
for (int i = _lineNumbers.size() - 1; i >= 0; i--)
- if (((LineNumber) _lineNumbers.get(i))._target.getByteIndex() <= pc) {
- return (LineNumber) _lineNumbers.get(i);
- }
-
+ if (((LineNumber) _lineNumbers.get(i)).
+ _target.getByteIndex() <= pc)
+ return(LineNumber) _lineNumbers.get(i);
return null;
}
/**
- * Return the line number for the given instruction, or null if none.
+ * Return the line number for the given instruction, or null if none.
*/
public LineNumber getLineNumber(Instruction ins) {
- if (ins == null) {
+ if (ins == null)
return null;
- }
-
return getLineNumber(ins.getByteIndex());
}
/**
- * Set the line numbers for the table. This method is useful when
- * importing line numbers from another method.
+ * Set the line numbers for the table. This method is useful when
+ * importing line numbers from another method.
*/
public void setLineNumbers(LineNumber[] lines) {
clear();
-
- if (lines != null) {
+ if (lines != null)
for (int i = 0; i < lines.length; i++)
addLineNumber(lines[i]);
- }
}
/**
- * Import a line number from another method.
- *
- * @return the newly added line number
+ * Import a line number from another method.
+ *
+ * @return the newly added line number
*/
public LineNumber addLineNumber(LineNumber ln) {
LineNumber line = addLineNumber();
line.setStartPc(ln.getStartPc());
line.setLine(ln.getLine());
-
return line;
}
/**
- * Add a new line number to this table.
+ * Add a new line number to this table.
*/
public LineNumber addLineNumber() {
LineNumber ln = new LineNumber(this);
_lineNumbers.add(ln);
-
return ln;
}
/**
- * Add a new line number to this table.
- */
+ * Add a new line number to this table.
+ */
public LineNumber addLineNumber(int startPc, int line) {
LineNumber ln = addLineNumber();
ln.setStartPc(startPc);
ln.setLine(line);
-
return ln;
}
/**
- * Add a new line number to this table.
- */
+ * Add a new line number to this table.
+ */
public LineNumber addLineNumber(Instruction start, int line) {
LineNumber ln = addLineNumber();
ln.setStart(start);
ln.setLine(line);
-
return ln;
}
/**
- * Clear the line numbers.
+ * Clear the line numbers.
*/
public void clear() {
for (int i = 0; i < _lineNumbers.size(); i++)
((LineNumber) _lineNumbers.get(i)).invalidate();
-
_lineNumbers.clear();
}
/**
- * Remove the given line.
- *
- * @return true if the line was removed, false otherwise
+ * Remove the given line.
+ *
+ * @return true if the line was removed, false otherwise
*/
public boolean removeLineNumber(LineNumber ln) {
- if ((ln == null) || !_lineNumbers.remove(ln)) {
+ if (ln == null || !_lineNumbers.remove(ln))
return false;
- }
ln.invalidate();
-
return true;
}
/**
- * Remove the line number for the given program counter.
- *
- * @return true if the line was removed, false otherwise
+ * Remove the line number for the given program counter.
+ *
+ * @return true if the line was removed, false otherwise
*/
public boolean removeLineNumber(int pc) {
return removeLineNumber(getLineNumber(pc));
}
/**
- * Remove the line number for the given instruction.
- *
- * @return true if the line was removed, false otherwise
+ * Remove the line number for the given instruction.
+ *
+ * @return true if the line was removed, false otherwise
*/
public boolean removeLineNumber(Instruction ins) {
return removeLineNumber(getLineNumber(ins));
@@ -185,7 +167,6 @@
visit.enterLineNumberTable(this);
LineNumber[] lines = getLineNumbers();
-
for (int i = 0; i < lines.length; i++)
lines[i].acceptVisit(visit);
@@ -193,7 +174,7 @@
}
int getLength() {
- return 2 + (4 * _lineNumbers.size());
+ return 2 + 4 * _lineNumbers.size();
}
void read(Attribute other) {
@@ -202,11 +183,9 @@
void read(DataInput in, int length) throws IOException {
clear();
-
int numLines = in.readUnsignedShort();
LineNumber lineNumber;
-
for (int i = 0; i < numLines; i++) {
lineNumber = addLineNumber();
lineNumber.read(in);
@@ -216,12 +195,11 @@
void write(DataOutput out, int length) throws IOException {
LineNumber[] lines = getLineNumbers();
out.writeShort(lines.length);
-
for (int i = 0; i < lines.length; i++)
lines[i].write(out);
}
public Code getCode() {
- return (Code) getOwner();
+ return(Code) getOwner();
}
}