diff options
author | Andy Clement <andrew.clement@gmail.com> | 2013-05-24 16:45:27 -0700 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2013-05-24 16:45:27 -0700 |
commit | 0a01bd478349676a87a6afaa71a77a04de3f27a4 (patch) | |
tree | 9aa066dbc6e07761169fe8ed9e193e468ea56c8f /bcel-builder/src | |
parent | f32426df49c42772c5ab57904209e04a26cb0361 (diff) | |
download | aspectj-0a01bd478349676a87a6afaa71a77a04de3f27a4.tar.gz aspectj-0a01bd478349676a87a6afaa71a77a04de3f27a4.zip |
Java8 support: methodparameters, typeannotations
Can read/write MethodParameters attribute.
Can read/write type annotation attributes.
Diffstat (limited to 'bcel-builder/src')
12 files changed, 112 insertions, 19 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java index 2604d8e54..4499284c2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java @@ -59,8 +59,8 @@ import org.aspectj.apache.bcel.generic.Type; /** * Constants for the project, mostly defined in the JVM specification. * - * @version $Id: Constants.java,v 1.7 2011/09/28 01:14:54 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + * @author Andy Clement */ public interface Constants { // Major and minor version of the code @@ -76,6 +76,10 @@ public interface Constants { public final static short MINOR_1_5 = 0; public final static short MAJOR_1_6 = 50; public final static short MINOR_1_6 = 0; + public final static short MAJOR_1_7 = 51; + public final static short MINOR_1_7 = 0; + public final static short MAJOR_1_8 = 52; + public final static short MINOR_1_8 = 0; // Defaults public final static short MAJOR = MAJOR_1_1; public final static short MINOR = MINOR_1_1; @@ -609,13 +613,20 @@ public interface Constants { public static final byte ATTR_ENCLOSING_METHOD = 17; public static final byte ATTR_ANNOTATION_DEFAULT = 18; public static final byte ATTR_BOOTSTRAPMETHODS = 19; - - public static final short KNOWN_ATTRIBUTES = 20; - - public static final String[] ATTRIBUTE_NAMES = { "SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", - "LocalVariableTable", "InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap", - "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", "RuntimeVisibleParameterAnnotations", - "RuntimeInvisibleParameterAnnotations", "LocalVariableTypeTable", "EnclosingMethod", "AnnotationDefault","BootstrapMethods" }; + public static final byte ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS = 20; + public static final byte ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = 21; + public static final byte ATTR_METHOD_PARAMETERS = 22; + + public static final short KNOWN_ATTRIBUTES = 23; + + public static final String[] ATTRIBUTE_NAMES = { + "SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", "LocalVariableTable", + "InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap", + "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", "RuntimeVisibleParameterAnnotations", + "RuntimeInvisibleParameterAnnotations", "LocalVariableTypeTable", "EnclosingMethod", + "AnnotationDefault","BootstrapMethods", "RuntimeVisibleTypeAnnotations", "RuntimeInvisibleTypeAnnotations", + "MethodParameters" + }; /** * Constants used in the StackMap attribute. diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java index 939fa36be..817628295 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java @@ -64,6 +64,7 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos; +import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisTypeAnnos; /** * Abstract super class for <em>Attribute</em> objects. Currently the <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>, @@ -159,6 +160,10 @@ public abstract class Attribute implements Cloneable, Node, Serializable { return new EnclosingMethod(idx, len, file, cpool); case Constants.ATTR_BOOTSTRAPMETHODS: return new BootstrapMethods(idx,len,file,cpool); + case Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS: + return new RuntimeVisTypeAnnos(idx, len, file, cpool); + case Constants.ATTR_METHOD_PARAMETERS: + return new MethodParameters(idx, len, file, cpool); default: throw new IllegalStateException(); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java index c411cb5d6..9280083a8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java @@ -2,8 +2,10 @@ package org.aspectj.apache.bcel.classfile; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos; +import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisTypeAnnos; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos; +import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisTypeAnnos; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -151,7 +153,13 @@ public interface ClassVisitor { public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos obj); + public void visitRuntimeVisibleTypeAnnotations(RuntimeVisTypeAnnos obj); + + public void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisTypeAnnos obj); + public void visitAnnotationDefault(AnnotationDefault obj); public void visitLocalVariableTypeTable(LocalVariableTypeTable obj); + + public void visitMethodParameters(MethodParameters methodParameters); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java index d354b7fe1..46aeac845 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java @@ -1,5 +1,3 @@ -package org.aspectj.apache.bcel.classfile; - /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -53,6 +51,8 @@ package org.aspectj.apache.bcel.classfile; * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ +package org.aspectj.apache.bcel.classfile; + import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java index af442522d..9a0a42909 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2004 IBM Corporation + * Copyright (c) 2004, 2013 IBM Corporation * * All rights reserved. * This program and the accompanying materials are made available @@ -127,13 +127,16 @@ public class AnnotationGen { public String toShortString() { StringBuffer s = new StringBuffer(); - s.append("@" + getTypeName() + "("); - for (int i = 0; i < pairs.size(); i++) { - s.append(pairs.get(i)); - if (i + 1 < pairs.size()) - s.append(","); + s.append("@").append(getTypeName()); + if (pairs.size()!=0) { + s.append("("); + for (int i = 0; i < pairs.size(); i++) { + s.append(pairs.get(i)); + if (i + 1 < pairs.size()) + s.append(","); + } + s.append(")"); } - s.append(")"); return s.toString(); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java index 511afe2b1..06f7c7273 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2004 IBM + * Copyright (c) 2004, 2013 IBM, VMware * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 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 a6b6534df..05c83a6ee 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 @@ -1,3 +1,14 @@ +/* ******************************************************************* + * Copyright (c) 2004, 2013 IBM, VMware + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ package org.aspectj.apache.bcel.classfile.annotation; import java.io.ByteArrayInputStream; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java index a2ab520d3..a6b2e529f 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java @@ -1,3 +1,14 @@ +/* ******************************************************************* + * Copyright (c) 2004, 2013 IBM, VMware + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataInputStream; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java index b5d7bb119..cb2eb8d7a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java @@ -1,3 +1,14 @@ +/* ******************************************************************* + * Copyright (c) 2004, 2013 IBM, VMware + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataInputStream; 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 4bd8644c5..ad92c9fce 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 @@ -1,3 +1,14 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ package org.aspectj.apache.bcel.classfile.annotation; import java.io.ByteArrayInputStream; @@ -12,7 +23,7 @@ import org.aspectj.apache.bcel.classfile.ConstantPool; public abstract class RuntimeParamAnnos extends Attribute { - private List /*Annotation[]*/<AnnotationGen[]> parameterAnnotations; + private List<AnnotationGen[]> parameterAnnotations; private boolean visible; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java index aa3f49eac..3b07cccc7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java @@ -1,3 +1,14 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataInputStream; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java index ccd1aa7d2..b47d8aac1 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java @@ -1,3 +1,14 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataInputStream; |