Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <j9build@ca.ibm.com>
  • Loading branch information
j9build committed Sep 17, 2024
2 parents d8ff203 + 179f008 commit 48a49a1
Show file tree
Hide file tree
Showing 28 changed files with 1,468 additions and 72 deletions.
2 changes: 1 addition & 1 deletion make/common/modules/LauncherCommon.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ define SetupBuildLauncherBody
endif

ifneq ($$($1_MAIN_CLASS), )
$1_JAVA_ARGS += -ms8m
$1_JAVA_ARGS += -Xms8m
$1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
endif

Expand Down
16 changes: 10 additions & 6 deletions make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,10 @@ private static Map<String, Object> extractZoneNames(Map<String, Object> map, Str
String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid))
.orElse(tzid);
// Follow link, if needed
var tzLink = tzdbLinks.get(tzKey);
String tzLink = null;
for (var k = tzKey; tzdbLinks.containsKey(k);) {
k = tzLink = tzdbLinks.get(k);
}
if (tzLink == null && tzdbLinks.containsValue(tzKey)) {
// reverse link search
// this is needed as in tzdb, "America/Buenos_Aires" links to
Expand Down Expand Up @@ -1214,7 +1217,7 @@ private static void generateZoneName() throws Exception {
private static Set<String> getAvailableZoneIds() {
assert handlerMetaZones != null;
if (AVAILABLE_TZIDS == null) {
AVAILABLE_TZIDS = new HashSet<>(ZoneId.getAvailableZoneIds());
AVAILABLE_TZIDS = new HashSet<>(Arrays.asList(TimeZone.getAvailableIDs()));
AVAILABLE_TZIDS.addAll(handlerMetaZones.keySet());
AVAILABLE_TZIDS.remove(MetaZonesParseHandler.NO_METAZONE_KEY);
}
Expand Down Expand Up @@ -1490,13 +1493,14 @@ private static void fillTZDBShortNames(String tzid, String[] names) {
/*
* Convert TZDB offsets to JDK's offsets, eg, "-08" to "GMT-08:00".
* If it cannot recognize the pattern, return the argument as is.
* Returning null results in generating the GMT format at runtime.
*/
private static String convertGMTName(String f) {
try {
// Should pre-fill GMT format once COMPAT is gone.
// Till then, fall back to GMT format at runtime, after COMPAT short
// names are populated
ZoneOffset.of(f);
if (!f.equals("%z")) {
// Validate if the format is an offset
ZoneOffset.of(f);
}
return null;
} catch (DateTimeException dte) {
// textual representation. return as is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
import java.lang.classfile.constantpool.ConstantPoolBuilder;
import java.lang.classfile.constantpool.MethodRefEntry;
import static java.lang.constant.ConstantDescs.*;
import static java.lang.invoke.MethodHandleNatives.Constants.NESTMATE_CLASS;
import static java.lang.invoke.MethodHandleNatives.Constants.STRONG_LOADER_LINK;
import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE;
import static java.lang.invoke.MethodHandles.Lookup.ClassOption.STRONG;
import static java.lang.invoke.MethodType.methodType;
Expand Down Expand Up @@ -348,7 +350,7 @@ else if (finalAccidentallySerializable)
try {
// this class is linked at the indy callsite; so define a hidden nestmate
var classdata = useImplMethodHandle? implementation : null;
return caller.makeHiddenClassDefiner(lambdaClassName, classBytes, Set.of(NESTMATE, STRONG), lambdaProxyClassFileDumper)
return caller.makeHiddenClassDefiner(lambdaClassName, classBytes, lambdaProxyClassFileDumper, NESTMATE_CLASS | STRONG_LOADER_LINK)
.defineClass(!disableEagerInitialization, classdata);

} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Stream;
import jdk.internal.constant.MethodTypeDescImpl;
Expand Down Expand Up @@ -224,7 +223,7 @@ FieldRefEntry classData(ClassFileBuilder<?, ?> cfb, Object arg, ClassDesc desc)
* Extract the MemberName of a newly-defined method.
*/
private MemberName loadMethod(byte[] classFile) {
Class<?> invokerClass = LOOKUP.makeHiddenClassDefiner(className, classFile, Set.of(), dumper())
Class<?> invokerClass = LOOKUP.makeHiddenClassDefiner(className, classFile, dumper())
.defineClass(true, classDataValues());
return resolveInvokerMember(invokerClass, invokerName, invokerType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodHandleNatives.Constants.MN_CALLER_SENSITIVE;
import static java.lang.invoke.MethodHandleNatives.Constants.MN_HIDDEN_MEMBER;
import static java.lang.invoke.MethodHandleNatives.Constants.NESTMATE_CLASS;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE;
Expand Down Expand Up @@ -1117,7 +1118,7 @@ private static Class<?> makeInjectedInvoker(Class<?> targetClass) {
}
name = name.replace('.', '/');
Class<?> invokerClass = new Lookup(targetClass)
.makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE, Set.of(NESTMATE), dumper())
.makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE, dumper(), NESTMATE_CLASS)
.defineClass(true, targetClass);
assert checkInjectedInvoker(targetClass, invokerClass);
return invokerClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private static Class<?> newProxyClass(Class<?> intfc) {
byte[] template = createTemplate(loader, binaryNameToDesc(className),
referenceClassDesc(intfc), uniqueName, methods);
// define the dynamic module to the class loader of the interface
var definer = new Lookup(intfc).makeHiddenClassDefiner(className, template, Set.of(), DUMPER);
var definer = new Lookup(intfc).makeHiddenClassDefiner(className, template, DUMPER);

@SuppressWarnings("removal")
var sm = System.getSecurityManager();
Expand Down
54 changes: 36 additions & 18 deletions src/java.base/share/classes/java/lang/invoke/MethodHandles.java
Original file line number Diff line number Diff line change
Expand Up @@ -1912,9 +1912,12 @@ public enum ClassOption {
this.flag = flag;
}

static int optionsToFlag(Set<ClassOption> options) {
static int optionsToFlag(ClassOption[] options) {
int flags = 0;
for (ClassOption cp : options) {
if ((flags & cp.flag) != 0) {
throw new IllegalArgumentException("Duplicate ClassOption " + cp);
}
flags |= cp.flag;
}
return flags;
Expand Down Expand Up @@ -2132,14 +2135,13 @@ public Lookup defineHiddenClass(byte[] bytes, boolean initialize, ClassOption...
throws IllegalAccessException
{
Objects.requireNonNull(bytes);
Objects.requireNonNull(options);

int flags = ClassOption.optionsToFlag(options);
ensureDefineClassPermission();
if (!hasFullPrivilegeAccess()) {
throw new IllegalAccessException(this + " does not have full privilege access");
}

return makeHiddenClassDefiner(bytes.clone(), Set.of(options), false).defineClassAsLookup(initialize);
return makeHiddenClassDefiner(bytes.clone(), false, flags).defineClassAsLookup(initialize);
}

/**
Expand Down Expand Up @@ -2219,14 +2221,15 @@ public Lookup defineHiddenClassWithClassData(byte[] bytes, Object classData, boo
{
Objects.requireNonNull(bytes);
Objects.requireNonNull(classData);
Objects.requireNonNull(options);

int flags = ClassOption.optionsToFlag(options);

ensureDefineClassPermission();
if (!hasFullPrivilegeAccess()) {
throw new IllegalAccessException(this + " does not have full privilege access");
}

return makeHiddenClassDefiner(bytes.clone(), Set.of(options), false)
return makeHiddenClassDefiner(bytes.clone(), false, flags)
.defineClassAsLookup(initialize, classData);
}

Expand Down Expand Up @@ -2372,7 +2375,7 @@ ClassDefiner makeClassDefiner(String name, byte[] bytes, ClassFileDumper dumper)
*/
ClassDefiner makeHiddenClassDefiner(byte[] bytes, ClassFileDumper dumper) {
ClassFile cf = ClassFile.newInstance(bytes, lookupClass().getPackageName());
return makeHiddenClassDefiner(cf, Set.of(), false, dumper);
return makeHiddenClassDefiner(cf, false, dumper, 0);
}

/**
Expand All @@ -2384,18 +2387,33 @@ ClassDefiner makeHiddenClassDefiner(byte[] bytes, ClassFileDumper dumper) {
* before calling this factory method.
*
* @param bytes class bytes
* @param options class options
* @param flags class option flag mask
* @param accessVmAnnotations true to give the hidden class access to VM annotations
* @return ClassDefiner that defines a hidden class of the given bytes and options
*
* @throws IllegalArgumentException if {@code bytes} is not a class or interface or
* {@code bytes} denotes a class in a different package than the lookup class
*/
private ClassDefiner makeHiddenClassDefiner(byte[] bytes,
Set<ClassOption> options,
boolean accessVmAnnotations) {
boolean accessVmAnnotations,
int flags) {
ClassFile cf = ClassFile.newInstance(bytes, lookupClass().getPackageName());
return makeHiddenClassDefiner(cf, options, accessVmAnnotations, defaultDumper());
return makeHiddenClassDefiner(cf, accessVmAnnotations, defaultDumper(), flags);
}

/**
* Returns a ClassDefiner that creates a {@code Class} object of a hidden class
* from the given bytes and the given options. No package name check on the given bytes.
*
* @param name internal name that specifies the prefix of the hidden class
* @param bytes class bytes
* @param dumper dumper to write the given bytes to the dumper's output directory
* @return ClassDefiner that defines a hidden class of the given bytes and options.
*/
ClassDefiner makeHiddenClassDefiner(String name, byte[] bytes, ClassFileDumper dumper) {
Objects.requireNonNull(dumper);
// skip name and access flags validation
return makeHiddenClassDefiner(ClassFile.newInstanceNoCheck(name, bytes), false, dumper, 0);
}

/**
Expand All @@ -2404,30 +2422,30 @@ private ClassDefiner makeHiddenClassDefiner(byte[] bytes,
*
* @param name internal name that specifies the prefix of the hidden class
* @param bytes class bytes
* @param options class options
* @param flags class options flag mask
* @param dumper dumper to write the given bytes to the dumper's output directory
* @return ClassDefiner that defines a hidden class of the given bytes and options.
*/
ClassDefiner makeHiddenClassDefiner(String name, byte[] bytes, Set<ClassOption> options, ClassFileDumper dumper) {
ClassDefiner makeHiddenClassDefiner(String name, byte[] bytes, ClassFileDumper dumper, int flags) {
Objects.requireNonNull(dumper);
// skip name and access flags validation
return makeHiddenClassDefiner(ClassFile.newInstanceNoCheck(name, bytes), options, false, dumper);
return makeHiddenClassDefiner(ClassFile.newInstanceNoCheck(name, bytes), false, dumper, flags);
}

/**
* Returns a ClassDefiner that creates a {@code Class} object of a hidden class
* from the given class file and options.
*
* @param cf ClassFile
* @param options class options
* @param flags class option flag mask
* @param accessVmAnnotations true to give the hidden class access to VM annotations
* @param dumper dumper to write the given bytes to the dumper's output directory
*/
private ClassDefiner makeHiddenClassDefiner(ClassFile cf,
Set<ClassOption> options,
boolean accessVmAnnotations,
ClassFileDumper dumper) {
int flags = HIDDEN_CLASS | ClassOption.optionsToFlag(options);
ClassFileDumper dumper,
int flags) {
flags |= HIDDEN_CLASS;
if (accessVmAnnotations | VM.isSystemDomainLoader(lookupClass.getClassLoader())) {
// jdk.internal.vm.annotations are permitted for classes
// defined to boot loader and platform loader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.lang.ref.SoftReference;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
Expand Down Expand Up @@ -1353,7 +1352,7 @@ public void accept(MethodBuilder mb) {
}
}});
try {
var hiddenClass = lookup.makeHiddenClassDefiner(CLASS_NAME, classBytes, Set.of(), DUMPER)
var hiddenClass = lookup.makeHiddenClassDefiner(CLASS_NAME, classBytes, DUMPER)
.defineClass(true, null);

if (staticConcat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ java.launcher.X.usage=\n\
\ -Xcomp forces compilation of methods on first invocation\n\
\ -Xdebug does nothing; deprecated for removal in a future release.\n\
\ -Xdiag show additional diagnostic messages\n\
\ -Xfuture enable strictest checks, anticipating future default.\n\
\ This option is deprecated and may be removed in a\n\
\ future release.\n\
\ -Xint interpreted mode execution only\n\
\ -Xinternalversion\n\
\ displays more detailed JVM version information than the\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ private boolean regionFormatFallback(String[] names, int index, Locale l) {
}

private String toGMTFormat(String id, boolean daylight, Locale l) {
var zr = ZoneInfoFile.getZoneInfo(id).toZoneId().getRules();
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
ResourceBundle fd = lr.getJavaTimeFormatData();
var zi = ZoneInfoFile.getZoneInfo(id);
if (zi == null) {
return fd.getString("timezone.gmtZeroFormat");
}
var zr = zi.toZoneId().getRules();
var now = Instant.now();
var saving = zr.getTransitions().reversed().stream()
.dropWhile(zot -> zot.getInstant().isAfter(now))
Expand All @@ -276,8 +282,6 @@ private String toGMTFormat(String id, boolean daylight, Locale l) {
.orElse(0);
int offset = (zr.getStandardOffset(now).getTotalSeconds() +
(daylight ? saving : 0)) / 60;
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
ResourceBundle fd = lr.getJavaTimeFormatData();

if (offset == 0) {
return fd.getString("timezone.gmtZeroFormat");
Expand Down
16 changes: 10 additions & 6 deletions src/java.base/share/man/java.1
Original file line number Diff line number Diff line change
Expand Up @@ -3749,12 +3749,6 @@ future JDK release.
They\[aq]re still accepted and acted upon, but a warning is issued when
they\[aq]re used.
.TP
\f[V]-Xfuture\f[R]
Enables strict class-file format checks that enforce close conformance
to the class-file format specification.
Developers should use this flag when developing new code.
Stricter checks may become the default in future releases.
.TP
\f[V]-Xloggc:\f[R]\f[I]filename\f[R]
Sets the file to which verbose GC events information should be
redirected for logging.
Expand Down Expand Up @@ -3920,6 +3914,16 @@ of objects reachable from the old generation space into the young
generation space.
To disable GC of the young generation before each full GC, specify the
option \f[V]-XX:-ScavengeBeforeFullGC\f[R].
.TP
\f[V]-Xfuture\f[R]
Enables strict class-file format checks that enforce close conformance
to the class-file format specification.
Developers should use this flag when developing new code.
Stricter checks may become the default in future releases.
.RS
.PP
Use the option \f[V]-Xverify:all\f[R] instead.
.RE
.PP
For the lists and descriptions of options removed in previous releases
see the \f[I]Removed Java Options\f[R] section in:
Expand Down
14 changes: 1 addition & 13 deletions src/java.base/share/native/libjli/java.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2024, 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
Expand Down Expand Up @@ -1544,17 +1544,10 @@ ParseArguments(int *pargc, char ***pargv,
return JNI_FALSE;
} else if (JLI_StrCmp(arg, "-verbosegc") == 0) {
AddOption("-verbose:gc", NULL);
} else if (JLI_StrCmp(arg, "-t") == 0) {
AddOption("-Xt", NULL);
} else if (JLI_StrCmp(arg, "-tm") == 0) {
AddOption("-Xtm", NULL);
} else if (JLI_StrCmp(arg, "-debug") == 0) {
JLI_ReportErrorMessage(ARG_DEPRECATED, "-debug");
} else if (JLI_StrCmp(arg, "-noclassgc") == 0) {
AddOption("-Xnoclassgc", NULL);
} else if (JLI_StrCmp(arg, "-Xfuture") == 0) {
JLI_ReportErrorMessage(ARG_DEPRECATED, "-Xfuture");
AddOption("-Xverify:all", NULL);
} else if (JLI_StrCmp(arg, "-verify") == 0) {
AddOption("-Xverify:all", NULL);
} else if (JLI_StrCmp(arg, "-verifyremote") == 0) {
Expand All @@ -1573,11 +1566,6 @@ ParseArguments(int *pargc, char ***pargv,
char *tmp = JLI_MemAlloc(tmpSize);
snprintf(tmp, tmpSize, "-X%s", arg + 1); /* skip '-' */
AddOption(tmp, NULL);
} else if (JLI_StrCmp(arg, "-checksource") == 0 ||
JLI_StrCmp(arg, "-cs") == 0 ||
JLI_StrCmp(arg, "-noasyncgc") == 0) {
/* No longer supported */
JLI_ReportErrorMessage(ARG_WARN, arg);
} else if (JLI_StrCCmp(arg, "-splash:") == 0) {
; /* Ignore machine independent options already handled */
} else if (JLI_StrCmp(arg, "--disable-@files") == 0) {
Expand Down
11 changes: 7 additions & 4 deletions src/java.base/unix/native/libjava/java_props_md.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024, 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
Expand Down Expand Up @@ -521,11 +521,14 @@ GetJavaProperties(JNIEnv *env)
{
char buf[MAXPATHLEN];
errno = 0;
if (getcwd(buf, sizeof(buf)) == NULL)
if (getcwd(buf, sizeof(buf)) == NULL) {
JNU_ThrowByName(env, "java/lang/Error",
"Properties init: Could not determine current working directory.");
else
"Properties init: Could not determine current working directory.");
return NULL;
}
else {
sprops.user_dir = strdup(buf);
}
}

sprops.file_separator = "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@

/**
* This doclet generates HTML-formatted documentation for the specified modules,
* packages and types.
* packages and types. It is the doclet that is used by the
* <a href="{@docRoot}/../specs/man/javadoc.html"><em>javadoc</em></a> tool
* and the {@linkplain javax.tools.ToolProvider#getSystemDocumentationTool
* system documentation tool} when no other doclet is specified to be used.
*
* <h2><a id="user-defined-taglets">User-Defined Taglets</a></h2>
*
Expand Down
Loading

0 comments on commit 48a49a1

Please sign in to comment.