Remove java.lang.JavaLangAccess
First port of openJdk to libcore took sun.misc.JavaLangAccess
and put it into java.lang to help with Class.getEnumConstantsShared
visibility. This change removes java.lang.JavaLangAccess,
makes Class.getEnumConstantsShared public&hidden and
changes java.util to call getEnumConstantsShared
directly.
Test: make
Bug: 36429512
Change-Id: I547fcebee3a5839d5af05753c9d18e08f54bd335
diff --git a/ojluni/src/main/java/java/lang/Class.java b/ojluni/src/main/java/java/lang/Class.java
index 3717cd7..ed9f915 100644
--- a/ojluni/src/main/java/java/lang/Class.java
+++ b/ojluni/src/main/java/java/lang/Class.java
@@ -2403,13 +2403,15 @@
return (values != null) ? values.clone() : null;
}
+ // Android-changed: Made public/hidden instead of using sun.misc.SharedSecrets.
/**
* Returns the elements of this enum class or null if this
* Class object does not represent an enum type;
* identical to getEnumConstants except that the result is
* uncloned, cached, and shared by all callers.
+ * @hide
*/
- T[] getEnumConstantsShared() {
+ public T[] getEnumConstantsShared() {
if (!isEnum()) return null;
return (T[]) Enum.getSharedConstants((Class) this);
}
diff --git a/ojluni/src/main/java/java/lang/JavaLangAccess.java b/ojluni/src/main/java/java/lang/JavaLangAccess.java
deleted file mode 100644
index 2779c60..0000000
--- a/ojluni/src/main/java/java/lang/JavaLangAccess.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2003, 2006, 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;
-
-/**
- * @hide
- */
-public final class JavaLangAccess {
- private JavaLangAccess() {
- }
-
- /**
- * @hide
- */
- public static <E extends Enum<E>>
- E[] getEnumConstantsShared(Class<E> klass) {
- return klass.getEnumConstantsShared();
- }
-}
diff --git a/ojluni/src/main/java/java/util/EnumMap.java b/ojluni/src/main/java/java/util/EnumMap.java
index a2512a8..207ce62 100644
--- a/ojluni/src/main/java/java/util/EnumMap.java
+++ b/ojluni/src/main/java/java/util/EnumMap.java
@@ -750,9 +750,9 @@
* The result is uncloned, cached, and shared by all callers.
*/
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
- // Android-changed: Use JavaLangAccess directly instead of going through
- // SharedSecrets.
- return JavaLangAccess.getEnumConstantsShared(keyType);
+ // Android-changed: Use getEnumConstantsShared directly instead of going
+ // through SharedSecrets.
+ return keyType.getEnumConstantsShared();
}
private static final long serialVersionUID = 458661240069192865L;
diff --git a/ojluni/src/main/java/java/util/EnumSet.java b/ojluni/src/main/java/java/util/EnumSet.java
index 5d9311a..2443f1e 100644
--- a/ojluni/src/main/java/java/util/EnumSet.java
+++ b/ojluni/src/main/java/java/util/EnumSet.java
@@ -402,9 +402,9 @@
* The result is uncloned, cached, and shared by all callers.
*/
private static <E extends Enum<E>> E[] getUniverse(Class<E> elementType) {
- // Android-changed: Use JavaLangAccess directly instead of going via
- // SharedSecrets.
- return java.lang.JavaLangAccess.getEnumConstantsShared(elementType);
+ // Android-changed: Use getEnumConstantsShared directly instead of going
+ // through SharedSecrets.
+ return elementType.getEnumConstantsShared();
}
/**
diff --git a/openjdk_java_files.mk b/openjdk_java_files.mk
index e500bd86..81110ab 100644
--- a/openjdk_java_files.mk
+++ b/openjdk_java_files.mk
@@ -152,7 +152,6 @@
ojluni/src/main/java/java/lang/InternalError.java \
ojluni/src/main/java/java/lang/InterruptedException.java \
ojluni/src/main/java/java/lang/Iterable.java \
- ojluni/src/main/java/java/lang/JavaLangAccess.java \
ojluni/src/main/java/java/lang/LinkageError.java \
ojluni/src/main/java/java/lang/Long.java \
ojluni/src/main/java/java/lang/Math.java \