aboutsummaryrefslogtreecommitdiffstats
path: root/bcel-builder/src
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2017-09-20 21:34:21 -0700
committerAndy Clement <aclement@pivotal.io>2017-09-20 21:34:21 -0700
commit03752862ba3bc6ef132195673903dcf9109e8b93 (patch)
tree949971954474b167cbcef83fa3161de4c4a4a7c8 /bcel-builder/src
parentee99996fb7f727d34a5393374b5661dba1ec9f9f (diff)
parent784906d2ee0cb1b432a9aff6973c12cfd865db6e (diff)
downloadaspectj-03752862ba3bc6ef132195673903dcf9109e8b93.tar.gz
aspectj-03752862ba3bc6ef132195673903dcf9109e8b93.zip
Merged post 1.8.5 changes into Java9 branch
Diffstat (limited to 'bcel-builder/src')
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/Constants.java4
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/BootstrapMethods.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/MethodParameters.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java11
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java22
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeTypeAnnos.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java4
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java2
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java16
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java2
14 files changed, 46 insertions, 29 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java
index 41d75a7cf..5f37d106a 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java
@@ -107,7 +107,9 @@ public interface Constants {
public final static short ACC_INTERFACE = 0x0200;
public final static short ACC_ABSTRACT = 0x0400;
public final static short ACC_STRICT = 0x0800;
-
+
+ public final static short ACC_SYNTHETIC = 0x1000;
+
public final static short ACC_ANNOTATION = 0x2000;
public final static short ACC_ENUM = 0x4000;
public final static int ACC_MODULE = 0x8000;
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/BootstrapMethods.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/BootstrapMethods.java
index a5216f2ef..f708c0cab 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/BootstrapMethods.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/BootstrapMethods.java
@@ -95,7 +95,7 @@ public final class BootstrapMethods extends Attribute {
BootstrapMethods(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
this(name_index, length, (BootstrapMethod[])null, constant_pool);
data = new byte[length];
- file.read(data);
+ file.readFully(data);
isInPackedState = true;
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
index 10d72fd3e..871bfe6bf 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
@@ -104,7 +104,7 @@ public final class LineNumberTable extends Attribute {
LineNumberTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
this(name_index, length, (LineNumber[]) null, constant_pool);
data = new byte[length];
- file.read(data);
+ file.readFully(data);
isInPackedState = true;
// assert(bytesRead==length)
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
index 717bb5965..e6415dae6 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
@@ -109,7 +109,7 @@ public class LocalVariableTable extends Attribute {
LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
data = new byte[length];
- file.read(data);
+ file.readFully(data);
isInPackedState = true;
// assert(bytesRead==length)
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/MethodParameters.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/MethodParameters.java
index 76f1642d5..547041584 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/MethodParameters.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/MethodParameters.java
@@ -38,7 +38,7 @@ public class MethodParameters extends Attribute {
public MethodParameters(int index, int length, DataInputStream dis, ConstantPool cpool) throws IOException {
super(Constants.ATTR_METHOD_PARAMETERS,index,length,cpool);
data = new byte[length];
- dis.read(data,0,length);
+ dis.readFully(data,0,length);
isInPackedState = true;
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
index 80f943bbf..29f9c1535 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
@@ -63,7 +63,7 @@ import org.aspectj.apache.bcel.Constants;
/**
* This class represents a stack map attribute used for preverification of Java classes for the <a href="http://java.sun.com/j2me/">
* Java 2 Micro Edition</a> (J2ME). This attribute is used by the <a href="http://java.sun.com/products/cldc/">KVM</a> and contained
- * within the Code attribute of a method. See CLDC specification §5.3.1.2
+ * within the Code attribute of a method. See CLDC specification 5.3.1.2
*
* @version $Id: StackMap.java,v 1.6 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java
index b369083fb..76bb2ab79 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java
@@ -61,7 +61,7 @@ import java.io.IOException;
/**
* This class represents a stack map entry recording the types of
* local variables and the the of stack items at a given byte code offset.
- * See CLDC specification §5.3.1.2
+ * See CLDC specification 5.3.1.2
*
* @version $Id: StackMapEntry.java,v 1.5 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java
index 05c83a6ee..ac145087b 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java
@@ -56,7 +56,7 @@ public abstract class RuntimeAnnos extends Attribute {
protected void readAnnotations(DataInputStream dis, ConstantPool cpool) throws IOException {
annotation_data = new byte[length];
- dis.read(annotation_data, 0, length);
+ dis.readFully(annotation_data, 0, length);
}
protected void writeAnnotations(DataOutputStream dos) throws IOException {
@@ -71,12 +71,17 @@ public abstract class RuntimeAnnos extends Attribute {
}
}
+
private void inflate() {
try {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data));
int numberOfAnnotations = dis.readUnsignedShort();
- for (int i = 0; i < numberOfAnnotations; i++) {
- annotations.add(AnnotationGen.read(dis, getConstantPool(), visible));
+ if (numberOfAnnotations > 0) {
+ List<AnnotationGen> inflatedAnnotations = new ArrayList<AnnotationGen>();
+ for (int i = 0; i < numberOfAnnotations; i++) {
+ inflatedAnnotations.add(AnnotationGen.read(dis, getConstantPool(), visible));
+ }
+ annotations = inflatedAnnotations;
}
dis.close();
inflated = true;
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java
index ad92c9fce..517ebee62 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java
@@ -80,20 +80,28 @@ public abstract class RuntimeParamAnnos extends Attribute {
protected void readParameterAnnotations(DataInputStream dis,ConstantPool cpool) throws IOException {
annotation_data = new byte[length];
- dis.read(annotation_data,0,length);
+ dis.readFully(annotation_data,0,length);
}
private void inflate() {
try {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data));
int numParameters = dis.readUnsignedByte();
- for (int i=0; i<numParameters; i++) {
- int numAnnotations = dis.readUnsignedShort();
- AnnotationGen[] annotations = new AnnotationGen[numAnnotations];
- for (int j=0; j<numAnnotations; j++) {
- annotations[j] = AnnotationGen.read(dis,getConstantPool(),visible);
+ if (numParameters > 0) {
+ List<AnnotationGen[]> inflatedParameterAnnotations = new ArrayList<AnnotationGen[]>();
+ for (int i=0; i<numParameters; i++) {
+ int numAnnotations = dis.readUnsignedShort();
+ if (numAnnotations == 0 ) {
+ inflatedParameterAnnotations.add(AnnotationGen.NO_ANNOTATIONS);
+ } else {
+ AnnotationGen[] annotations = new AnnotationGen[numAnnotations];
+ for (int j=0; j<numAnnotations; j++) {
+ annotations[j] = AnnotationGen.read(dis,getConstantPool(),visible);
+ }
+ inflatedParameterAnnotations.add(annotations);
+ }
}
- parameterAnnotations.add(annotations);
+ parameterAnnotations = inflatedParameterAnnotations;
}
inflated = true;
} catch (IOException ioe) {
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeTypeAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeTypeAnnos.java
index c783eae3b..fb5c32ce1 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeTypeAnnos.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeTypeAnnos.java
@@ -34,7 +34,7 @@ public abstract class RuntimeTypeAnnos extends Attribute {
protected void readTypeAnnotations(DataInputStream dis,ConstantPool cpool) throws IOException {
annotation_data = new byte[length];
- dis.read(annotation_data,0,length);
+ dis.readFully(annotation_data,0,length);
}
public final void dump(DataOutputStream dos) throws IOException {
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
index 606beab3e..6a12a8c80 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
@@ -66,6 +66,7 @@ import org.aspectj.apache.bcel.classfile.ConstantInteger;
import org.aspectj.apache.bcel.classfile.ConstantLong;
import org.aspectj.apache.bcel.classfile.ConstantObject;
import org.aspectj.apache.bcel.classfile.ConstantPool;
+import org.aspectj.apache.bcel.classfile.ConstantString;
import org.aspectj.apache.bcel.classfile.ConstantValue;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.Utility;
@@ -126,7 +127,6 @@ public class FieldGen extends FieldGenOrMethodGen {
}
}
- // TODO setting the constant value is a mess...
public void setValue(int index) {
ConstantPool cp = this.cp;
Constant c = cp.getConstant(index);
@@ -138,6 +138,8 @@ public class FieldGen extends FieldGenOrMethodGen {
value = ((ConstantDouble) c).getValue();
} else if (c instanceof ConstantLong) {
value = ((ConstantLong) c).getValue();
+ } else if (c instanceof ConstantString) {
+ value = ((ConstantString)c).getString(cp);
} else {
value = ((ConstantObject) c).getConstantValue(cp);
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java
index 95e467529..544363f16 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java
@@ -146,7 +146,7 @@ public class ObjectType extends ReferenceType {
}
/**
- * Java Virtual Machine Specification edition 2, § 5.4.4 Access Control
+ * Java Virtual Machine Specification edition 2, 5.4.4 Access Control
*/
public boolean accessibleTo(ObjectType accessor) {
JavaClass jc = Repository.lookupClass(classname);
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java
index ae3be0c00..1e290f5a4 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java
@@ -137,7 +137,7 @@ public abstract class ReferenceType extends Type {
*/
if (this instanceof ObjectType && ((ObjectType) this).referencesInterface()) {
/*
- * If T is a class type, then T must be Object (§2.4.7).
+ * If T is a class type, then T must be Object (2.4.7).
*/
if (T instanceof ObjectType && ((ObjectType) T).referencesClass()) {
if (T.equals(Type.OBJECT)) {
@@ -146,7 +146,7 @@ public abstract class ReferenceType extends Type {
}
/*
- * If T is an interface type, then T must be the same interface as this or a superinterface of this (§2.13.2).
+ * If T is an interface type, then T must be the same interface as this or a superinterface of this (2.13.2).
*/
if (T instanceof ObjectType && ((ObjectType) T).referencesInterface()) {
if (this.equals(T)) {
@@ -163,7 +163,7 @@ public abstract class ReferenceType extends Type {
*/
if (this instanceof ArrayType) {
/*
- * If T is a class type, then T must be Object (§2.4.7).
+ * If T is a class type, then T must be Object (2.4.7).
*/
if (T instanceof ObjectType && ((ObjectType) T).referencesClass()) {
if (T.equals(Type.OBJECT)) {
@@ -176,7 +176,7 @@ public abstract class ReferenceType extends Type {
*/
if (T instanceof ArrayType) {
/*
- * TC and SC are the same primitive type (§2.4.1).
+ * TC and SC are the same primitive type (2.4.1).
*/
Type sc = ((ArrayType) this).getElementType();
Type tc = ((ArrayType) this).getElementType();
@@ -186,7 +186,7 @@ public abstract class ReferenceType extends Type {
}
/*
- * TC and SC are reference types (§2.4.6), and type SC is assignable to TC by these runtime rules.
+ * TC and SC are reference types (2.4.6), and type SC is assignable to TC by these runtime rules.
*/
if (tc instanceof ReferenceType && sc instanceof ReferenceType
&& ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) {
@@ -194,7 +194,7 @@ public abstract class ReferenceType extends Type {
}
}
- /* If T is an interface type, T must be one of the interfaces implemented by arrays (§2.15). */
+ /* If T is an interface type, T must be one of the interfaces implemented by arrays (2.15). */
// TODO: Check if this is still valid or find a way to dynamically find out which
// interfaces arrays implement. However, as of the JVM specification edition 2, there
// are at least two different pages where assignment compatibility is defined and
@@ -218,7 +218,7 @@ public abstract class ReferenceType extends Type {
* t is an ArrayType, then Type.OBJECT is returned; unless their dimensions match. Then an ArrayType of the same number of
* dimensions is returned, with its basic type being the first common super class of the basic types of "this" and t. If "this"
* or t is a ReferenceType referencing an interface, then Type.OBJECT is returned. If not all of the two classes' superclasses
- * cannot be found, "null" is returned. See the JVM specification edition 2, "§4.9.2 The Bytecode Verifier".
+ * cannot be found, "null" is returned. See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
*/
public ReferenceType getFirstCommonSuperclass(ReferenceType t) {
if (this.equals(Type.NULL)) {
@@ -300,7 +300,7 @@ public abstract class ReferenceType extends Type {
// * t is an ArrayType, then Type.OBJECT is returned. If "this" or t is a ReferenceType referencing an interface, then
// Type.OBJECT
// * is returned. If not all of the two classes' superclasses cannot be found, "null" is returned. See the JVM specification
- // * edition 2, "§4.9.2 The Bytecode Verifier".
+ // * edition 2, "4.9.2 The Bytecode Verifier".
// *
// * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has slightly changed semantics.
// */
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java
index 45ffae9b7..a38ffedfd 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java
@@ -59,7 +59,7 @@ import org.aspectj.apache.bcel.generic.InstructionHandle;
/**
* Returnaddress, the type JSR or JSR_W instructions push upon the stack.
*
- * see vmspec2 §3.3.3
+ * see vmspec2 3.3.3
* @version $Id: ReturnaddressType.java,v 1.3 2008/05/28 23:52:56 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">Enver Haase</A>
*/