diff options
Diffstat (limited to 'bcel-builder')
7 files changed, 136 insertions, 4 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java index a5068f638..9ef04f4ff 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java @@ -84,6 +84,8 @@ public interface Constants { public final static short MINOR_1_9 = 0; public final static short MAJOR_10 = 54; public final static short MINOR_10 = 0; + public final static short MAJOR_11 = 55; + public final static short MINOR_11 = 0; // Defaults public final static short MAJOR = MAJOR_1_1; public final static short MINOR = MINOR_1_1; @@ -155,9 +157,9 @@ public interface Constants { public final static byte CONSTANT_MethodHandle = 15; public final static byte CONSTANT_MethodType = 16; + public final static byte CONSTANT_Dynamic = 17; public final static byte CONSTANT_InvokeDynamic = 18; - // J9: public final static byte CONSTANT_Module = 19; public final static byte CONSTANT_Package = 20; 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 0a9340649..654cd8146 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java @@ -98,6 +98,8 @@ public interface ClassVisitor { public void visitConstantMethodType(ConstantMethodType obj); public void visitConstantInvokeDynamic(ConstantInvokeDynamic obj); + + public void visitConstantDynamic(ConstantDynamic obj); public void visitConstantPool(ConstantPool obj); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java index 6fbbff3a3..d391b75ea 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java @@ -135,8 +135,12 @@ public abstract class Constant implements Cloneable, Node { return new ConstantMethodType(dis); case Constants.CONSTANT_InvokeDynamic: return new ConstantInvokeDynamic(dis); - case Constants.CONSTANT_Module: return new ConstantModule(dis); - case Constants.CONSTANT_Package: return new ConstantPackage(dis); + case Constants.CONSTANT_Module: + return new ConstantModule(dis); + case Constants.CONSTANT_Package: + return new ConstantPackage(dis); + case Constants.CONSTANT_Dynamic: + return new ConstantDynamic(dis); default: throw new ClassFormatException("Invalid byte tag in constant pool: " + b); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDynamic.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDynamic.java new file mode 100644 index 000000000..40100f83b --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDynamic.java @@ -0,0 +1,116 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * 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.DataOutputStream; +import java.io.IOException; + +import org.aspectj.apache.bcel.Constants; + +/** + * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and + * represents a reference to the name and signature of a field or method. + * + * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.10 + * + * @author Andy Clement + * @see Constant + */ +public final class ConstantDynamic extends Constant { + private final int bootstrapMethodAttrIndex; + private final int nameAndTypeIndex; + + ConstantDynamic(DataInputStream file) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort()); + } + + public ConstantDynamic(int readUnsignedShort, int nameAndTypeIndex) { + super(Constants.CONSTANT_InvokeDynamic); + this.bootstrapMethodAttrIndex = readUnsignedShort; + this.nameAndTypeIndex = nameAndTypeIndex; + } + + @Override + public final void dump(DataOutputStream file) throws IOException { + file.writeByte(tag); + file.writeShort(bootstrapMethodAttrIndex); + file.writeShort(nameAndTypeIndex); + } + + public final int getNameAndTypeIndex() { + return nameAndTypeIndex; + } + + public final int getBootstrapMethodAttrIndex() { + return bootstrapMethodAttrIndex; + } + + @Override + public final String toString() { + return super.toString() + "(bootstrapMethodAttrIndex=" + bootstrapMethodAttrIndex + ",nameAndTypeIndex=" + nameAndTypeIndex + ")"; + } + + @Override + public String getValue() { + return toString(); + } + + @Override + public void accept(ClassVisitor v) { + v.visitConstantDynamic(this); + } + +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java index 136f69390..b7db332d2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java @@ -226,7 +226,7 @@ public class ClassPath implements Serializable { } // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem - if (vm_version.startsWith("9") || vm_version.startsWith("10")) { + if (vm_version.startsWith("9") || vm_version.startsWith("10") || vm_version.startsWith("11")) { buf.insert(0, File.pathSeparatorChar); buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS); } diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java index 69b9e1321..6dc3eae46 100644 --- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java @@ -64,6 +64,7 @@ import org.aspectj.apache.bcel.classfile.CodeException; import org.aspectj.apache.bcel.classfile.Constant; import org.aspectj.apache.bcel.classfile.ConstantClass; import org.aspectj.apache.bcel.classfile.ConstantDouble; +import org.aspectj.apache.bcel.classfile.ConstantDynamic; import org.aspectj.apache.bcel.classfile.ConstantFieldref; import org.aspectj.apache.bcel.classfile.ConstantFloat; import org.aspectj.apache.bcel.classfile.ConstantInteger; @@ -357,6 +358,10 @@ public class DescendingVisitor implements ClassVisitor { throw new IllegalStateException("nyi"); } + public void visitConstantDynamic(ConstantDynamic obj) { + throw new IllegalStateException("nyi"); + } + public void visitBootstrapMethods(BootstrapMethods obj) { throw new IllegalStateException("nyi"); } diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java index 039d204dd..aca992fbf 100644 --- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java @@ -59,6 +59,7 @@ import org.aspectj.apache.bcel.classfile.Code; import org.aspectj.apache.bcel.classfile.CodeException; import org.aspectj.apache.bcel.classfile.ConstantClass; import org.aspectj.apache.bcel.classfile.ConstantDouble; +import org.aspectj.apache.bcel.classfile.ConstantDynamic; import org.aspectj.apache.bcel.classfile.ConstantFieldref; import org.aspectj.apache.bcel.classfile.ConstantFloat; import org.aspectj.apache.bcel.classfile.ConstantInteger; @@ -176,5 +177,7 @@ public class EmptyClassVisitor implements ClassVisitor { public void visitModule(Module attribute) {} public void visitModulePackages(ModulePackages attribute) {} public void visitModuleMainClass(ModuleMainClass attribute) {} + + public void visitConstantDynamic(ConstantDynamic obj) {} } |