Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper S Moller2013-04-17 13:16:30 +0000
committerssankaran2013-04-17 13:28:59 +0000
commitea1fe8ed052821b2b1ca5a7ad0079411db5ede64 (patch)
tree6a479e36076ed128c54fa0d620a07dbff413bd95
parentaade06a7dde9bdd68930bb7332e79ee5b41e5db9 (diff)
downloadeclipse.jdt.core-ea1fe8ed052821b2b1ca5a7ad0079411db5ede64.tar.gz
eclipse.jdt.core-ea1fe8ed052821b2b1ca5a7ad0079411db5ede64.tar.xz
eclipse.jdt.core-ea1fe8ed052821b2b1ca5a7ad0079411db5ede64.zip
Fixed Bug 405066 - [1.8][compiler][codegen] Implement code generation
infrastructure for JSR335
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java84
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java17
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java70
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java14
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java5
10 files changed, 228 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index 45a8207a05..71315ac772 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -11,6 +11,8 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler;
@@ -37,6 +39,7 @@ import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
@@ -117,6 +120,7 @@ public class ClassFile implements TypeConstants, TypeIds {
// that collection contains all the remaining bytes of the .class file
public int headerOffset;
public Set innerClassesBindings;
+ public List bootstrapMethods = null;
public int methodCount;
public int methodCountOffset;
// pool managment
@@ -347,6 +351,10 @@ public class ClassFile implements TypeConstants, TypeIds {
}
attributesNumber += generateHierarchyInconsistentAttribute();
}
+ // Functional expression and lambda bootstrap methods
+ if (this.bootstrapMethods != null && !this.bootstrapMethods.isEmpty()) {
+ attributesNumber += generateBootstrapMethods(this.bootstrapMethods);
+ }
// Inner class attribute
int numberOfInnerClasses = this.innerClassesBindings == null ? 0 : this.innerClassesBindings.size();
if (numberOfInnerClasses != 0) {
@@ -2394,6 +2402,71 @@ public class ClassFile implements TypeConstants, TypeIds {
this.contentsOffset = localContentsOffset;
return 1;
}
+
+ private int generateBootstrapMethods(List functionalExpressionList) {
+ /* See JVM spec 4.7.21
+ The BootstrapMethods attribute has the following format:
+ BootstrapMethods_attribute {
+ u2 attribute_name_index;
+ u4 attribute_length;
+ u2 num_bootstrap_methods;
+ { u2 bootstrap_method_ref;
+ u2 num_bootstrap_arguments;
+ u2 bootstrap_arguments[num_bootstrap_arguments];
+ } bootstrap_methods[num_bootstrap_methods];
+ }
+ */
+ // Record inner classes for MethodHandles$Lookup
+ recordInnerClasses(this.referenceBinding.scope.getJavaLangInvokeMethodHandlesLookup()); // Should be done, it's what javac does also
+ ReferenceBinding javaLangInvokeLambdaMetafactory = this.referenceBinding.scope.getJavaLangInvokeLambdaMetafactory();
+ int indexForMetaFactory = this.constantPool.literalIndexForMethodHandle(ClassFileConstants.MethodHandleRefKindInvokeStatic, javaLangInvokeLambdaMetafactory,
+ ConstantPool.METAFACTORY, ConstantPool.JAVA_LANG_INVOKE_LAMBDAMETAFACTORY_METAFACTORY_SIGNATURE, false);
+
+ int numberOfBootstraps = functionalExpressionList.size();
+ int localContentsOffset = this.contentsOffset;
+ // Generate the boot strap attribute - since we are only making lambdas and
+ // functional expressions, we know the size ahead of time - this less general
+ // than the full invokedynamic scope, but fine for Java 8
+ int exSize = 10 * numberOfBootstraps + 8;
+ if (exSize + localContentsOffset >= this.contents.length) {
+ resizeContents(exSize);
+ }
+ this.contentsOffset += exSize;
+
+ int attributeNameIndex =
+ this.constantPool.literalIndex(AttributeNamesConstants.BootstrapMethodsName);
+ this.contents[localContentsOffset++] = (byte) (attributeNameIndex >> 8);
+ this.contents[localContentsOffset++] = (byte) attributeNameIndex;
+ int value = (numberOfBootstraps * 10) + 2;
+ this.contents[localContentsOffset++] = (byte) (value >> 24);
+ this.contents[localContentsOffset++] = (byte) (value >> 16);
+ this.contents[localContentsOffset++] = (byte) (value >> 8);
+ this.contents[localContentsOffset++] = (byte) value;
+ this.contents[localContentsOffset++] = (byte) (numberOfBootstraps >> 8);
+ this.contents[localContentsOffset++] = (byte) numberOfBootstraps;
+ for (int i = 0; i < numberOfBootstraps; i++) {
+ FunctionalExpression functional = (FunctionalExpression) functionalExpressionList.get(i);
+ this.contents[localContentsOffset++] = (byte) (indexForMetaFactory >> 8);
+ this.contents[localContentsOffset++] = (byte) indexForMetaFactory;
+
+ this.contents[localContentsOffset++] = 0;
+ this.contents[localContentsOffset++] = (byte) 3;
+
+ int functionalDescriptorIndex = this.constantPool.literalIndexForMethodHandle(functional.descriptor.original());
+ this.contents[localContentsOffset++] = (byte) (functionalDescriptorIndex >> 8);
+ this.contents[localContentsOffset++] = (byte) functionalDescriptorIndex;
+
+ int methodHandleIndex = this.constantPool.literalIndexForMethodHandle(functional.binding);
+ this.contents[localContentsOffset++] = (byte) (methodHandleIndex >> 8);
+ this.contents[localContentsOffset++] = (byte) methodHandleIndex;
+
+ char [] instantiatedSignature = functional.signature();
+ int methodTypeIndex = this.constantPool.literalIndexForMethodType(instantiatedSignature);
+ this.contents[localContentsOffset++] = (byte) (methodTypeIndex >> 8);
+ this.contents[localContentsOffset++] = (byte) methodTypeIndex;
+ }
+ return 1;
+ }
private int generateLineNumberAttribute() {
int localContentsOffset = this.contentsOffset;
int attributesNumber = 0;
@@ -4154,6 +4227,14 @@ public class ClassFile implements TypeConstants, TypeIds {
}
}
+ public int recordBootstrapMethod(FunctionalExpression expression) {
+ if (this.bootstrapMethods == null) {
+ this.bootstrapMethods = new ArrayList();
+ }
+ this.bootstrapMethods.add(expression);
+ return this.bootstrapMethods.size() - 1;
+ }
+
public void reset(SourceTypeBinding typeBinding) {
// the code stream is reinitialized for each method
final CompilerOptions options = typeBinding.scope.compilerOptions();
@@ -4180,6 +4261,9 @@ public class ClassFile implements TypeConstants, TypeIds {
if (this.innerClassesBindings != null) {
this.innerClassesBindings.clear();
}
+ if (this.bootstrapMethods != null) {
+ this.bootstrapMethods.clear();
+ }
this.missingTypes = null;
this.visitedTypes = null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 1746785345..1306b97ab5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -12,6 +12,8 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for bug 295551
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -149,6 +151,7 @@ public void cleanUp() {
// null out the classfile backpointer to a type binding
classFile.referenceBinding = null;
classFile.innerClassesBindings = null;
+ classFile.bootstrapMethods = null;
classFile.missingTypes = null;
classFile.visitedTypes = null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java
index 385c2bc93d..3f407c089a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java
@@ -13,6 +13,7 @@
* IBM Corporation - initial API and implementation
* Jesper S Moller - Contributions for
* bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -37,7 +38,7 @@ import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
public abstract class FunctionalExpression extends Expression {
TypeBinding expectedType;
- MethodBinding descriptor;
+ public MethodBinding descriptor;
public MethodBinding binding;
boolean ignoreFurtherInvestigation;
protected ExpressionContext expressionContext = VANILLA_CONTEXT;
@@ -177,4 +178,8 @@ public abstract class FunctionalExpression extends Expression {
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+
+ public char[] signature() {
+ return null;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
index 03a23f19ba..c2cafd7a9c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
@@ -11,6 +11,8 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
@@ -81,6 +83,17 @@ public interface ClassFileConstants {
int ConstantMethodTypeFixedSize = 3;
int ConstantInvokeDynamicFixedSize = 5;
+ // JVMS 4.4.8
+ int MethodHandleRefKindGetField = 1;
+ int MethodHandleRefKindGetStatic = 2;
+ int MethodHandleRefKindPutField = 3;
+ int MethodHandleRefKindPutStatic = 4;
+ int MethodHandleRefKindInvokeVirtual = 5;
+ int MethodHandleRefKindInvokeStatic = 6;
+ int MethodHandleRefKindInvokeSpecial = 7;
+ int MethodHandleRefKindNewInvokeSpecial = 8;
+ int MethodHandleRefKindInvokeInterface = 9;
+
int MAJOR_VERSION_1_1 = 45;
int MAJOR_VERSION_1_2 = 46;
int MAJOR_VERSION_1_3 = 47;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java
index 51a4e8354e..0b14be05de 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* 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
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
@@ -33,4 +39,5 @@ public interface AttributeNamesConstants {
final char[] VarargsName = "Varargs".toCharArray(); //$NON-NLS-1$
final char[] StackMapName = "StackMap".toCharArray(); //$NON-NLS-1$
final char[] MissingTypesName = "MissingTypes".toCharArray(); //$NON-NLS-1$
+ final char[] BootstrapMethodsName = "BootstrapMethods".toCharArray(); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index d349054196..a55642dbf9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -14,6 +14,8 @@
* Stephan Herrmann - Contribution for
* bug 400710 - [1.8][compiler] synthetic access to default method generates wrong code
* bug 391376 - [1.8] check interaction of default methods with bridge methods and generics
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
@@ -3900,6 +3902,21 @@ protected void invoke(byte opcode, int receiverAndArgsSize, int returnTypeSize,
this.stackMax = this.stackDepth;
}
}
+public void invokeDynamic(int bootStrapIndex, int argsSize, int returnTypeSize, char[] selector, char[] signature) {
+ if (this.classFileOffset + 4 >= this.bCodeStream.length) {
+ resizeByteArray();
+ }
+ int invokeDynamicIndex = this.constantPool.literalIndexForInvokeDynamic(bootStrapIndex, selector, signature);
+ this.position +=3;
+ this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokedynamic;
+ writeUnsignedShort(invokeDynamicIndex);
+ this.bCodeStream[this.classFileOffset++] = 0;
+ this.bCodeStream[this.classFileOffset++] = 0;
+ this.stackDepth += returnTypeSize - argsSize;
+ if (this.stackDepth > this.stackMax) {
+ this.stackMax = this.stackDepth;
+ }
+}
public void invoke(byte opcode, MethodBinding methodBinding, TypeBinding declaringClass) {
if (declaringClass == null) declaringClass = methodBinding.declaringClass;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
index c449385166..8035deee59 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
@@ -1,18 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* 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
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
@@ -248,6 +255,9 @@ public class ConstantPool implements ClassFileConstants, TypeIds {
public static final char[] JAVA_LANG_SAFEVARARGS = "Ljava/lang/SafeVarargs;".toCharArray(); //$NON-NLS-1$
// java 7 java.lang.invoke.MethodHandle.invokeExact(..)/invokeGeneric(..)
public static final char[] JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE = "Ljava/lang/invoke/MethodHandle$PolymorphicSignature;".toCharArray(); //$NON-NLS-1$
+ // Java 8 lambda support
+ public static final char[] METAFACTORY = "metaFactory".toCharArray(); //$NON-NLS-1$
+ public static final char[] JAVA_LANG_INVOKE_LAMBDAMETAFACTORY_METAFACTORY_SIGNATURE = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;".toCharArray(); //$NON-NLS-1$
public static final char[] HashCode = "hashCode".toCharArray(); //$NON-NLS-1$
public static final char[] HashCodeSignature = "()I".toCharArray(); //$NON-NLS-1$;
@@ -738,6 +748,64 @@ public class ConstantPool implements ClassFileConstants, TypeIds {
}
return index;
}
+ public int literalIndexForMethodHandle(MethodBinding binding) {
+ boolean isInterface = binding.declaringClass.isInterface();
+ int referenceKind =
+ isInterface ? MethodHandleRefKindInvokeInterface
+ : binding.isConstructor() ? MethodHandleRefKindNewInvokeSpecial
+ : binding.isStatic() ? MethodHandleRefKindInvokeStatic
+ : MethodHandleRefKindInvokeVirtual;
+
+ return literalIndexForMethodHandle(referenceKind, binding.declaringClass, binding.selector, binding.signature(), isInterface);
+ }
+
+ public int literalIndexForMethodHandle(int referenceKind, TypeBinding declaringClass, char[] selector, char[] signature, boolean isInterface) {
+ int indexForMethod = literalIndexForMethod(declaringClass, selector, signature, isInterface);
+
+ int index = this.currentIndex++;
+ int length = this.offsets.length;
+ if (length <= index) {
+ // resize
+ System.arraycopy(this.offsets, 0, (this.offsets = new int[index * 2]), 0, length);
+ }
+
+ this.offsets[index] = this.currentOffset;
+ writeU1(MethodHandleTag);
+ writeU1(referenceKind);
+ writeU2(indexForMethod);
+
+ return index;
+ }
+ public int literalIndexForMethodType(char[] descriptor) {
+ int signatureIndex = literalIndex(descriptor);
+
+ int index = this.currentIndex++;
+
+ int length = this.offsets.length;
+ if (length <= index) {
+ // resize
+ System.arraycopy(this.offsets, 0, (this.offsets = new int[index * 2]), 0, length);
+ }
+ this.offsets[index] = this.currentOffset;
+ writeU1(MethodTypeTag);
+ writeU2(signatureIndex);
+
+ return index;
+ }
+ public int literalIndexForInvokeDynamic(int bootStrapIndex, char[] selector, char[] descriptor) {
+ int nameAndTypeIndex = literalIndexForNameAndType(selector, descriptor);
+ int index = this.currentIndex++;
+ int length = this.offsets.length;
+ if (length <= index) {
+ // resize
+ System.arraycopy(this.offsets, 0, (this.offsets = new int[index * 2]), 0, length);
+ }
+ this.offsets[index] = this.currentOffset;
+ writeU1(InvokeDynamicTag);
+ writeU2(bootStrapIndex);
+ writeU2(nameAndTypeIndex);
+ return index;
+ }
public int literalIndexForField(char[] declaringClass, char[] name, char[] signature) {
int index;
if ((index = putInCacheIfAbsent(declaringClass, name, signature, this.currentIndex)) < 0) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java
index 85ae27911a..a177713033 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java
@@ -1,12 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* 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
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ *
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
@@ -198,6 +205,7 @@ public interface Opcodes {
public static final byte OPC_invokespecial = (byte) 183;
public static final byte OPC_invokestatic = (byte) 184;
public static final byte OPC_invokeinterface = (byte) 185;
+ public static final byte OPC_invokedynamic = (byte) 186;
public static final byte OPC_new = (byte) 187;
public static final byte OPC_newarray = (byte) 188;
public static final byte OPC_anewarray = (byte) 189;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index 741aa8932a..1e34c03237 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -19,6 +19,7 @@
* bug 401271 - StackOverflowError when searching for a methods references
* Jesper S Moller - Contributions for
* Bug 378674 - "The method can be declared as static" is wrong
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -2379,6 +2380,19 @@ public abstract class Scope {
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ENUM, this);
}
+ public final ReferenceBinding getJavaLangInvokeLambdaMetafactory() {
+ CompilationUnitScope unitScope = compilationUnitScope();
+ unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_INVOKE_LAMBDAMETAFACTORY);
+ return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_INVOKE_LAMBDAMETAFACTORY, this);
+ }
+
+ public final ReferenceBinding getJavaLangInvokeMethodHandlesLookup() {
+ CompilationUnitScope unitScope = compilationUnitScope();
+ unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_INVOKE_METHODHANDLES);
+ ReferenceBinding outerType = unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_INVOKE_METHODHANDLES, this);
+ return findDirectMemberType("Lookup".toCharArray(), outerType); //$NON-NLS-1$
+ }
+
public final ReferenceBinding getJavaLangIterable() {
CompilationUnitScope unitScope = compilationUnitScope();
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ITERABLE);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
index a605d66c42..6453ff13b5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
@@ -17,6 +17,9 @@
* bug 381445 - [compiler][resource] Can the resource leak check be made aware of Closeables.closeQuietly?
* bug 400421 - [compiler] Null analysis for fields does not take @com.google.inject.Inject into account
* bug 382069 - [null] Make the null analysis consider JUnit's assertNotNull similarly to assertions
+ *
+ * Jesper S Moller - Contributions for
+ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -180,6 +183,8 @@ public interface TypeConstants {
INVOKE,
"MethodHandle$PolymorphicSignature".toCharArray() //$NON-NLS-1$
};
+ char[][] JAVA_LANG_INVOKE_LAMBDAMETAFACTORY = {JAVA, LANG, INVOKE, "LambdaMetafactory".toCharArray()}; //$NON-NLS-1$
+ char[][] JAVA_LANG_INVOKE_METHODHANDLES = {JAVA, LANG, INVOKE, "MethodHandles".toCharArray()}; //$NON-NLS-1$
char[][] JAVA_LANG_AUTOCLOSEABLE = {JAVA, LANG, "AutoCloseable".toCharArray()}; //$NON-NLS-1$
char[] CLOSE = "close".toCharArray(); //$NON-NLS-1$
// known helper functions for closing a Closeable (all receive a Closeable as their first argument):

Back to the top