Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Java 12 build failures #3980

Merged
merged 4 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ K05cc=Cannot assign '{0}' to methodtype '{1}'
K05cd=unable to resolve 'bootstrap_method_ref' in '{0}' at index {1}
K05ce=Invalid method name: {0}
K05cf=illegal setter on final field
K05d0=Can't apply fold of type: {0} to handle of type: {1} starting at {2}
K05d0=Can't apply preprocessor of type: {0} to handle of type: {1} starting at {2}
K05d1=cannot have null spread argument unless spreadCount is 0
K05d2=expected '{0}' sized array; encountered '{1}' sized array
K05d3=invalid descriptor: {0}
Expand Down Expand Up @@ -1207,7 +1207,8 @@ K0636="No such field: {0}.{1}({2})"
#java.lang.invoke.MethodHandles
K0637=The value of {0}: {1} must be in a range from 0 to {2}
K0638=The count of argument indices: {0} must be equal to the parameter count of the combiner: {1}
K063A=The return type of combiner: {0} is inconsistent with the argument type of fold handle: {1} at the fold position: {2}
K063A1=The return type of combiner: {0} is inconsistent with the argument type of {1} handle: {2} at the {3} position: {4}
K063A2=The return type of combiner should never be void.
K063B=The return type of the try handle: {0} is inconsistent with the return type of the finally handle: {1}
K063C=The 1st parameter type of the finally handle: {0} is not {1}
K063D=The 2nd parameter type of the finally handle: {0} is inconsistent with the return type of the try handle: {1}
Expand Down
18 changes: 17 additions & 1 deletion jcl/src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*[INCLUDE-IF Sidecar16]*/
/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
* Copyright (c) 1998, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -27,6 +27,9 @@
import java.security.ProtectionDomain;
import java.security.AllPermission;
import java.security.Permissions;
/*[IF Java12]*/
import java.lang.constant.ClassDesc;
/*[ENDIF] Java12*/
import java.lang.reflect.*;
import java.net.URL;
import java.lang.annotation.*;
Expand All @@ -38,6 +41,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
/*[IF Java12]*/
import java.util.Optional;
/*[ENDIF] Java12 */
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.security.AccessController;
Expand Down Expand Up @@ -4545,4 +4551,14 @@ public Class<?>[] getNestMembers() throws LinkageError, SecurityException {
return nestMembers;
}
/*[ENDIF] Java11 */

/*[IF Java12]*/
public Class<?> arrayType() {
throw new UnsupportedOperationException("Stub for Java 12 compilation");
}

public Optional<ClassDesc> describeConstable() {
throw new UnsupportedOperationException("Stub for Java 12 compilation");
}
/*[ENDIF] Java12 */
}
116 changes: 77 additions & 39 deletions jcl/src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import jdk.internal.access.SharedSecrets;
/*[ELSE]
import jdk.internal.misc.SharedSecrets;
/*[ENDIF]*/
/*[ENDIF] Java12 */
import jdk.internal.misc.VM;
import java.lang.StackWalker.Option;
import java.lang.Module;
Expand Down Expand Up @@ -141,16 +141,10 @@ static void afterClinitInitialization() {
}

// Fill in the properties from the VM information.
ensureProperties();
ensureProperties(true);

/*[PR CMVC 150472] sun.misc.SharedSecrets needs access to java.lang. */
SharedSecrets.setJavaLangAccess(new Access());

/*[PR CMVC 179976] System.setProperties(null) throws IllegalStateException */
try {
VM.saveAndRemoveProperties(systemProperties);
} catch (NoSuchMethodError e) {
}

/*[REM] Initialize the JITHelpers needed in J9VMInternals since the class can't do it itself */
try {
Expand Down Expand Up @@ -362,28 +356,32 @@ private static void arraycopy(Object[] A1, int offset1, Object[] A2, int offset2
* provided by the virtual machine.
*/
@SuppressWarnings("nls")
private static void ensureProperties() {
private static void ensureProperties(boolean isInitialization) {
/*[IF OpenJ9-RawBuild]*/
// invoke JCL native to initialize platform encoding
initProperties(new Properties());
/*[ENDIF] OpenJ9-RawBuild */

systemProperties = new Properties();
/*[IF Java12]*/
Map<String, String> initializedProperties = new Hashtable<String, String>();
/*[ELSE]
Properties initializedProperties = new Properties();
/*[ENDIF] Java12 */

if (osEncoding != null) {
systemProperties.put("os.encoding", osEncoding); //$NON-NLS-1$
initializedProperties.put("os.encoding", osEncoding); //$NON-NLS-1$
}
/*[PR The launcher apparently needs sun.jnu.encoding property or it does not work]*/
systemProperties.put("ibm.system.encoding", platformEncoding); //$NON-NLS-1$
systemProperties.put("sun.jnu.encoding", platformEncoding); //$NON-NLS-1$
systemProperties.put("file.encoding", fileEncoding); //$NON-NLS-1$
systemProperties.put("file.encoding.pkg", "sun.io"); //$NON-NLS-1$ //$NON-NLS-2$
initializedProperties.put("ibm.system.encoding", platformEncoding); //$NON-NLS-1$
initializedProperties.put("sun.jnu.encoding", platformEncoding); //$NON-NLS-1$
initializedProperties.put("file.encoding", fileEncoding); //$NON-NLS-1$
initializedProperties.put("file.encoding.pkg", "sun.io"); //$NON-NLS-1$ //$NON-NLS-2$
/*[IF !Java12]*/
/* System property java.specification.vendor is set via VersionProps.init(systemProperties) since JDK12 */
systemProperties.put("java.specification.vendor", "Oracle Corporation"); //$NON-NLS-1$ //$NON-NLS-2$
initializedProperties.put("java.specification.vendor", "Oracle Corporation"); //$NON-NLS-1$ //$NON-NLS-2$
/*[ENDIF] !Java12 */
systemProperties.put("java.specification.name", "Java Platform API Specification"); //$NON-NLS-1$ //$NON-NLS-2$
systemProperties.put("com.ibm.oti.configuration", "scar"); //$NON-NLS-1$
initializedProperties.put("java.specification.name", "Java Platform API Specification"); //$NON-NLS-1$ //$NON-NLS-2$
initializedProperties.put("com.ibm.oti.configuration", "scar"); //$NON-NLS-1$

String[] list = getPropertyList();
for (int i = 0; i < list.length; i += 2) {
Expand All @@ -392,44 +390,84 @@ private static void ensureProperties() {
if (key == null) {
break;
}
systemProperties.put(key, list[i+1]);
initializedProperties.put(key, list[i+1]);
}

propertiesInitialized = true;

/*[IF Java12]*/
/* java.lang.VersionProps.init() eventually calls into System.setProperty() where propertiesInitialized needs to be true */
java.lang.VersionProps.init(systemProperties);
propertiesInitialized = true;

/*[IF Java12]*/
java.lang.VersionProps.init(initializedProperties);
/* VersionProps.init(systemProperties) above sets java.specification.version value which is used to set java.vm.specification.version. */
systemProperties.put("java.vm.specification.version", systemProperties.getProperty("java.specification.version")); //$NON-NLS-1$ //$NON-NLS-2$
systemProperties.put("java.vm.vendor", systemProperties.getProperty("java.vendor")); //$NON-NLS-1$ //$NON-NLS-2$
/*[ELSE]
/*[IF Sidecar19-SE]*/
/* java.lang.VersionProps.init() eventually calls into System.setProperty() where propertiesInitialized needs to be true */
initializedProperties.put("java.vm.specification.version", initializedProperties.get("java.specification.version")); //$NON-NLS-1$ //$NON-NLS-2$
initializedProperties.put("java.vm.vendor", initializedProperties.get("java.vendor")); //$NON-NLS-1$ //$NON-NLS-2$
/*[ELSE]
/* VersionProps.init requires systemProperties to be set */
systemProperties = initializedProperties;

/*[IF Sidecar19-SE]*/
java.lang.VersionProps.init();
/*[ELSE]*/
/*[ELSE]
sun.misc.Version.init();
/*[ENDIF] Sidecar19-SE */
/*[ENDIF] Java12 */

/*[IF !Sidecar19-SE]*/
StringBuffer.initFromSystemProperties(systemProperties);
StringBuilder.initFromSystemProperties(systemProperties);
/*[ENDIF]*/
/*[ENDIF] Sidecar19-SE */
/*[ENDIF] Java12 */

String javaRuntimeVersion = systemProperties.getProperty("java.runtime.version"); //$NON-NLS-1$
/*[IF Java12]*/
String javaRuntimeVersion = initializedProperties.get("java.runtime.version"); //$NON-NLS-1$
/*[ELSE]
String javaRuntimeVersion = initializedProperties.getProperty("java.runtime.version"); //$NON-NLS-1$
/*[ENDIF] Java12 */
if (null != javaRuntimeVersion) {
String fullVersion = systemProperties.getProperty("java.fullversion"); //$NON-NLS-1$
/*[IF Java12]*/
String fullVersion = initializedProperties.get("java.fullversion"); //$NON-NLS-1$
/*[ELSE]
String fullVersion = initializedProperties.getProperty("java.fullversion"); //$NON-NLS-1$
/*[ENDIF] Java12 */
if (null != fullVersion) {
systemProperties.put("java.fullversion", (javaRuntimeVersion + "\n" + fullVersion)); //$NON-NLS-1$ //$NON-NLS-2$
initializedProperties.put("java.fullversion", (javaRuntimeVersion + "\n" + fullVersion)); //$NON-NLS-1$ //$NON-NLS-2$
}
rasInitializeVersion(javaRuntimeVersion);
}

lineSeparator = systemProperties.getProperty("line.separator", "\n"); //$NON-NLS-1$
/*[IF Java12]*/
lineSeparator = initializedProperties.getOrDefault("line.separator", "\n"); //$NON-NLS-1$
/*[ELSE]
lineSeparator = initializedProperties.getProperty("line.separator", "\n"); //$NON-NLS-1$
/*[ENDIF] Java12 */
/*[IF Sidecar19-SE]*/
useLegacyVerPresents = systemProperties.containsKey("use.legacy.version");
useLegacyVerPresents = initializedProperties.containsKey("use.legacy.version");
/*[ENDIF]*/

if (isInitialization) {
/*[PR CMVC 179976] System.setProperties(null) throws IllegalStateException */
/*[IF Java12]*/
VM.saveProperties(initializedProperties);
/*[ELSE]
VM.saveAndRemoveProperties(initializedProperties);
/*[ENDIF] Java12 */
}

/* create systemProperties from properties Map */
/*[IF Java12]*/
initializeSystemProperties(initializedProperties);
/*[ELSE]
systemProperties = initializedProperties;
/*[ENDIF] Java12 */
}

/* Converts a Map<String, String> to a properties object.
*
* The sytem properties will be initialized as a Map<String, String> type to be compatible
* with jdk.internal.misc.VM and java.lang.VersionProps APIs.
*/
private static void initializeSystemProperties(Map<String, String> mapProperties) {
systemProperties = new Properties();
for (Map.Entry<String, String> property : mapProperties.entrySet()) {
systemProperties.put(property.getKey(), property.getValue());
}
}

private static native void rasInitializeVersion(String javaRuntimeVersion);
Expand Down Expand Up @@ -731,7 +769,7 @@ public static void setProperties(Properties p) {
if (security != null)
security.checkPropertiesAccess();
if (p == null) {
ensureProperties();
ensureProperties(false);
} else {
systemProperties = p;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*[INCLUDE-IF Java12]*/
/*******************************************************************************
* Copyright (c) 2018, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be madpe available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package java.lang.invoke;

/*
* Pseudocode example:
* handle: D original(A, B, C)
* filterPosition: 1
* preprocessor: B filter(B, A)
* argumentIndices: {1, 0}
*
* resulting handle:
* D result(A a, B b, C c) {
* B e = filter(b, a)
* return original(a, e, c)
* }
*/
final class FilterArgumentsWithCombinerHandle extends MethodHandle {
protected final MethodHandle next;
protected final MethodHandle combiner;
private final int filterPosition;
private final int[] argumentIndices;

FilterArgumentsWithCombinerHandle(MethodHandle next, int filterPosition, MethodHandle combiner, int... argumentIndices) {
super(next.type, KIND_FILTERARGUMENTS_WITHCOMBINER, infoAffectingThunks(combiner.type(), filterPosition, argumentIndices));
this.next = next;
this.combiner = combiner;
this.filterPosition = filterPosition;
this.argumentIndices = argumentIndices;
}

FilterArgumentsWithCombinerHandle(FilterArgumentsWithCombinerHandle originalHandle, MethodType newType) {
super(originalHandle, newType);
this.next = originalHandle.next;
this.combiner = originalHandle.combiner;
this.filterPosition = originalHandle.filterPosition;
this.argumentIndices = originalHandle.argumentIndices;
}

static FilterArgumentsWithCombinerHandle get(MethodHandle next, int filterPosition, MethodHandle combiner, int... argumentIndices) {
return new FilterArgumentsWithCombinerHandle(next, filterPosition, combiner, argumentIndices);
}

@Override
MethodHandle cloneWithNewType(MethodType newType) {
return new FilterArgumentsWithCombinerHandle(this, newType);
}

private static Object[] infoAffectingThunks(MethodType combinerType, int filterPosition, int...argumentIndices) {
MethodType thunkableType = ThunkKey.computeThunkableType(combinerType);
Object[] result = {thunkableType, filterPosition, argumentIndices};
return result;
}

private static final ThunkTable _thunkTable = new ThunkTable();
@Override
protected ThunkTable thunkTable(){ return _thunkTable; }

@Override
protected final ThunkTuple computeThunks(Object info) {
return thunkTable().get(new ThunkKeyWithObjectArray(ThunkKey.computeThunkableType(type()), (Object[])info));
}

private static native int filterPosition();
private static native int argumentIndices();
/* create placeholder for combiner based on argumentIndices the original handle's arguments */
private static native int argumentsForCombiner(int indice, int argPlaceholder);
/* number of arguments remaining after the filtered argument */
private static native int numSuffixArgs();

@FrameIteratorSkip
private final int invokeExact_thunkArchetype_X(int argPlaceholder) {
if (ILGenMacros.isShareableThunk()) {
undoCustomizationLogic(combiner, next);
}
if (!ILGenMacros.isCustomThunk()) {
doCustomizationLogic();
}

return ILGenMacros.invokeExact_X(next, ILGenMacros.placeholder(
ILGenMacros.firstN(filterPosition(), argPlaceholder),
ILGenMacros.invokeExact(combiner, argumentsForCombiner(argumentIndices(), argPlaceholder)),
ILGenMacros.lastN(numSuffixArgs(), argPlaceholder)));
}

@Override
final void compareWith(MethodHandle right, Comparator c) {
if (right instanceof FilterArgumentsWithCombinerHandle) {
((FilterArgumentsWithCombinerHandle)right).compareWithFilterArgumentsWithCombiner(this, c);
} else {
c.fail();
}
}

final void compareWithFilterArgumentsWithCombiner(FilterArgumentsWithCombinerHandle left, Comparator c) {
c.compareChildHandle(left.next, this.next);
c.compareChildHandle(left.combiner, this.combiner);
c.compareStructuralParameter(left.filterPosition, this.filterPosition);
c.compareStructuralParameter(left.argumentIndices, this.argumentIndices);
}
}
Loading