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 [30/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/lowlevel/ConstantEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantEntry.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,20 @@
*/
package serp.bytecode.lowlevel;
-
/**
- * <p>Interface implemented by entries representing constant values. Allows
- * generic access the constant value regardless of type.</p>
- *
- * @author Abe White
+ * Interface implemented by entries representing constant values. Allows
+ * generic access the constant value regardless of type.
+ *
+ * @author Abe White
*/
public interface ConstantEntry {
/**
- * Return the value of the constant held by this entry.</p>
+ * Return the value of the constant held by this entry.
*/
public Object getConstant();
/**
- * Set the value of the constant held by this entry.</p>
+ * Set the value of the constant held by this entry.
*/
public void setConstant(Object value);
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPool.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPool.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPool.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPool.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,95 +12,80 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
-import serp.util.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.visitor.*;
+import serp.util.*;
/**
- * <p>A bytecode constant pool, containing entries for all strings,
- * constants, classes, etc referenced in the class structure and method
- * opcodes. In keeping with the low-level bytecode representation, all pool
- * indexes are 1-based and {@link LongEntry}s and {@link DoubleEntry}s each
- * occupy two indexes in the pool.</p>
- *
- * @author Abe White
+ * A bytecode constant pool, containing entries for all strings,
+ * constants, classes, etc referenced in the class structure and method
+ * opcodes. In keeping with the low-level bytecode representation, all pool
+ * indexes are 1-based and {@link LongEntry}s and {@link DoubleEntry}s each
+ * occupy two indexes in the pool.
+ *
+ * @author Abe White
*/
public class ConstantPool implements VisitAcceptor {
private List _entries = new ArrayList(50);
private Map _lookup = new HashMap(50);
/**
- * Default constructor.
+ * Default constructor.
*/
public ConstantPool() {
}
/**
- * Return all the entries in the pool.
+ * Return all the entries in the pool.
*/
public Entry[] getEntries() {
List entries = new ArrayList(_entries.size());
Entry entry;
-
for (Iterator itr = _entries.iterator(); itr.hasNext();) {
entry = (Entry) itr.next();
-
- if (entry != null) {
+ if (entry != null)
entries.add(entry);
- }
}
-
- return (Entry[]) entries.toArray(new Entry[entries.size()]);
+ return(Entry[]) entries.toArray(new Entry[entries.size()]);
}
/**
- * Retrieve the entry at the specified 1-based index.
- *
- * @throws IndexOutOfBoundsException if index is invalid,
- * including the case that it points to the second slot of a
- * long or double entry
+ * Retrieve the entry at the specified 1-based index.
+ *
+ * @throws IndexOutOfBoundsException if index is invalid,
+ * including the case that it points to the second slot of a
+ * long or double entry
*/
public Entry getEntry(int index) {
Entry entry = (Entry) _entries.get(index - 1);
-
- if (entry == null) {
+ if (entry == null)
throw new IndexOutOfBoundsException("index = " + index);
- }
-
return entry;
}
/**
- * Return the index of the given entry, or 0 if it is not in the pool.
+ * Return the index of the given entry, or 0 if it is not in the pool.
*/
public int indexOf(Entry entry) {
- if ((entry == null) || (entry.getPool() != this)) {
+ if (entry == null || entry.getPool() != this)
return 0;
- }
-
return entry.getIndex();
}
/**
- * Add an entry to the pool.
- *
- * @return the index at which the entry was added
+ * Add an entry to the pool.
+ *
+ * @return the index at which the entry was added
*/
public int addEntry(Entry entry) {
- if (entry.getPool() != this) {
+ if (entry.getPool() != this)
addEntry(getKey(entry), entry);
- }
-
return entry.getIndex();
}
/**
- * Add an entry to the pool using the given key.
+ * Add an entry to the pool using the given key.
*/
private int addEntry(Object key, Entry entry) {
entry.setPool(this);
@@ -111,42 +93,33 @@
entry.setIndex(_entries.size());
_lookup.put(key, entry);
-
- if (entry.isWide()) {
+ if (entry.isWide())
_entries.add(null);
- }
-
return entry.getIndex();
}
/**
- * Remove the given entry from the pool.
- *
- * @return false if the entry is not in the pool, true otherwise
+ * Remove the given entry from the pool.
+ *
+ * @return false if the entry is not in the pool, true otherwise
*/
public boolean removeEntry(Entry entry) {
- if ((entry == null) || (entry.getPool() != this)) {
+ if (entry == null || entry.getPool() != this)
return false;
- }
int index = entry.getIndex() - 1;
entry.setPool(null);
entry.setIndex(0);
_entries.remove(index);
-
- if (entry.isWide()) {
+ if (entry.isWide())
_entries.remove(index);
- }
-
_lookup.remove(getKey(entry));
// rehash all the entries after the removed one with their new index
Object key;
-
for (int i = index; i < _entries.size(); i++) {
entry = (Entry) _entries.get(i);
-
if (entry != null) {
key = getKey(entry);
_lookup.remove(key);
@@ -154,19 +127,16 @@
_lookup.put(key, entry);
}
}
-
return true;
}
/**
- * Clear all entries from the pool.
+ * Clear all entries from the pool.
*/
public void clear() {
Entry entry;
-
for (Iterator itr = _entries.iterator(); itr.hasNext();) {
entry = (Entry) itr.next();
-
if (entry != null) {
entry.setPool(null);
entry.setIndex(0);
@@ -178,310 +148,254 @@
}
/**
- * Return the number of places occupied in the pool, including the fact
- * that long and double entries occupy two places.
+ * Return the number of places occupied in the pool, including the fact
+ * that long and double entries occupy two places.
*/
public int size() {
return _entries.size();
}
/**
- * Return the index of the {@link UTF8Entry} with the given value, or
- * 0 if it does not exist.
- *
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
+ * Return the index of the {@link UTF8Entry} with the given value, or
+ * 0 if it does not exist.
+ *
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
*/
public int findUTF8Entry(String value, boolean add) {
if (value == null) {
- if (add) {
+ if (add)
throw new NullPointerException("value = null");
- }
-
return 0;
}
int index = find(value);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(value, new UTF8Entry(value));
}
/**
- * Return the constant pool index of the {@link DoubleEntry} for the given
- * value, or 0 if it does not exist.
- *
- * @param value the value to find
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link DoubleEntry} for the given
+ * value, or 0 if it does not exist.
+ *
+ * @param value the value to find
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findDoubleEntry(double value, boolean add) {
Double key = new Double(value);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new DoubleEntry(value));
}
/**
- * Return the constant pool index of the {@link FloatEntry} for the given
- * value, or 0 if it does not exist.
- *
- * @param value the value to find
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link FloatEntry} for the given
+ * value, or 0 if it does not exist.
+ *
+ * @param value the value to find
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findFloatEntry(float value, boolean add) {
Float key = new Float(value);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new FloatEntry(value));
}
/**
- * Return the constant pool index of the {@link IntEntry} for the given
- * value, or 0 if it does not exist.
- *
- * @param value the value to find
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link IntEntry} for the given
+ * value, or 0 if it does not exist.
+ *
+ * @param value the value to find
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findIntEntry(int value, boolean add) {
Integer key = Numbers.valueOf(value);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new IntEntry(value));
}
/**
- * Return the constant pool index of the {@link LongEntry} for the given
- * value, or 0 if it does not exist.
- *
- * @param value the value to find
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link LongEntry} for the given
+ * value, or 0 if it does not exist.
+ *
+ * @param value the value to find
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findLongEntry(long value, boolean add) {
Long key = Numbers.valueOf(value);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new LongEntry(value));
}
/**
- * Return the constant pool index of the {@link StringEntry} for the given
- * string value, or 0 if it does not exist.
- *
- * @param value the value to find
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link StringEntry} for the given
+ * string value, or 0 if it does not exist.
+ *
+ * @param value the value to find
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findStringEntry(String value, boolean add) {
int valueIndex = findUTF8Entry(value, add);
-
- if (valueIndex == 0) {
+ if (valueIndex == 0)
return 0;
- }
StringKey key = new StringKey(valueIndex);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new StringEntry(valueIndex));
}
/**
- * Return the constant pool index of the {@link ClassEntry} for the given
- * class name, or 0 if it does not exist.
- *
- * @param name the class name in internal form
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link ClassEntry} for the given
+ * class name, or 0 if it does not exist.
+ *
+ * @param name the class name in internal form
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findClassEntry(String name, boolean add) {
int nameIndex = findUTF8Entry(name, add);
-
- if (nameIndex == 0) {
+ if (nameIndex == 0)
return 0;
- }
ClassKey key = new ClassKey(nameIndex);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new ClassEntry(nameIndex));
}
/**
- * Return the constant pool index of the {@link NameAndTypeEntry} for the
- * given name and descriptor, or 0 if it does not exist.
- *
- * @param name the name of the entity
- * @param desc the descriptor of the entity in internal form
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link NameAndTypeEntry} for the
+ * given name and descriptor, or 0 if it does not exist.
+ *
+ * @param name the name of the entity
+ * @param desc the descriptor of the entity in internal form
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findNameAndTypeEntry(String name, String desc, boolean add) {
int nameIndex = findUTF8Entry(name, add);
-
- if (nameIndex == 0) {
+ if (nameIndex == 0)
return 0;
- }
-
int descIndex = findUTF8Entry(desc, add);
-
- if (descIndex == 0) {
+ if (descIndex == 0)
return 0;
- }
NameAndTypeKey key = new NameAndTypeKey(nameIndex, descIndex);
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
-
return addEntry(key, new NameAndTypeEntry(nameIndex, descIndex));
}
/**
- * Return the constant pool index of the {@link FieldEntry} for the
- * given name, descriptor, and owner class name.
- *
- * @param owner the name of the field's owning class in internal form
- * @param name the name of the field
- * @param desc the descriptor of the field in internal form
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link FieldEntry} for the
+ * given name, descriptor, and owner class name.
+ *
+ * @param owner the name of the field's owning class in internal form
+ * @param name the name of the field
+ * @param desc the descriptor of the field in internal form
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findFieldEntry(String owner, String name, String desc,
boolean add) {
return findComplexEntry(owner, name, desc, Entry.FIELD, add);
}
/**
- * Return the constant pool index of the {@link MethodEntry} for the
- * given name, descriptor, and owner class name.
- *
- * @param owner the name of the method's owning class in internal form
- * @param name the name of the method
- * @param desc the descriptor of the method in internal form
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link MethodEntry} for the
+ * given name, descriptor, and owner class name.
+ *
+ * @param owner the name of the method's owning class in internal form
+ * @param name the name of the method
+ * @param desc the descriptor of the method in internal form
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findMethodEntry(String owner, String name, String desc,
boolean add) {
return findComplexEntry(owner, name, desc, Entry.METHOD, add);
}
/**
- * Return the constant pool index of the {@link InterfaceMethodEntry} for
- * the given name, descriptor, and owner class name.
- *
- * @param owner the name of the method's owning class in internal form
- * @param name the name of the method
- * @param desc the descriptor of the method in internal form
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link InterfaceMethodEntry} for
+ * the given name, descriptor, and owner class name.
+ *
+ * @param owner the name of the method's owning class in internal form
+ * @param name the name of the method
+ * @param desc the descriptor of the method in internal form
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
public int findInterfaceMethodEntry(String owner, String name, String desc,
boolean add) {
return findComplexEntry(owner, name, desc, Entry.INTERFACEMETHOD, add);
}
/**
- * Return the constant pool index of the {@link ComplexEntry} for the
- * given name, descriptor, and owner class name.
- *
- * @param owner the name of the owning class in internal form
- * @param name the name of the entity
- * @param desc the descriptor of the entity in internal form
- * @param type the type of entry: field, method, interface method
- * @param add if true, the entry will be added if it does not
- * already exist, and the new entry's index returned
- */
+ * Return the constant pool index of the {@link ComplexEntry} for the
+ * given name, descriptor, and owner class name.
+ *
+ * @param owner the name of the owning class in internal form
+ * @param name the name of the entity
+ * @param desc the descriptor of the entity in internal form
+ * @param type the type of entry: field, method, interface method
+ * @param add if true, the entry will be added if it does not
+ * already exist, and the new entry's index returned
+ */
private int findComplexEntry(String owner, String name, String desc,
int type, boolean add) {
int classIndex = findClassEntry(owner, add);
-
- if (classIndex == 0) {
+ if (classIndex == 0)
return 0;
- }
-
int descIndex = findNameAndTypeEntry(name, desc, add);
-
- if (descIndex == 0) {
+ if (descIndex == 0)
return 0;
- }
Object key = null;
-
switch (type) {
case Entry.FIELD:
key = new FieldKey(classIndex, descIndex);
-
break;
-
case Entry.METHOD:
key = new MethodKey(classIndex, descIndex);
-
break;
-
case Entry.INTERFACEMETHOD:
key = new InterfaceMethodKey(classIndex, descIndex);
-
break;
}
-
int index = find(key);
-
- if (!add || (index > 0)) {
+ if (!add || index > 0)
return index;
- }
Entry entry = null;
-
switch (type) {
case Entry.FIELD:
entry = new FieldEntry(classIndex, descIndex);
-
break;
-
case Entry.METHOD:
entry = new MethodEntry(classIndex, descIndex);
-
break;
-
case Entry.INTERFACEMETHOD:
entry = new InterfaceMethodEntry(classIndex, descIndex);
-
break;
}
-
return addEntry(key, entry);
}
@@ -489,13 +403,10 @@
visit.enterConstantPool(this);
Entry entry;
-
for (Iterator itr = _entries.iterator(); itr.hasNext();) {
entry = (Entry) itr.next();
-
- if (entry == null) {
+ if (entry == null)
continue;
- }
visit.enterEntry(entry);
entry.acceptVisit(visit);
@@ -506,43 +417,38 @@
}
/**
- * Fill the constant pool from the given bytecode stream.
+ * Fill the constant pool from the given bytecode stream.
*/
public void read(DataInput in) throws IOException {
clear();
int entryCount = in.readUnsignedShort();
Entry entry;
-
for (int i = 1; i < entryCount; i++) {
entry = Entry.read(in);
addEntry(entry);
- if (entry.isWide()) {
+ if (entry.isWide())
i++;
- }
}
}
/**
- * Write the constant pool to the given bytecode stream.
+ * Write the constant pool to the given bytecode stream.
*/
public void write(DataOutput out) throws IOException {
out.writeShort(_entries.size() + 1);
Entry entry;
-
for (Iterator itr = _entries.iterator(); itr.hasNext();) {
entry = (Entry) itr.next();
-
- if (entry != null) {
+ if (entry != null)
Entry.write(entry, out);
- }
}
}
/**
- * Called by constant pool entries when they are mutated.
+ * Called by constant pool entries when they are mutated.
*/
void modifyEntry(Object origKey, Entry entry) {
_lookup.remove(origKey);
@@ -550,69 +456,51 @@
}
/**
- * Returns the constant pool index of the entry with the given key.
+ * Returns the constant pool index of the entry with the given key.
*/
private int find(Object key) {
Entry entry = (Entry) _lookup.get(key);
-
- if (entry == null) {
+ if (entry == null)
return 0;
- }
-
return entry.getIndex();
}
/**
- * Return the hash key used for the specified entry.
+ * Return the hash key used for the specified entry.
*/
static Object getKey(Entry entry) {
switch (entry.getType()) {
case Entry.CLASS:
return new ClassKey(((ClassEntry) entry).getNameIndex());
-
case Entry.FIELD:
-
FieldEntry fe = (FieldEntry) entry;
-
return new FieldKey(fe.getClassIndex(), fe.getNameAndTypeIndex());
-
case Entry.METHOD:
-
MethodEntry me = (MethodEntry) entry;
-
return new MethodKey(me.getClassIndex(), me.getNameAndTypeIndex());
-
case Entry.INTERFACEMETHOD:
-
InterfaceMethodEntry ime = (InterfaceMethodEntry) entry;
-
return new InterfaceMethodKey(ime.getClassIndex(),
ime.getNameAndTypeIndex());
-
case Entry.STRING:
return new StringKey(((StringEntry) entry).getStringIndex());
-
case Entry.INT:
case Entry.FLOAT:
case Entry.LONG:
case Entry.DOUBLE:
case Entry.UTF8:
- return ((ConstantEntry) entry).getConstant();
-
+ return((ConstantEntry) entry).getConstant();
case Entry.NAMEANDTYPE:
-
NameAndTypeEntry nte = (NameAndTypeEntry) entry;
-
return new NameAndTypeKey(nte.getNameIndex(),
nte.getDescriptorIndex());
-
default:
return null;
}
}
/**
- * Base class key for entries with one ptr to another entry.
+ * Base class key for entries with one ptr to another entry.
*/
private static abstract class PtrKey {
private final int _index;
@@ -626,20 +514,16 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other.getClass() != getClass()) {
+ if (other.getClass() != getClass())
return false;
- }
-
- return ((PtrKey) other)._index == _index;
+ return((PtrKey) other)._index == _index;
}
}
/**
- * Key for string entries.
+ * Key for string entries.
*/
private static class StringKey extends PtrKey {
public StringKey(int index) {
@@ -648,7 +532,7 @@
}
/**
- * Key for class entries.
+ * Key for class entries.
*/
private static class ClassKey extends PtrKey {
public ClassKey(int index) {
@@ -657,7 +541,7 @@
}
/**
- * Base class key for entries with two ptr to other entries.
+ * Base class key for entries with two ptr to other entries.
*/
private static abstract class DoublePtrKey {
private final int _index1;
@@ -673,22 +557,18 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other.getClass() != getClass()) {
+ if (other.getClass() != getClass())
return false;
- }
DoublePtrKey key = (DoublePtrKey) other;
-
- return (key._index1 == _index1) && (key._index2 == _index2);
+ return key._index1 == _index1 && key._index2 == _index2;
}
}
/**
- * Key for name and type entries.
+ * Key for name and type entries.
*/
private static class NameAndTypeKey extends DoublePtrKey {
public NameAndTypeKey(int index1, int index2) {
@@ -697,7 +577,7 @@
}
/**
- * Key for field entries.
+ * Key for field entries.
*/
private static class FieldKey extends DoublePtrKey {
public FieldKey(int index1, int index2) {
@@ -706,7 +586,7 @@
}
/**
- * Key for method entries.
+ * Key for method entries.
*/
private static class MethodKey extends DoublePtrKey {
public MethodKey(int index1, int index2) {
@@ -715,7 +595,7 @@
}
/**
- * Key for interface method entries.
+ * Key for interface method entries.
*/
private static class InterfaceMethodKey extends DoublePtrKey {
public InterfaceMethodKey(int index1, int index2) {
@@ -723,3 +603,4 @@
}
}
}
+
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPoolTable.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPoolTable.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPoolTable.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/ConstantPoolTable.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,13 +14,12 @@
import java.io.*;
-
/**
- * <p>Efficient representation of the constant pool as a table. This class
- * can be used to parse out bits of information from bytecode without
- * instantiating a full {@link serp.bytecode.BCClass}.</p>
- *
- * @author Abe White
+ * Efficient representation of the constant pool as a table. This class
+ * can be used to parse out bits of information from bytecode without
+ * instantiating a full {@link serp.bytecode.BCClass}.
+ *
+ * @author Abe White
*/
public class ConstantPoolTable {
private byte[] _bytecode = null;
@@ -31,49 +27,28 @@
private int _idx = 0;
/**
- * Constructor; supply class bytecode.
- */
- public ConstantPoolTable(byte[] b) {
- _bytecode = b;
- _table = new int[readUnsignedShort(b, 8)];
- _idx = parse(b, _table);
- }
-
- /**
- * Constructor; supply input stream to bytecode.
- */
- public ConstantPoolTable(InputStream in) throws IOException {
- this(toByteArray(in));
- }
-
- /**
- * Allows static computation of the byte index after the constant
- * pool without caching constant pool information.
+ * Allows static computation of the byte index after the constant
+ * pool without caching constant pool information.
*/
public static int getEndIndex(byte[] b) {
return parse(b, null);
}
/**
- * Parse class bytecode, returning end index of pool.
+ * Parse class bytecode, returning end index of pool.
*/
private static int parse(byte[] b, int[] table) {
// each entry is the index in the byte array of the data for a const
// pool entry
int entries = (table == null) ? readUnsignedShort(b, 8) : table.length;
int idx = 10;
-
for (int i = 1; i < entries; i++) {
- if (table != null) {
+ if (table != null)
table[i] = idx + 1; // skip entry type
- }
-
switch (b[idx]) {
case 1: // utf8
- idx += (3 + readUnsignedShort(b, idx + 1));
-
+ idx += 3 + readUnsignedShort(b, idx + 1);
break;
-
case 3: // integer
case 4: // float
case 9: // field
@@ -81,61 +56,53 @@
case 11: // interface method
case 12: // name
idx += 5;
-
break;
-
case 5: // long
case 6: // double
idx += 9;
i++; // wide entry
-
break;
-
default:
idx += 3;
}
}
-
return idx;
}
/**
- * Read a byte value at the given offset into the given bytecode.
+ * Read a byte value at the given offset into the given bytecode.
*/
public static int readByte(byte[] b, int idx) {
return b[idx] & 0xFF;
}
/**
- * Read an unsigned short value at the given offset into the given
- * bytecode.
+ * Read an unsigned short value at the given offset into the given bytecode.
*/
public static int readUnsignedShort(byte[] b, int idx) {
- return (readByte(b, idx) << 8) | readByte(b, idx + 1);
+ return(readByte(b, idx) << 8) | readByte(b, idx + 1);
}
/**
- * Read an int value at the given offset into the given bytecode.
+ * Read an int value at the given offset into the given bytecode.
*/
public static int readInt(byte[] b, int idx) {
- return (readByte(b, idx) << 24) | (readByte(b, idx + 1) << 16) |
- (readByte(b, idx + 2) << 8) | readByte(b, idx + 3);
+ return(readByte(b, idx) << 24) | (readByte(b, idx + 1) << 16)
+ | (readByte(b, idx + 2) << 8) | readByte(b, idx + 3);
}
/**
- * Read a long value at the given offset into the given bytecode.
+ * Read a long value at the given offset into the given bytecode.
*/
public static long readLong(byte[] b, int idx) {
- return (readInt(b, idx) << 32) | readInt(b, idx + 4);
+ return(readInt(b, idx) << 32) | readInt(b, idx + 4);
}
/**
- * Read a UTF-8 string value at the given offset into the given
- * bytecode.
+ * Read a UTF-8 string value at the given offset into the given bytecode.
*/
public static String readString(byte[] b, int idx) {
int len = readUnsignedShort(b, idx);
-
try {
return new String(b, idx + 2, len, "UTF-8");
} catch (UnsupportedEncodingException uee) {
@@ -144,62 +111,75 @@
}
/**
- * Read the contents of the given stream.
+ * Constructor; supply class bytecode.
+ */
+ public ConstantPoolTable(byte[] b) {
+ _bytecode = b;
+ _table = new int[readUnsignedShort(b, 8)];
+ _idx = parse(b, _table);
+ }
+
+ /**
+ * Constructor; supply input stream to bytecode.
+ */
+ public ConstantPoolTable(InputStream in) throws IOException {
+ this(toByteArray(in));
+ }
+
+ /**
+ * Read the contents of the given stream.
*/
private static byte[] toByteArray(InputStream in) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
-
- for (int r; (r = in.read(buf)) != -1; bout.write(buf, 0, r))
- ;
-
+ for (int r; (r = in.read(buf)) != -1; bout.write(buf, 0, r));
return bout.toByteArray();
}
/**
- * Return the index into the bytecode of the end of the constant pool.
+ * Return the index into the bytecode of the end of the constant pool.
*/
public int getEndIndex() {
return _idx;
}
/**
- * Return the given table entry.
+ * Return the given table entry.
*/
public int get(int idx) {
return _table[idx];
}
/**
- * Read a byte value at the given offset.
+ * Read a byte value at the given offset.
*/
public int readByte(int idx) {
return readByte(_bytecode, idx);
}
/**
- * Read an unsigned short value at the given offset.
+ * Read an unsigned short value at the given offset.
*/
public int readUnsignedShort(int idx) {
return readUnsignedShort(_bytecode, idx);
}
/**
- * Read an int value at the given offset.
+ * Read an int value at the given offset.
*/
public int readInt(int idx) {
return readInt(_bytecode, idx);
}
/**
- * Read a long value at the given offset.
+ * Read a long value at the given offset.
*/
public long readLong(int idx) {
return readLong(_bytecode, idx);
}
/**
- * Read a UTF-8 string value at the given offset.
+ * Read a UTF-8 string value at the given offset.
*/
public String readString(int idx) {
return readString(_bytecode, idx);
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/DoubleEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/DoubleEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/DoubleEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/DoubleEntry.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,29 +12,27 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A constant double value in the constant pool.</p>
- *
- * @author Abe White
+ * A constant double value in the constant pool.
+ *
+ * @author Abe White
*/
public class DoubleEntry extends Entry implements ConstantEntry {
private double _value = 0.0;
/**
- * Default constructor.
+ * Default constructor.
*/
public DoubleEntry() {
}
/**
- * Constructor.
- *
- * @param value the constant double value of this entry
+ * Constructor.
+ *
+ * @param value the constant double value of this entry
*/
public DoubleEntry(double value) {
_value = value;
@@ -52,14 +47,14 @@
}
/**
- * Return the value of the constant.
+ * Return the value of the constant.
*/
public double getValue() {
return _value;
}
/**
- * Set the value of the constant.
+ * Set the value of the constant.
*/
public void setValue(double value) {
Object key = beforeModify();
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/Entry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/Entry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/Entry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/Entry.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,17 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>Base type for all constant pool entries. Entries should generally be
- * considered immutable; modifying an entry directly can have dire
- * consequences, and often renders the resulting class file invalid.</p>
- *
- * <p>Entries cannot be shared among constant pools.</p>
- *
- * @author Abe White
+ * Base type for all constant pool entries. Entries should generally be
+ * considered immutable; modifying an entry directly can have dire
+ * consequences, and often renders the resulting class file invalid.
+ * Entries cannot be shared among constant pools.
+ *
+ * @author Abe White
*/
public abstract class Entry implements VisitAcceptor {
public static final int UTF8 = 1;
@@ -43,144 +36,128 @@
public static final int METHOD = 10;
public static final int INTERFACEMETHOD = 11;
public static final int NAMEANDTYPE = 12;
+
private ConstantPool _pool = null;
private int _index = 0;
/**
- * Read a single entry from the given bytecode stream and returns it.
+ * Read a single entry from the given bytecode stream and returns it.
*/
public static Entry read(DataInput in) throws IOException {
Entry entry = create(in.readUnsignedByte());
entry.readData(in);
-
return entry;
}
/**
- * Write the given entry to the given bytecode stream.
+ * Write the given entry to the given bytecode stream.
*/
- public static void write(Entry entry, DataOutput out)
- throws IOException {
+ public static void write(Entry entry, DataOutput out) throws IOException {
out.writeByte(entry.getType());
entry.writeData(out);
}
/**
- * Create an entry based on its type code.
+ * Create an entry based on its type code.
*/
public static Entry create(int type) {
switch (type) {
case CLASS:
return new ClassEntry();
-
case FIELD:
return new FieldEntry();
-
case METHOD:
return new MethodEntry();
-
case INTERFACEMETHOD:
return new InterfaceMethodEntry();
-
case STRING:
return new StringEntry();
-
case INT:
return new IntEntry();
-
case FLOAT:
return new FloatEntry();
-
case LONG:
return new LongEntry();
-
case DOUBLE:
return new DoubleEntry();
-
case NAMEANDTYPE:
return new NameAndTypeEntry();
-
case UTF8:
return new UTF8Entry();
-
default:
throw new IllegalArgumentException("type = " + type);
}
}
/**
- * Return the type code for this entry type.
+ * Return the type code for this entry type.
*/
public abstract int getType();
/**
- * Return true if this is a wide entry -- i.e. if it takes up two
- * places in the constant pool. Returns false by default.
+ * Return true if this is a wide entry -- i.e. if it takes up two
+ * places in the constant pool. Returns false by default.
*/
public boolean isWide() {
return false;
}
/**
- * Returns the constant pool containing this entry, or null if none.
+ * Returns the constant pool containing this entry, or null if none.
*/
public ConstantPool getPool() {
return _pool;
}
/**
- * Returns the index of the entry in the owning constant pool, or 0.
+ * Returns the index of the entry in the owning constant pool, or 0.
*/
public int getIndex() {
return _index;
}
/**
- * This method is called after reading the entry type from bytecode.
- * It should read all the data for this entry from the given stream.
+ * This method is called after reading the entry type from bytecode.
+ * It should read all the data for this entry from the given stream.
*/
abstract void readData(DataInput in) throws IOException;
/**
- * This method is called after writing the entry type to bytecode.
- * It should write all data for this entry to the given stream.
+ * This method is called after writing the entry type to bytecode.
+ * It should write all data for this entry to the given stream.
*/
abstract void writeData(DataOutput out) throws IOException;
/**
- * Subclasses must call this method before their state is mutated.
+ * Subclasses must call this method before their state is mutated.
*/
Object beforeModify() {
- if (_pool == null) {
+ if (_pool == null)
return null;
- }
-
return _pool.getKey(this);
}
/**
- * Subclasses must call this method when their state is mutated.
+ * Subclasses must call this method when their state is mutated.
*/
void afterModify(Object key) {
- if (_pool != null) {
+ if (_pool != null)
_pool.modifyEntry(key, this);
- }
}
/**
- * Sets the owning pool of the entry.
+ * Sets the owning pool of the entry.
*/
void setPool(ConstantPool pool) {
// attempting to overwrite current pool?
- if ((_pool != null) && (pool != null) && (_pool != pool)) {
+ if (_pool != null && pool != null && _pool != pool)
throw new IllegalStateException("Entry already belongs to a pool");
- }
_pool = pool;
}
/**
- * Set the index of this entry within the pool.
+ * Set the index of this entry within the pool.
*/
void setIndex(int index) {
_index = index;
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FieldEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FieldEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FieldEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FieldEntry.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,27 +12,25 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A reference to a class field.</p>
- *
- * @author Abe White
+ * A reference to a class field.
+ *
+ * @author Abe White
*/
public class FieldEntry extends ComplexEntry {
/**
- * Default constructor.
+ * Default constructor.
*/
public FieldEntry() {
}
/**
- * Constructor.
- *
- * @see ComplexEntry#ComplexEntry(int,int)
+ * Constructor.
+ *
+ * @see ComplexEntry#ComplexEntry(int,int)
*/
public FieldEntry(int classIndex, int nameAndTypeIndex) {
super(classIndex, nameAndTypeIndex);
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FloatEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FloatEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FloatEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/FloatEntry.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,29 +12,27 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A constant float value in the constant pool.</p>
- *
- * @author Abe White
+ * A constant float value in the constant pool.
+ *
+ * @author Abe White
*/
public class FloatEntry extends Entry implements ConstantEntry {
private float _value = 0.0F;
/**
- * Default constructor.
+ * Default constructor.
*/
public FloatEntry() {
}
/**
- * Constructor.
- *
- * @param value the constant float value of this entry
+ * Constructor.
+ *
+ * @param value the constant float value of this entry
*/
public FloatEntry(float value) {
_value = value;
@@ -48,15 +43,15 @@
}
/**
- * Return the value of this constant.
- */
+ * Return the value of this constant.
+ */
public float getValue() {
return _value;
}
/**
- * Set the value of this constant.
- */
+ * Set the value of this constant.
+ */
public void setValue(float value) {
Object key = beforeModify();
_value = value;
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/IntEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/IntEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/IntEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/IntEntry.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,31 +12,28 @@
*/
package serp.bytecode.lowlevel;
+import java.io.*;
import serp.bytecode.visitor.*;
-
import serp.util.*;
-import java.io.*;
-
-
/**
- * <p>A constant int value in the constant pool.</p>
- *
- * @author Abe White
+ * A constant int value in the constant pool.
+ *
+ * @author Abe White
*/
public class IntEntry extends Entry implements ConstantEntry {
private int _value = -1;
/**
- * Default constructor.
+ * Default constructor.
*/
public IntEntry() {
}
/**
- * Constructor.
- *
- * @param value the constant int value of this entry
+ * Constructor.
+ *
+ * @param value the constant int value of this entry
*/
public IntEntry(int value) {
_value = value;
@@ -50,14 +44,14 @@
}
/**
- * Return the value of this constant.
+ * Return the value of this constant.
*/
public int getValue() {
return _value;
}
/**
- * Set the value of this constant.
+ * Set the value of this constant.
*/
public void setValue(int value) {
Object key = beforeModify();
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/InterfaceMethodEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/InterfaceMethodEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/InterfaceMethodEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/InterfaceMethodEntry.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,27 +12,25 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A reference to an interface method.</p>
- *
- * @author Abe White
+ * A reference to an interface method.
+ *
+ * @author Abe White
*/
public class InterfaceMethodEntry extends ComplexEntry {
/**
- * Default constructor.
+ * Default constructor.
*/
public InterfaceMethodEntry() {
}
/**
- * Constructor.
- *
- * @see ComplexEntry#ComplexEntry(int,int)
+ * Constructor.
+ *
+ * @see ComplexEntry#ComplexEntry(int,int)
*/
public InterfaceMethodEntry(int classIndex, int nameAndTypeIndex) {
super(classIndex, nameAndTypeIndex);
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/LongEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/LongEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/LongEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/LongEntry.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,31 +12,28 @@
*/
package serp.bytecode.lowlevel;
+import java.io.*;
import serp.bytecode.visitor.*;
-
import serp.util.*;
-import java.io.*;
-
-
/**
- * <p>A long constant in the constant pool.</p>
- *
- * @author Abe White
+ * A long constant in the constant pool.
+ *
+ * @author Abe White
*/
public class LongEntry extends Entry implements ConstantEntry {
private long _value = 0L;
/**
- * Default constructor.
+ * Default constructor.
*/
public LongEntry() {
}
/**
- * Constructor.
- *
- * @param value the constant long value of this entry
+ * Constructor.
+ *
+ * @param value the constant long value of this entry
*/
public LongEntry(long value) {
_value = value;
@@ -54,14 +48,14 @@
}
/**
- * Return the value of the constant.
+ * Return the value of the constant.
*/
public long getValue() {
return _value;
}
/**
- * Set the value of the constant.
+ * Set the value of the constant.
*/
public void setValue(long value) {
Object key = beforeModify();
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/MethodEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/MethodEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/MethodEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/MethodEntry.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,27 +12,25 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A reference to a class method.</p>
- *
- * @author Abe White
+ * A reference to a class method.
+ *
+ * @author Abe White
*/
public class MethodEntry extends ComplexEntry {
/**
- * Default constructor.
+ * Default constructor.
*/
public MethodEntry() {
}
/**
- * Constructor.
- *
- * @see ComplexEntry#ComplexEntry(int,int)
+ * Constructor.
+ *
+ * @see ComplexEntry#ComplexEntry(int,int)
*/
public MethodEntry(int classIndex, int nameAndTypeIndex) {
super(classIndex, nameAndTypeIndex);
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/NameAndTypeEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/NameAndTypeEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/NameAndTypeEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/NameAndTypeEntry.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,36 +12,32 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>Entry containing indexes referencing a name and a descriptor. Used
- * to describe fields and methods of other classes referenced by opcodes.</p>
- *
- * @author Abe White
+ * Entry containing indexes referencing a name and a descriptor. Used
+ * to describe fields and methods of other classes referenced by opcodes.
+ *
+ * @author Abe White
*/
public class NameAndTypeEntry extends Entry {
private int _nameIndex = 0;
private int _descriptorIndex = 0;
/**
- * Default constructor.
+ * Default constructor.
*/
public NameAndTypeEntry() {
}
/**
- * Constructor.
- *
- * @param nameIndex the constant pool index of the
- * {@link UTF8Entry} containing the name of
- * this entity
- * @param descriptorIndex the constant pool index of the
- * {@link UTF8Entry} containing the descriptor
- * for this entity
+ * Constructor.
+ *
+ * @param nameIndex the constant pool index of the
+ * {@link UTF8Entry} containing the name of this entity
+ * @param descriptorIndex the constant pool index of the
+ * {@link UTF8Entry} containing the descriptor for this entity
*/
public NameAndTypeEntry(int nameIndex, int descriptorIndex) {
_nameIndex = nameIndex;
@@ -56,16 +49,16 @@
}
/**
- * Return the constant pool index of the {@link UTF8Entry}
- * containing the name of this entity.
+ * Return the constant pool index of the {@link UTF8Entry}
+ * containing the name of this entity.
*/
public int getNameIndex() {
return _nameIndex;
}
/**
- * Set the constant pool index of the {@link UTF8Entry}
- * containing the name of this entity.
+ * Set the constant pool index of the {@link UTF8Entry}
+ * containing the name of this entity.
*/
public void setNameIndex(int nameIndex) {
Object key = beforeModify();
@@ -74,24 +67,24 @@
}
/**
- * Return the name's referenced {@link UTF8Entry}. This method can only
- * be run for entries that have been added to a constant pool.
+ * Return the name's referenced {@link UTF8Entry}. This method can only
+ * be run for entries that have been added to a constant pool.
*/
public UTF8Entry getNameEntry() {
- return (UTF8Entry) getPool().getEntry(_nameIndex);
+ return(UTF8Entry) getPool().getEntry(_nameIndex);
}
/**
- * Return the constant pool index of the {@link UTF8Entry}
- * containing the descriptor for this entity.
+ * Return the constant pool index of the {@link UTF8Entry}
+ * containing the descriptor for this entity.
*/
public int getDescriptorIndex() {
return _descriptorIndex;
}
/**
- * Set the constant pool index of a {@link UTF8Entry}
- * containing the descriptor for this entity.
+ * Set the constant pool index of a {@link UTF8Entry}
+ * containing the descriptor for this entity.
*/
public void setDescriptorIndex(int descriptorIndex) {
Object key = beforeModify();
@@ -100,11 +93,11 @@
}
/**
- * Return the descriptor's referenced {@link UTF8Entry}. This method
- * can only be run for entries that have been added to a constant pool.
+ * Return the descriptor's referenced {@link UTF8Entry}. This method
+ * can only be run for entries that have been added to a constant pool.
*/
public UTF8Entry getDescriptorEntry() {
- return (UTF8Entry) getPool().getEntry(_descriptorIndex);
+ return(UTF8Entry) getPool().getEntry(_descriptorIndex);
}
public void acceptVisit(BCVisitor visit) {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/StringEntry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/StringEntry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/StringEntry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/StringEntry.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,31 +12,29 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A String constant in the constant pool. String constants
- * hold a reference to a {@link UTF8Entry} that stores the actual value.</p>
- *
- * @author Abe White
+ * A String constant in the constant pool. String constants
+ * hold a reference to a {@link UTF8Entry} that stores the actual value.
+ *
+ * @author Abe White
*/
public class StringEntry extends Entry implements ConstantEntry {
private int _stringIndex = -1;
/**
- * Default constructor.
+ * Default constructor.
*/
public StringEntry() {
}
/**
- * Constructor.
- *
- * @param stringIndex the constant pool index of the {@link UTF8Entry}
- * containing the value of this string
+ * Constructor.
+ *
+ * @param stringIndex the constant pool index of the {@link UTF8Entry}
+ * containing the value of this string
*/
public StringEntry(int stringIndex) {
_stringIndex = stringIndex;
@@ -50,16 +45,16 @@
}
/**
- * Return the constant pool index of the {@link UTF8Entry}
- * storing the value of this string.
+ * Return the constant pool index of the {@link UTF8Entry}
+ * storing the value of this string.
*/
public int getStringIndex() {
return _stringIndex;
}
/**
- * Set the constant pool index of the {@link UTF8Entry}
- * storing the value of this string.
+ * Set the constant pool index of the {@link UTF8Entry}
+ * storing the value of this string.
*/
public void setStringIndex(int stringIndex) {
Object key = beforeModify();
@@ -68,11 +63,11 @@
}
/**
- * Return the referenced {@link UTF8Entry}. This method can only
- * be run for entries that have been added to a constant pool.
+ * Return the referenced {@link UTF8Entry}. This method can only
+ * be run for entries that have been added to a constant pool.
*/
public UTF8Entry getStringEntry() {
- return (UTF8Entry) getPool().getEntry(_stringIndex);
+ return(UTF8Entry) getPool().getEntry(_stringIndex);
}
public Object getConstant() {
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/UTF8Entry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/UTF8Entry.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/UTF8Entry.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/lowlevel/UTF8Entry.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,29 +12,27 @@
*/
package serp.bytecode.lowlevel;
-import serp.bytecode.visitor.*;
-
import java.io.*;
-
+import serp.bytecode.visitor.*;
/**
- * <p>A unicode string value in the constant pool.</p>
- *
- * @author Abe White
+ * A unicode string value in the constant pool.
+ *
+ * @author Abe White
*/
public class UTF8Entry extends Entry implements ConstantEntry {
private String _value = "";
/**
- * Default constructor.
+ * Default constructor.
*/
public UTF8Entry() {
}
/**
- * Constructor.
- *
- * @param value the constant string value of this entry
+ * Constructor.
+ *
+ * @param value the constant string value of this entry
*/
public UTF8Entry(String value) {
_value = value;
@@ -48,19 +43,18 @@
}
/**
- * Return the value of the entry.
+ * Return the value of the entry.
*/
public String getValue() {
return _value;
}
/**
- * Set the value of the entry.
+ * Set the value of the entry.
*/
public void setValue(String value) {
- if (value == null) {
+ if (value == null)
throw new NullPointerException("value = null");
- }
Object key = beforeModify();
_value = value;
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/BCVisitor.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/BCVisitor.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/BCVisitor.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/BCVisitor.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,29 @@
import serp.bytecode.*;
import serp.bytecode.Deprecated;
-
import serp.bytecode.lowlevel.*;
-
/**
- * <p>Base class for visitors on a bytecode entity. The public {@link #visit}
- * method will traverse the object graph of the given entity, calling the
- * <code>enter*</code> and <code>exit*</code> methods as it visits each
- * object. The traversal is done depth-first. Subclasses should override
- * only the methods for visiting the entities they are interested in.
- * Whenever there is a general method (i.e. <code>enter/exitEntry</code>) as
- * well as a more specific one (i.e. <code>enter/exitStringEntry</code>), the
- * more general method will be called first, followed by a call on the correct
- * specific method. Most subclasses will override either the general or
- * specific cases, but not both.</p>
- *
- * @author Abe White
+ * Base class for visitors on a bytecode entity. The public {@link #visit}
+ * method will traverse the object graph of the given entity, calling the
+ * <code>enter*</code> and <code>exit*</code> methods as it visits each
+ * object. The traversal is done depth-first. Subclasses should override
+ * only the methods for visiting the entities they are interested in.
+ * Whenever there is a general method(i.e. <code>enter/exitEntry</code>) as
+ * well as a more specific one(i.e. <code>enter/exitStringEntry</code>), the
+ * more general method will be called first, followed by a call on the correct
+ * specific method. Most subclasses will override either the general or
+ * specific cases, but not both.
+ *
+ * @author Abe White
*/
public class BCVisitor {
/**
- * Visit the given entity.
+ * Visit the given entity.
*/
public void visit(VisitAcceptor obj) {
- if (obj == null) {
+ if (obj == null)
return;
- }
obj.acceptVisit(this);
}
Modified: incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/PrettyPrintVisitor.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/PrettyPrintVisitor.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/PrettyPrintVisitor.java (original)
+++ incubator/openjpa/trunk/serp/src/main/java/serp/bytecode/visitor/PrettyPrintVisitor.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.visitor;
+import java.io.*;
import serp.bytecode.*;
-
import serp.bytecode.lowlevel.*;
-import java.io.*;
-
-
/**
- * <p>Visitor type that outputs a detailed, formatted document of the
- * visited entity; similar to the <i>javap -c</i> command but more
- * detailed.</p>
- *
- * @author Abe White
+ * Visitor type that outputs a detailed, formatted document of the
+ * visited entity; similar to the <i>javap -c</i> command but more detailed.
+ *
+ * @author Abe White
*/
public class PrettyPrintVisitor extends BCVisitor {
private PrintWriter _out = null;
@@ -35,51 +28,48 @@
private int _entryCount = 0;
/**
- * Constructor; all pritning will go to stdout.
- */
- public PrettyPrintVisitor() {
- _out = new PrintWriter(System.out);
- }
-
- /**
- * Constructor.
- *
- * @param out the stream to print to
- */
- public PrettyPrintVisitor(PrintWriter out) {
- _out = out;
- }
-
- /**
- * Invoke with the class or file names to pretty print; the
- * functionality is similar to the <i>javap -c</i> command, but more
- * detailed.
+ * Invoke with the class or file names to pretty print; the
+ * functionality is similar to the <i>javap -c</i> command, but more
+ * detailed.
*/
public static void main(String[] args)
throws ClassNotFoundException, IOException {
if (args.length == 0) {
- System.err.println("Usage: java " +
- PrettyPrintVisitor.class.getName() +
- " <class name | .class file>+");
+ System.err.println("Usage: java "
+ + PrettyPrintVisitor.class.getName()
+ + " <class name | .class file>+");
System.exit(1);
}
PrettyPrintVisitor ppv = new PrettyPrintVisitor();
Project project = new Project();
BCClass type;
-
for (int i = 0; i < args.length; i++) {
- if (args[i].endsWith(".class")) {
+ if (args[i].endsWith(".class"))
type = project.loadClass(new File(args[i]));
- } else {
+ else
type = project.loadClass(Class.forName(args[i], false,
- PrettyPrintVisitor.class.getClassLoader()));
- }
-
+ PrettyPrintVisitor.class.getClassLoader()));
ppv.visit(type);
}
}
+ /**
+ * Constructor; all pritning will go to stdout.
+ */
+ public PrettyPrintVisitor() {
+ _out = new PrintWriter(System.out);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param out the stream to print to
+ */
+ public PrettyPrintVisitor(PrintWriter out) {
+ _out = out;
+ }
+
public void visit(VisitAcceptor entity) {
super.visit(entity);
_out.flush();
@@ -103,12 +93,11 @@
println("major=" + obj.getMajorVersion());
println("access=" + obj.getAccessFlags());
println("name=" + obj.getIndex() + " <" + obj.getName() + ">");
- println("super=" + obj.getSuperclassIndex() + " <" +
- obj.getSuperclassName() + ">");
+ println("super=" + obj.getSuperclassIndex()
+ + " <" + obj.getSuperclassName() + ">");
int[] indexes = obj.getDeclaredInterfaceIndexes();
String[] names = obj.getDeclaredInterfaceNames();
-
for (int i = 0; i < indexes.length; i++)
println("interface=" + indexes[i] + " <" + names[i] + ">");
}
@@ -121,8 +110,8 @@
openBlock("Field");
println("access=" + obj.getAccessFlags());
println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">");
- println("type=" + obj.getDescriptorIndex() + " <" + obj.getTypeName() +
- ">");
+ println("type=" + obj.getDescriptorIndex()
+ + " <" + obj.getTypeName() + ">");
}
public void exitBCField(BCField obj) {
@@ -135,9 +124,7 @@
println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">");
println("descriptor=" + obj.getDescriptorIndex());
println("return=" + obj.getReturnName());
-
String[] params = obj.getParamNames();
-
for (int i = 0; i < params.length; i++)
println("param=" + params[i]);
}
@@ -155,21 +142,20 @@
}
public void enterConstantValue(ConstantValue obj) {
- println("value=" + obj.getValueIndex() + " <" + obj.getTypeName() +
- "=" + obj.getValue() + ">");
+ println("value=" + obj.getValueIndex() + " <" + obj.getTypeName()
+ + "=" + obj.getValue() + ">");
}
public void enterExceptions(Exceptions obj) {
int[] indexes = obj.getExceptionIndexes();
String[] names = obj.getExceptionNames();
-
for (int i = 0; i < indexes.length; i++)
println("exception=" + indexes[i] + " <" + names[i] + ">");
}
public void enterSourceFile(SourceFile obj) {
- println("source=" + obj.getFileIndex() + " <" + obj.getFileName() +
- ">");
+ println("source=" + obj.getFileIndex() + " <"
+ + obj.getFileName() + ">");
}
public void enterCode(Code obj) {
@@ -183,8 +169,8 @@
println("startPc=" + obj.getTryStartPc());
println("endPc=" + obj.getTryEndPc());
println("handlerPc=" + obj.getHandlerStartPc());
- println("catch=" + obj.getCatchIndex() + " <" + obj.getCatchName() +
- ">");
+ println("catch=" + obj.getCatchIndex() + " <"
+ + obj.getCatchName() + ">");
}
public void exitExceptionHandler(ExceptionHandler obj) {
@@ -196,8 +182,8 @@
println("access=" + obj.getAccessFlags());
println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">");
println("type=" + obj.getTypeIndex() + "<" + obj.getTypeName() + ">");
- println("declarer=" + obj.getDeclarerIndex() + "<" +
- obj.getDeclarerName() + ">");
+ println("declarer=" + obj.getDeclarerIndex() + "<"
+ + obj.getDeclarerName() + ">");
}
public void exitInnerClass(InnerClass obj) {
@@ -233,8 +219,8 @@
println("length=" + obj.getLength());
println("local=" + obj.getLocal());
println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">");
- println("signature=" + obj.getTypeIndex() + " <" + obj.getTypeName() +
- ">");
+ println("signature=" + obj.getTypeIndex() + " <"
+ + obj.getTypeName() + ">");
}
public void exitLocalVariableType(LocalVariableType obj) {
@@ -258,17 +244,15 @@
}
public void enterGetFieldInstruction(GetFieldInstruction obj) {
- _out.print(obj.getFieldIndex() + " <" + obj.getFieldTypeName() + " " +
- obj.getFieldDeclarerName() + "." + obj.getFieldName() + ">");
+ _out.print(obj.getFieldIndex() + " <" + obj.getFieldTypeName()
+ + " " + obj.getFieldDeclarerName()
+ + "." + obj.getFieldName() + ">");
}
public void enterIIncInstruction(IIncInstruction obj) {
_out.print(obj.getLocal() + " ");
-
- if (obj.getIncrement() < 0) {
+ if (obj.getIncrement() < 0)
_out.print("-");
- }
-
_out.print(obj.getIncrement());
}
@@ -290,49 +274,38 @@
int[] offsets = obj.getOffsets();
int[] matches = obj.getMatches();
-
for (int i = 0; i < offsets.length; i++)
println("case " + matches[i] + "=" + offsets[i]);
-
_out.print(_prefix + "default=" + obj.getDefaultOffset());
_prefix = _prefix.substring(2);
}
public void enterMethodInstruction(MethodInstruction obj) {
- _out.print(obj.getMethodIndex() + " <" + obj.getMethodReturnName() +
- " " + obj.getMethodDeclarerName() + "." + obj.getMethodName() +
- "(");
-
+ _out.print(obj.getMethodIndex() + " <" + obj.getMethodReturnName()
+ + " " + obj.getMethodDeclarerName()
+ + "." + obj.getMethodName() + "(");
String[] params = obj.getMethodParamNames();
int dotIndex;
-
for (int i = 0; i < params.length; i++) {
dotIndex = params[i].lastIndexOf('.');
-
- if (dotIndex != -1) {
+ if (dotIndex != -1)
params[i] = params[i].substring(dotIndex + 1);
- }
_out.print(params[i]);
-
- if (i != (params.length - 1)) {
+ if (i != params.length - 1)
_out.print(", ");
- }
}
_out.print(")>");
}
public void enterMultiANewArrayInstruction(MultiANewArrayInstruction obj) {
- _out.print(obj.getTypeIndex() + " " + obj.getDimensions() + " <" +
- obj.getTypeName());
-
+ _out.print(obj.getTypeIndex() + " " + obj.getDimensions()
+ + " <" + obj.getTypeName());
String post = "";
-
for (int i = 0; i < obj.getDimensions(); i++)
post += "[]";
-
_out.print(post + ">");
}
@@ -341,8 +314,9 @@
}
public void enterPutFieldInstruction(PutFieldInstruction obj) {
- _out.print(obj.getFieldIndex() + " <" + obj.getFieldTypeName() + " " +
- obj.getFieldDeclarerName() + "." + obj.getFieldName() + ">");
+ _out.print(obj.getFieldIndex() + " <" + obj.getFieldTypeName()
+ + " " + obj.getFieldDeclarerName()
+ + "." + obj.getFieldName() + ">");
}
public void enterRetInstruction(RetInstruction obj) {
@@ -359,12 +333,9 @@
println("low=" + obj.getLow());
println("high=" + obj.getHigh());
-
int[] offsets = obj.getOffsets();
-
for (int i = 0; i < offsets.length; i++)
println("case=" + offsets[i]);
-
_out.print(_prefix + "default=" + obj.getDefaultOffset());
_prefix = _prefix.substring(2);
@@ -386,8 +357,8 @@
public void enterEntry(Entry obj) {
String name = obj.getClass().getName();
- openBlock(++_entryCount + ": " +
- name.substring(name.lastIndexOf('.') + 1));
+ openBlock(++_entryCount + ": "
+ + name.substring(name.lastIndexOf('.') + 1));
}
public void exitEntry(Entry obj) {