Skip to content

Commit

Permalink
Fix error prone build.
Browse files Browse the repository at this point in the history
We need to bring back stubs for MethodType / LambdaConversionException
to avoid build issues when targeting older SDKs.

bug: 30550796
test: make checkbuild; make -j39 javac-check RUN_ERROR_PRONE=true
Change-Id: I3c8a2ff296a51c0d9a552cf0e6cbf1815c680da8
  • Loading branch information
narayank committed Aug 2, 2016
1 parent a6d9d27 commit 3c9b631
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 8 deletions.
4 changes: 2 additions & 2 deletions JavaLibrary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ include $(BUILD_JAVA_LIBRARY)
# A library that exists to satisfy javac when
# compiling source code that contains lambdas.
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(openjdk_lambda_stub_files)
LOCAL_SRC_FILES := $(openjdk_lambda_stub_files) $(openjdk_lambda_duplicate_stub_files)
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_MODULE_TAGS := optional
Expand Down Expand Up @@ -318,7 +318,7 @@ include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
# A library that exists to satisfy javac when
# compiling source code that contains lambdas.
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(openjdk_lambda_stub_files)
LOCAL_SRC_FILES := $(openjdk_lambda_stub_files) $(openjdk_lambda_duplicate_stub_files)
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_MODULE_TAGS := optional
Expand Down
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);
}
}
102 changes: 102 additions & 0 deletions ojluni/src/lambda/java/java/lang/invoke/MethodType.java
Original file line number Diff line number Diff line change
@@ -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<Class<?>> 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<Class<?>> ptypesToInsert) { return null; }

public MethodType appendParameterTypes(List<Class<?>> 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<Class<?>> 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; }

}
19 changes: 13 additions & 6 deletions openjdk_java_files.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1606,14 +1606,21 @@ openjdk_java_files := \
ojluni/src/main/java/sun/util/resources/OpenListResourceBundle.java \
$(openjdk_javadoc_files)

# javac requires sections of java.lang.invoke.* to be available in the boot
# classpath in order to compile a lambda expression in Java source. Some of
# the classes it needs are present in core-oj, and those that aren't are
# stubbed here. In the long term, core-oj will contain a complete
# java.lang.invoke implementation and this list can be removed.
# Stubs needed to satisfy javac's dependencies when compiling lambda code. These are
# not used on Android devices or required by the Jack compiler.
#
# The stub files in openjdk_lambda_duplicate_stub_files are present in core-oj as
# well, and need to be included here to support compiling against older SDKs and the
# like. This additional bit of ugliness if required to avoid a circular dependency
# between core-all and these stubs. Eventually, all of these stubs will become
# "duplicates" and then that list can be renamed to "openjdk_lambda_stub_files".
openjdk_lambda_stub_files := \
ojluni/src/lambda/java/java/lang/invoke/CallSite.java \
ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.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/SerializedLambda.java \
ojluni/src/lambda/java/java/lang/invoke/SerializedLambda.java
openjdk_lambda_duplicate_stub_files := \
ojluni/src/lambda/java/java/lang/invoke/LambdaConversionException.java \
ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java \
ojluni/src/lambda/java/java/lang/invoke/MethodType.java \

0 comments on commit 3c9b631

Please sign in to comment.