Skip to content

Commit

Permalink
Merge "Stubs required for javac to compile lambda code"
Browse files Browse the repository at this point in the history
  • Loading branch information
nfuller authored and Gerrit Code Review committed Feb 16, 2016
2 parents 62272ca + 7d6a54c commit 754b3a9
Show file tree
Hide file tree
Showing 9 changed files with 546 additions and 2 deletions.
4 changes: 2 additions & 2 deletions JavaLibrary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -217,7 +217,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)
Expand Down
39 changes: 39 additions & 0 deletions ojluni/src/lambda/java/java/lang/invoke/CallSite.java
Original file line number Diff line number Diff line change
@@ -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();

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
49 changes: 49 additions & 0 deletions ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.java
Original file line number Diff line number Diff line change
@@ -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; }
}
52 changes: 52 additions & 0 deletions ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java
Original file line number Diff line number Diff line change
@@ -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; }

}
62 changes: 62 additions & 0 deletions ojluni/src/lambda/java/java/lang/invoke/MethodHandleInfo.java
Original file line number Diff line number Diff line change
@@ -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 extends Member> T reflectAs(Class<T> 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;
}
}
Loading

0 comments on commit 754b3a9

Please sign in to comment.