diff --git a/JavaLibrary.mk b/JavaLibrary.mk index bbe23451d..404035956 100644 --- a/JavaLibrary.mk +++ b/JavaLibrary.mk @@ -81,7 +81,7 @@ android_icu4j_resource_dirs := $(android_icu4j_root)/resources # include $(CLEAR_VARS) -LOCAL_SRC_FILES := $(openjdk_java_files) $(non_openjdk_java_files) $(android_icu4j_src_files) +LOCAL_SRC_FILES := $(openjdk_java_files) $(non_openjdk_java_files) $(android_icu4j_src_files) $(openjdk_lambda_stub_files) LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) $(android_icu4j_resource_dirs) LOCAL_NO_STANDARD_LIBRARIES := true LOCAL_JAVACFLAGS := $(local_javac_flags) @@ -212,7 +212,7 @@ LOCAL_MODULE := dex-host include $(BUILD_HOST_JAVA_LIBRARY) include $(CLEAR_VARS) -LOCAL_SRC_FILES := $(non_openjdk_java_files) $(openjdk_java_files) $(android_icu4j_src_files) +LOCAL_SRC_FILES := $(non_openjdk_java_files) $(openjdk_java_files) $(android_icu4j_src_files) $(openjdk_lambda_stub_files) LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) LOCAL_NO_STANDARD_LIBRARIES := true LOCAL_JAVACFLAGS := $(local_javac_flags) diff --git a/ojluni/src/lambda/java/java/lang/invoke/CallSite.java b/ojluni/src/lambda/java/java/lang/invoke/CallSite.java new file mode 100644 index 000000000..1ff1eb843 --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/CallSite.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +abstract +public class CallSite { + + public MethodType type() { return null; } + + public abstract MethodHandle getTarget(); + + public abstract void setTarget(MethodHandle newTarget); + + public abstract MethodHandle dynamicInvoker(); + +} diff --git a/ojluni/src/lambda/java/java/lang/invoke/LambdaConversionException.java b/ojluni/src/lambda/java/java/lang/invoke/LambdaConversionException.java new file mode 100644 index 000000000..e1123da59 --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/LambdaConversionException.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +/** + * LambdaConversionException + */ +public class LambdaConversionException extends Exception { + private static final long serialVersionUID = 292L + 8L; + + /** + * Constructs a {@code LambdaConversionException}. + */ + public LambdaConversionException() { + } + + /** + * Constructs a {@code LambdaConversionException} with a message. + * @param message the detail message + */ + public LambdaConversionException(String message) { + super(message); + } + + /** + * Constructs a {@code LambdaConversionException} with a message and cause. + * @param message the detail message + * @param cause the cause + */ + public LambdaConversionException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a {@code LambdaConversionException} with a cause. + * @param cause the cause + */ + public LambdaConversionException(Throwable cause) { + super(cause); + } + + /** + * Constructs a {@code LambdaConversionException} with a message, + * cause, and other settings. + * @param message the detail message + * @param cause the cause + * @param enableSuppression whether or not suppressed exceptions are enabled + * @param writableStackTrace whether or not the stack trace is writable + */ + public LambdaConversionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.java b/ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.java new file mode 100644 index 000000000..e1ce46f33 --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +public class LambdaMetafactory { + + public static final int FLAG_SERIALIZABLE = 1 << 0; + + public static final int FLAG_MARKERS = 1 << 1; + + public static final int FLAG_BRIDGES = 1 << 2; + + public static CallSite metafactory(MethodHandles.Lookup caller, + String invokedName, + MethodType invokedType, + MethodType samMethodType, + MethodHandle implMethod, + MethodType instantiatedMethodType) + throws LambdaConversionException { return null; } + + public static CallSite altMetafactory(MethodHandles.Lookup caller, + String invokedName, + MethodType invokedType, + Object... args) + throws LambdaConversionException { return null; } +} diff --git a/ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java b/ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java new file mode 100644 index 000000000..159f9dd77 --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +public abstract class MethodHandle { + + public MethodType type() { return null; } + + public final Object invokeExact(Object... args) throws Throwable { return null; } + + public final Object invoke(Object... args) throws Throwable { return null; } + + public Object invokeWithArguments(Object... arguments) throws Throwable { return null; } + + public Object invokeWithArguments(java.util.List arguments) throws Throwable { return null; } + + public MethodHandle asType(MethodType newType) { return null; } + + public MethodHandle asCollector(Class arrayType, int arrayLength) { return null; } + + public MethodHandle asVarargsCollector(Class arrayType) { return null; } + + public boolean isVarargsCollector() { return false; } + + public MethodHandle asFixedArity() { return null; } + + public MethodHandle bindTo(Object x) { return null; } + +} diff --git a/ojluni/src/lambda/java/java/lang/invoke/MethodHandleInfo.java b/ojluni/src/lambda/java/java/lang/invoke/MethodHandleInfo.java new file mode 100644 index 000000000..68a736c72 --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/MethodHandleInfo.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +import java.lang.invoke.MethodHandles.Lookup; +import java.lang.reflect.Member; + +public +interface MethodHandleInfo { + public static final int REF_getField = 0; + public static final int REF_getStatic = 0; + public static final int REF_putField = 0; + public static final int REF_putStatic = 0; + public static final int REF_invokeVirtual = 0; + public static final int REF_invokeStatic = 0; + public static final int REF_invokeSpecial = 0; + public static final int REF_newInvokeSpecial = 0; + public static final int REF_invokeInterface = 0; + + public int getReferenceKind(); + + public Class getDeclaringClass(); + + public String getName(); + + public MethodType getMethodType(); + + public T reflectAs(Class expected, Lookup lookup); + + public int getModifiers(); + + public default boolean isVarArgs() { return false; } + + public static String referenceKindToString(int referenceKind) { return null; } + + public static String toString(int kind, Class defc, String name, MethodType type) { + return null; + } +} diff --git a/ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java b/ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java new file mode 100644 index 000000000..f27ad9884 --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.util.List; + +public class MethodHandles { + + public static Lookup lookup() { return null; } + + public static Lookup publicLookup() { return null; } + + public static T + reflectAs(Class expected, MethodHandle target) { return null; } + + public static final + class Lookup { + public static final int PUBLIC = 0; + + public static final int PRIVATE = 0; + + public static final int PROTECTED = 0; + + public static final int PACKAGE = 0; + + public Class lookupClass() { return null; } + + public int lookupModes() { return 0; } + + public Lookup in(Class requestedLookupClass) { return null; } + + public + MethodHandle findStatic(Class refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException { return null; } + + public MethodHandle findVirtual(Class refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException { return null; } + + public MethodHandle findConstructor(Class refc, MethodType type) throws NoSuchMethodException, IllegalAccessException { return null; } + + public MethodHandle findSpecial(Class refc, String name, MethodType type, + Class specialCaller) throws NoSuchMethodException, IllegalAccessException { return null; } + + public MethodHandle findGetter(Class refc, String name, Class type) throws NoSuchFieldException, IllegalAccessException { return null; } + + public MethodHandle findSetter(Class refc, String name, Class type) throws NoSuchFieldException, IllegalAccessException { return null; } + + public MethodHandle findStaticGetter(Class refc, String name, Class type) throws NoSuchFieldException, IllegalAccessException { return null; } + + public MethodHandle findStaticSetter(Class refc, String name, Class type) throws NoSuchFieldException, IllegalAccessException { return null; } + + public MethodHandle bind(Object receiver, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException { return null; } + + public MethodHandle unreflect(Method m) throws IllegalAccessException { return null; } + + public MethodHandle unreflectSpecial(Method m, Class specialCaller) throws IllegalAccessException { return null; } + + public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException { return null; } + + public MethodHandle unreflectGetter(Field f) throws IllegalAccessException { return null; } + + public MethodHandle unreflectSetter(Field f) throws IllegalAccessException { return null; } + + public MethodHandleInfo revealDirect(MethodHandle target) { return null; } + + } + + public static + MethodHandle arrayElementGetter(Class arrayClass) throws IllegalArgumentException { return null; } + + public static + MethodHandle arrayElementSetter(Class arrayClass) throws IllegalArgumentException { return null; } + + static public + MethodHandle spreadInvoker(MethodType type, int leadingArgCount) { return null; } + + static public + MethodHandle exactInvoker(MethodType type) { return null; } + + static public + MethodHandle invoker(MethodType type) { return null; } + + public static + MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) { return null; } + + public static + MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) { return null; } + + public static + MethodHandle constant(Class type, Object value) { return null; } + + public static + MethodHandle identity(Class type) { return null; } + + public static + MethodHandle insertArguments(MethodHandle target, int pos, Object... values) { return null; } + + public static + MethodHandle dropArguments(MethodHandle target, int pos, List> valueTypes) { return null; } + + public static + MethodHandle dropArguments(MethodHandle target, int pos, Class... valueTypes) { return null; } + + public static + MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) { return null; } + + public static + MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle filter) { return null; } + + public static + MethodHandle filterReturnValue(MethodHandle target, MethodHandle filter) { return null; } + + public static + MethodHandle foldArguments(MethodHandle target, MethodHandle combiner) { return null; } + + public static + MethodHandle guardWithTest(MethodHandle test, + MethodHandle target, + MethodHandle fallback) { return null; } + + public static + MethodHandle catchException(MethodHandle target, + Class exType, + MethodHandle handler) { return null; } + + public static + MethodHandle throwException(Class returnType, Class exType) { return null; } +} diff --git a/ojluni/src/lambda/java/java/lang/invoke/MethodType.java b/ojluni/src/lambda/java/java/lang/invoke/MethodType.java new file mode 100644 index 000000000..4cb5c226c --- /dev/null +++ b/ojluni/src/lambda/java/java/lang/invoke/MethodType.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +import java.util.List; + +public final +class MethodType implements java.io.Serializable { + + public static + MethodType methodType(Class rtype, Class[] ptypes) { + return null; + } + + public static + MethodType methodType(Class rtype, List> ptypes) { + return null; + } + + public static + MethodType methodType(Class rtype, Class ptype0, Class... ptypes) { return null; } + + public static + MethodType methodType(Class rtype) { return null; } + + public static + MethodType methodType(Class rtype, Class ptype0) { return null; } + + public static + MethodType methodType(Class rtype, MethodType ptypes) { return null; } + + public static + MethodType genericMethodType(int objectArgCount, boolean finalArray) { return null; } + + public static + MethodType genericMethodType(int objectArgCount) { return null; } + + public MethodType changeParameterType(int num, Class nptype) { return null; } + + public MethodType insertParameterTypes(int num, Class... ptypesToInsert) { return null; } + + public MethodType appendParameterTypes(Class... ptypesToInsert) { return null; } + + public MethodType insertParameterTypes(int num, List> ptypesToInsert) { return null; } + + public MethodType appendParameterTypes(List> ptypesToInsert) { return null; } + + public MethodType dropParameterTypes(int start, int end) { return null; } + + public MethodType changeReturnType(Class nrtype) { return null; } + + public boolean hasPrimitives() { return false; } + + public boolean hasWrappers() { return false; } + + public MethodType erase() { return null; } + + public MethodType generic() { return null; } + + public MethodType wrap() { return null; } + + public MethodType unwrap() { return null; } + + public Class parameterType(int num) { return null; } + + public int parameterCount() { return 0; } + + public Class returnType() { return null; } + + public List> parameterList() { return null; } + + public Class[] parameterArray() { return null; } + + public static MethodType fromMethodDescriptorString(String descriptor, ClassLoader loader) + throws IllegalArgumentException, TypeNotPresentException { return null; } + + public String toMethodDescriptorString() { return null; } + +} diff --git a/openjdk_java_files.mk b/openjdk_java_files.mk index 29f53aa7d..ffca70016 100644 --- a/openjdk_java_files.mk +++ b/openjdk_java_files.mk @@ -1445,3 +1445,14 @@ openjdk_java_files := \ ojluni/src/main/java/sun/util/ResourceBundleEnumeration.java \ ojluni/src/main/java/sun/util/resources/OpenListResourceBundle.java \ $(openjdk_javadoc_files) + +# Stubs needed to satisfy javac's dependencies when compiling lambda code. These are +# not used on Android devices or required by the Jack compiler. +openjdk_lambda_stub_files := \ + ojluni/src/lambda/java/java/lang/invoke/CallSite.java \ + ojluni/src/lambda/java/java/lang/invoke/LambdaConversionException.java \ + ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.java \ + ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java \ + ojluni/src/lambda/java/java/lang/invoke/MethodHandleInfo.java \ + ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java \ + ojluni/src/lambda/java/java/lang/invoke/MethodType.java \