This commit is contained in:
Jesper Wilhelmsson 2022-06-27 18:25:53 +00:00
commit d4b040f42d
24 changed files with 325 additions and 92 deletions
src
hotspot
java.base/share/classes/jdk/internal/jimage
java.desktop/share/classes
java/awt/doc-files
javax
imageio/plugins/tiff
swing/plaf
java.xml/share/classes/com/sun/org/apache/xerces/internal/dom
jdk.compiler/share/classes/com/sun/tools/javac/comp
jdk.httpserver/share/classes/com/sun/net/httpserver
test
hotspot/jtreg
ProblemList.txt
compiler/c1
runtime/classFileParserBug
serviceability/jvmti/vthread/GetSetLocalTest
jaxp/javax/xml/jaxp/unittest/dom
jdk
langtools/tools/javac/patterns

@ -1478,6 +1478,9 @@ void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, L
__ mov_double(result->as_double_reg(), c->as_jdouble(), acond);
#endif // __SOFTFP__
break;
case T_METADATA:
__ mov_metadata(result->as_register(), c->as_metadata(), acond);
break;
default:
ShouldNotReachHere();
}

@ -2439,7 +2439,7 @@ class LIR_OpVisitState: public StackObj {
typedef enum { inputMode, firstMode = inputMode, tempMode, outputMode, numModes, invalidMode = -1 } OprMode;
enum {
maxNumberOfOperands = 20,
maxNumberOfOperands = 21,
maxNumberOfInfos = 4
};

@ -611,7 +611,7 @@ void VM_BaseGetOrSetLocal::doit() {
frame fr = _jvf->fr();
if (_set && _depth != 0 && Continuation::is_frame_in_continuation(_jvf->thread(), fr)) {
_result = JVMTI_ERROR_OPAQUE_FRAME; // deferred locals currently unsupported in continuations
_result = JVMTI_ERROR_OPAQUE_FRAME; // deferred locals are not fully supported in continuations
return;
}
@ -644,6 +644,17 @@ void VM_BaseGetOrSetLocal::doit() {
return;
}
if (_set) {
if (fr.is_heap_frame()) { // we want this check after the check for JVMTI_ERROR_INVALID_SLOT
assert(Continuation::is_frame_in_continuation(_jvf->thread(), fr), "sanity check");
// If the topmost frame is a heap frame, then it hasn't been thawed. This can happen
// if we are executing at a return barrier safepoint. The callee frame has been popped,
// but the caller frame has not been thawed. We can't support a JVMTI SetLocal in the callee
// frame at this point, because we aren't truly in the callee yet.
// fr.is_heap_frame() is impossible if a continuation is at a single step or breakpoint.
_result = JVMTI_ERROR_OPAQUE_FRAME; // deferred locals are not fully supported in continuations
return;
}
// Force deoptimization of frame if compiled because it's
// possible the compiler emitted some locals as constant values,
// meaning they are not mutable.

@ -458,7 +458,11 @@ public final class ImageReader implements AutoCloseable {
makeDirectories(path);
} else { // a resource
makeDirectories(childloc.buildName(true, true, false));
newResource(dir, childloc);
// if we have already created a resource for this name previously, then don't
// recreate it
if (!nodes.containsKey(childloc.getFullName(true))) {
newResource(dir, childloc);
}
}
});
dir.setCompleted(true);
@ -753,6 +757,7 @@ public final class ImageReader implements AutoCloseable {
}
void addChild(Node node) {
assert !children.contains(node) : "Child " + node + " already added";
children.add(node);
}

@ -5,7 +5,7 @@
<title>AWT Threading Issues</title>
</head>
<!--
Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2002, 2022, 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
@ -118,11 +118,7 @@ The implementation-specific details are given below.
Implementation-dependent behavior.
</h3>
Prior to 1.4, the helper threads were never terminated.
<p>
Starting with 1.4, the behavior has changed as a result of the fix for
<a href="https://bugs.java.com/view_bug.do?bug_id=4030718">
4030718</a>. With the current implementation, AWT terminates all its
AWT terminates all its
helper threads allowing the application to exit cleanly when the
following three conditions are true:
<ul>
@ -153,13 +149,7 @@ exit cleanly under normal conditions, it is not guaranteed that it
will exit cleanly in all cases. Two examples:
<ul>
<li> Other packages can create displayable components for internal
needs and never make them undisplayable. See
<a href="https://bugs.java.com/view_bug.do?bug_id=4515058">
4515058</a>,
<a href="https://bugs.java.com/view_bug.do?bug_id=4671025">
4671025</a>, and
<a href="https://bugs.java.com/view_bug.do?bug_id=4465537">
4465537</a>.
needs and never make them undisplayable.
<li> Both Microsoft Windows and X11 allow an application to send native
events to windows that belong to another application. With this
feature it is possible to write a malicious program that will

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
@ -32,8 +32,8 @@ import java.util.List;
* A class representing the tags found in an Exif IFD. Exif is a
* standard for annotating images used by most digital camera
* manufacturers. The Exif specification may be found at
* <a href="http://www.exif.org/Exif2-2.PDF">
* {@code http://www.exif.org/Exif2-2.PDF}
* <a href="https://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf">
* {@code https://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf}
* </a>.
*
* <p> The definitions of the data types referenced by the field

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, 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
@ -2140,8 +2140,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
/**
* Returns a {@code LayoutStyle} implementing the Java look and feel
* design guidelines as specified at
* <a href="http://www.oracle.com/technetwork/java/hig-136467.html">http://www.oracle.com/technetwork/java/hig-136467.html</a>.
* design guidelines.
*
* @return LayoutStyle implementing the Java look and feel design
* guidelines

@ -5,7 +5,7 @@
<title>Using the Multiplexing Look and Feel</title>
</head>
<!--
Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 1998, 2022, 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
@ -33,19 +33,6 @@
<main role="main">
<h1>Using the Multiplexing Look and Feel</h1>
<blockquote>
<hr>
<p>
<i>
This document is based on an article
originally published in
<a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html"
target="_top"><em>The Swing Connection</em></a>.
</i>
</p>
<hr>
</blockquote>
<p>
The Multiplexing look and feel lets
you supplement an ordinary look and feel

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -39,7 +39,7 @@ import org.w3c.dom.Node;
*
* @xerces.internal
*
* @LastModified: Oct 2017
* @LastModified: June 2022
*/
public class AttributeMap extends NamedNodeMapImpl {
@ -117,7 +117,7 @@ public class AttributeMap extends NamedNodeMapImpl {
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new ArrayList<>(5);
nodes = new ArrayList<>();
}
nodes.add(i, arg);
}
@ -193,7 +193,7 @@ public class AttributeMap extends NamedNodeMapImpl {
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new ArrayList<>(5);
nodes = new ArrayList<>();
}
nodes.add(i, arg);
}
@ -591,7 +591,7 @@ public class AttributeMap extends NamedNodeMapImpl {
else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new ArrayList<>(5);
nodes = new ArrayList<>();
}
nodes.add(i, arg);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -89,7 +89,7 @@ import org.w3c.dom.Text;
*
* @author Elena Litani, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @LastModified: Apr 2019
* @LastModified: June 2022
*/
public class DOMNormalizer implements XMLDocumentHandler {
@ -140,9 +140,6 @@ public class DOMNormalizer implements XMLDocumentHandler {
/** Stores all namespace bindings on the current element */
protected final NamespaceContext fLocalNSBinder = new NamespaceSupport();
/** list of attributes */
protected final List<Node> fAttributeList = new ArrayList<>(5);
/** DOM Locator - for namespace fixup algorithm */
protected final DOMLocatorImpl fLocator = new DOMLocatorImpl();
@ -885,9 +882,9 @@ public class DOMNormalizer implements XMLDocumentHandler {
if (attributes != null) {
// clone content of the attributes
attributes.cloneMap(fAttributeList);
for (int i = 0; i < fAttributeList.size(); i++) {
Attr attr = (Attr) fAttributeList.get(i);
List<Node> attrList = attributes.cloneMap(new ArrayList<>());
for (int i = 0; i < attrList.size(); i++) {
Attr attr = (Attr) attrList.get(i);
fLocator.fRelatedNode = attr;
if (DEBUG) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -56,7 +56,7 @@ import org.w3c.dom.Node;
* @xerces.internal
*
* @since PR-DOM-Level-1-19980818.
* @LastModified: Jan 2018
* @LastModified: June 2022
*/
public class NamedNodeMapImpl
implements NamedNodeMap, Serializable {
@ -197,7 +197,7 @@ public class NamedNodeMapImpl
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new ArrayList<>(5);
nodes = new ArrayList<>();
}
nodes.add(i, arg);
}
@ -247,7 +247,7 @@ public class NamedNodeMapImpl
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new ArrayList<>(5);
nodes = new ArrayList<>();
}
nodes.add(i, arg);
}
@ -562,7 +562,7 @@ public class NamedNodeMapImpl
else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new ArrayList<>(5);
nodes = new ArrayList<>();
}
nodes.add(i, arg);
}

@ -97,6 +97,7 @@ import com.sun.tools.javac.tree.JCTree.JCSwitchExpression;
import com.sun.tools.javac.tree.JCTree.LetExpr;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.List;
/**
@ -284,7 +285,7 @@ public class TransPatterns extends TreeTranslator {
names.fromString(target.syntheticNameChar() + "c" + target.syntheticNameChar() + component.name),
component.erasure(types),
currentMethodSym);
Symbol accessor = getAccessor(component);
Symbol accessor = getAccessor(tree.pos(), component);
JCVariableDecl nestedTempVar =
make.VarDef(nestedTemp,
make.App(make.QualIdent(accessor),
@ -344,12 +345,8 @@ public class TransPatterns extends TreeTranslator {
result = test != null ? test : makeLit(syms.booleanType, 1);
}
private MethodSymbol getAccessor(RecordComponent component) {
private MethodSymbol getAccessor(DiagnosticPosition pos, RecordComponent component) {
return component2Proxy.computeIfAbsent(component, c -> {
MethodSymbol realAccessor = (MethodSymbol) component.owner
.members()
.findFirst(component.name, s -> s.kind == Kind.MTH &&
((MethodSymbol) s).params.isEmpty());
MethodType type = new MethodType(List.of(component.owner.erasure(types)),
types.erasure(component.type),
List.nil(),
@ -359,7 +356,7 @@ public class TransPatterns extends TreeTranslator {
type,
currentClass);
JCStatement accessorStatement =
make.Return(make.App(make.Select(make.Ident(proxy.params().head), realAccessor)));
make.Return(make.App(make.Select(make.Ident(proxy.params().head), c.accessor)));
VarSymbol ctch = new VarSymbol(Flags.SYNTHETIC,
names.fromString("catch" + currentClassTree.pos + target.syntheticNameChar()),
syms.throwableType,

@ -42,8 +42,7 @@ import sun.net.httpserver.simpleserver.OutputFilter;
* A simple HTTP file server and its components (intended for testing,
* development and debugging purposes only).
*
* <p> A <a href="#server-impl">simple file server</a> is composed of three
* components:
* <p> A simple file server is composed of three components:
* <ul>
* <li> an {@link HttpServer HttpServer} that is bound to a given address, </li>
* <li> an {@link HttpHandler HttpHandler} that serves files from a given

@ -111,6 +111,7 @@ serviceability/sa/sadebugd/DebugdConnectTest.java 8239062,8270326 macosx-x64,mac
serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
serviceability/jvmti/vthread/GetSetLocalTest/GetSetLocalTest.java 8286836 generic-all
serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64
serviceability/sa/ClhsdbCDSCore.java 8269982,8267433 macosx-aarch64,macosx-x64

@ -0,0 +1,57 @@
/*
* Copyright (c) 2022 SAP SE. 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.
*
* 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.
*
*/
/**
* @test
* @bug 8288781
* @summary Test if a call with 8 integer + 13 float = 21 parameters can can be compiled.
* On ppc all parameters can be passed in registers.
* @author Richard Reingruber
*
* @run main/othervm -Xbatch -XX:CompileCommand=dontinline,*::*dontinline* compiler.c1.TestManyMethodParameters
*/
package compiler.c1;
public class TestManyMethodParameters {
public static void main(String[] args) {
for (int i = 30_000; i >= 0; i--) {
double sum = testMethod_01_dontinline();
if (sum != 127) {
throw new Error("Wrong sum: " + sum);
}
}
}
public static double testMethod_01_dontinline() {
return testMethod_01_manyArgs(1, 2, 3, 4, 5, 6, 7, 8,
1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, 9.0d, 10.0d, 11.0d, 12.0d, 13.0d);
}
public static double testMethod_01_manyArgs(long l1, long l2, long l3, long l4, long l5, long l6, long l7, long l8,
double d1, double d2, double d3, double d4, double d5, double d6, double d7,
double d8, double d9, double d10, double d11, double d12, double d13) {
return l1+l2+l3+l4+l5+l6+l7+l8+d1+d2+d3+d4+d5+d6+d7+d8+d9+d10+d11+d12+d13;
}
}

@ -21,7 +21,7 @@
* questions.
*/
/*
/**
* @test
* @bug 8288976
* @library /test/lib
@ -31,7 +31,6 @@
* java.management
* @compile C.java
* @run driver Bad_NCDFE_Msg
*/
import java.io.File;
import jdk.test.lib.process.ProcessTools;

@ -35,8 +35,7 @@ import java.util.concurrent.*;
public class GetSetLocalTest {
private static final String agentLib = "GetSetLocalTest";
static final int MSG_COUNT = 600*1000;
static final SynchronousQueue<String> QUEUE = new SynchronousQueue<>();
static SynchronousQueue<String> QUEUE;
static native boolean completed();
static native void enableEvents(Thread thread);
static native void testSuspendedVirtualThreads(Thread thread);
@ -56,19 +55,17 @@ public class GetSetLocalTest {
static final Runnable PRODUCER = () -> {
try {
for (int i = 0; i < MSG_COUNT; i++) {
if (completed()) {
consumer.interrupt();
break;
}
while (!completed()) {
producer("msg: ");
}
} catch (InterruptedException e) { }
consumer.interrupt();
} catch (InterruptedException e) {
}
};
static final Runnable CONSUMER = () -> {
try {
for (int i = 0; i < MSG_COUNT; i++) {
while(true) {
String s = QUEUE.take();
}
} catch (InterruptedException e) {
@ -77,6 +74,7 @@ public class GetSetLocalTest {
};
public static void test1() throws Exception {
QUEUE = new SynchronousQueue<>();
producer = Thread.ofVirtual().name("VThread-Producer").start(PRODUCER);
consumer = Thread.ofVirtual().name("VThread-Consumer").start(CONSUMER);
@ -101,6 +99,10 @@ public class GetSetLocalTest {
}
GetSetLocalTest obj = new GetSetLocalTest();
obj.runTest();
for (int i = 0; i < 200; i++) {
obj.runTest();
}
}
}

@ -232,7 +232,7 @@ test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread,
static bool
test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread,
int depth, int frame_count, Values *values) {
int depth, int frame_count, Values *values, bool at_event) {
jvmtiError err;
LOG("test_SetLocal: mounted: %d depth: %d fcount: %d\n", cthread != NULL, depth, frame_count);
@ -288,7 +288,7 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread,
fatal(jni, "JVMTI SetLocalObject for unmounted vthread pr depth > 0failed to return JVMTI_ERROR_OPAQUE_FRAME");
}
return false; // skip testing other types for unmounted vthread
} else if (err == JVMTI_ERROR_OPAQUE_FRAME) {
} else if (!at_event && err == JVMTI_ERROR_OPAQUE_FRAME) {
LOG("JVMTI SetLocalObject for mounted vthread at depth=0 returned JVMTI_ERROR_OPAQUE_FRAME: %d\n", err);
return false; // skip testing other types for compiled frame that can't be deoptimized
}
@ -309,7 +309,7 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread,
}
static void
test_GetSetLocal(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, int depth, int frame_count) {
test_GetSetLocal(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, int depth, int frame_count, bool at_event) {
Values values0 = { NULL, NULL, 1, 2L, (jfloat)3.2F, (jdouble)4.500000047683716 };
Values values1 = { NULL, NULL, 2, 3L, (jfloat)4.2F, (jdouble)5.500000047683716 };
jthread cthread = get_carrier_thread(jvmti, jni, vthread);
@ -319,8 +319,8 @@ test_GetSetLocal(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, int depth, int f
LOG("test_GetSetLocal: test_GetLocal with values0\n");
test_GetLocal(jvmti, jni, cthread, vthread, depth, frame_count, &values0);
LOG("test_GetSetLocal: test_SetLocal with values1\n");
bool success = test_SetLocal(jvmti, jni, cthread, vthread, depth, frame_count, &values1);
LOG("test_GetSetLocal: test_SetLocal at_event: %d with values1\n", at_event);
bool success = test_SetLocal(jvmti, jni, cthread, vthread, depth, frame_count, &values1, at_event);
if (!success) {
goto End; // skip testing for compiled frame that can't be deoptimized
@ -334,8 +334,8 @@ test_GetSetLocal(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, int depth, int f
} else {
LOG("test_GetSetLocal: test_GetLocal with values1\n");
test_GetLocal(jvmti, jni, cthread, vthread, depth, frame_count, &values1);
LOG("test_GetSetLocal: test_SetLocal with values0 to restore original local values\n");
test_SetLocal(jvmti, jni, cthread, vthread, depth, frame_count, &values0);
LOG("test_GetSetLocal: test_SetLocal at_event: %d with values0 to restore original local values\n", at_event);
test_SetLocal(jvmti, jni, cthread, vthread, depth, frame_count, &values0, at_event);
}
End:
LOG("test_GetSetLocal: finished\n\n");
@ -360,7 +360,7 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread,
{
int frame_count = get_frame_count(jvmti, jni, vthread);
test_GetSetLocal(jvmti, jni, vthread, depth, frame_count);
test_GetSetLocal(jvmti, jni, vthread, depth, frame_count, true /* at_event */);
}
deallocate(jvmti, jni, (void*)mname);
deallocate(jvmti, jni, (void*)tname);
@ -470,7 +470,7 @@ Java_GetSetLocalTest_testSuspendedVirtualThreads(JNIEnv *jni, jclass klass, jthr
#if 0
print_stack_trace(jvmti, jni, vthread);
#endif
test_GetSetLocal(jvmti, jni, vthread, depth, frame_count);
test_GetSetLocal(jvmti, jni, vthread, depth, frame_count, false /* !at_event */);
}
err = jvmti->ResumeThread(vthread);
@ -487,7 +487,11 @@ Java_GetSetLocalTest_testSuspendedVirtualThreads(JNIEnv *jni, jclass klass, jthr
JNIEXPORT jboolean JNICALL
Java_GetSetLocalTest_completed(JNIEnv *jni, jclass klass) {
return completed;
if (completed) {
completed = JNI_FALSE;
return JNI_TRUE;
}
return JNI_FALSE;
}
} // extern "C"

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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
@ -34,15 +34,20 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.testng.Assert;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSParser;
/*
* @test
* @bug 8213117 8222743
* @bug 8213117 8222743 8287076
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @modules java.xml
* @modules java.xml/com.sun.org.apache.xerces.internal.dom
@ -56,6 +61,53 @@ public class DocumentTest {
static final int DOC1 = 1;
static final int DOC2 = 2;
/*
* @bug 8287076
* Verifies that Document::normalizeDocument returns the same result as that
* prior to JDK 10 (JDK-8181150).
* Attribute Name:
* JDK 9: NS1:wsu and NS2:wsu2
* After the JDK 10 change: wsu and wsu2
*/
@Test
public void testNormalizeDocument() throws Exception {
final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
final LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
final LSInput input = impl.createLSInput();
input.setStringData("<xml/>");
final Document document = builder.parse(input);
final Element root = document.getDocumentElement();
// Generate a single element
final Element element = document.createElement("token");
final Attr attr = element.getOwnerDocument().createAttributeNS("http://blah.xsd", "wsu");
attr.setValue("Id");
element.setAttributeNodeNS(attr);
final Attr attr2 = element.getOwnerDocument().createAttributeNS("http://blah2.xsd", "wsu2");
element.setAttributeNodeNS(attr2);
final Attr attr3 = element.getOwnerDocument().createAttribute("aa");
element.setAttributeNodeNS(attr3);
final Attr attr4 = element.getOwnerDocument().createAttribute("zz");
element.setAttributeNodeNS(attr4);
final Attr attr5 = element.getOwnerDocument().createAttribute("tt");
element.setAttributeNodeNS(attr5);
root.appendChild(element);
document.normalizeDocument();
Node wsu = element.getAttributes().getNamedItemNS("http://blah.xsd", "wsu");
Node wsu2 = element.getAttributes().getNamedItemNS("http://blah2.xsd", "wsu2");
Assert.assertEquals(wsu.getNodeName(), "NS1:wsu");
Assert.assertEquals(wsu2.getNodeName(), "NS2:wsu2");
}
/**
* Verifies the adoptNode method. Before a node from a deferred DOM can be
* adopted, it needs to be fully expanded.

@ -692,7 +692,6 @@ sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8265770 macosx-all
# core_tools
tools/jlink/plugins/CompressorPluginTest.java 8247407 generic-all
############################################################################

@ -63,8 +63,6 @@ public class AttachTest {
.executeTestJava(opts)
.outputTo(System.out)
.errorTo(System.out);
int exitValue = outputAnalyzer.getExitValue();
if (exitValue != 0)
throw new RuntimeException("Test failed");
outputAnalyzer.shouldHaveExitValue(0);
}
}

@ -52,7 +52,7 @@ public class ImplicitAttach {
.findStatic(ImplicitAttach.class, "callback", MethodType.methodType(void.class));
MemorySegment upcallStub = abi.upcallStub(callback,
FunctionDescriptor.ofVoid(),
MemorySession.openImplicit());
MemorySession.global());
// void start_threads(int count, void *(*f)(void *))
SymbolLookup symbolLookup = SymbolLookup.loaderLookup();

@ -0,0 +1,86 @@
/*
* Copyright (c) 2022, 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.
*
* 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.
*/
import jdk.internal.jimage.ImageReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @test
* @bug 8247407
* @summary Test that ImageReader doesn't create a Directory node with duplicate children
* @modules java.base/jdk.internal.jimage
* @run main ImageReaderDuplicateChildNodesTest
*/
public class ImageReaderDuplicateChildNodesTest {
/**
* Uses the ImageReader to open and read the JAVA_HOME/lib/modules image. Tests that the
* {@link ImageReader#findNode(String)} corresponding to a directory doesn't return a node
* with duplicate children in it.
*/
public static void main(final String[] args) throws Exception {
final Path imagePath = Paths.get(System.getProperty("java.home"), "lib", "modules");
if (!Files.exists(imagePath)) {
// skip the testing in the absence of the image file
System.err.println("Skipping test since " + imagePath + " is absent");
return;
}
System.out.println("Running test against image " + imagePath);
final String integersParentResource = "/modules/java.base/java/lang";
final String integerResource = integersParentResource + "/Integer.class";
try (final ImageReader reader = ImageReader.open(imagePath)) {
// find the child node/resource first
final ImageReader.Node integerNode = reader.findNode(integerResource);
if (integerNode == null) {
throw new RuntimeException("ImageReader could not locate " + integerResource
+ " in " + imagePath);
}
// now find the parent node (which will represent a directory)
final ImageReader.Node parent = reader.findNode(integersParentResource);
if (parent == null) {
throw new RuntimeException("ImageReader could not locate " + integersParentResource
+ " in " + imagePath);
}
// now verify that the parent node which is a directory, doesn't have duplicate children
final List<ImageReader.Node> children = parent.getChildren();
if (children == null || children.isEmpty()) {
throw new RuntimeException("ImageReader did not return any child resources under "
+ integersParentResource + " in " + imagePath);
}
final Set<ImageReader.Node> uniqueChildren = new HashSet<>();
for (final ImageReader.Node child : children) {
final boolean unique = uniqueChildren.add(child);
if (!unique) {
throw new RuntimeException("ImageReader returned duplicate child resource "
+ child + " under " + parent + " from image " + imagePath);
}
}
}
}
}

@ -0,0 +1,47 @@
/*
* Copyright (c) 2022, 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.
*
* 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.
*/
/**
* @test
* @bug 8288120
* @summary Verify an appropriate accessor method is looked up.
* @compile --enable-preview -source ${jdk.version} ProxyMethodLookup.java
* @run main/othervm --enable-preview ProxyMethodLookup
*/
public class ProxyMethodLookup {
public static void main(String[] args) {
Object val = new R(new Component());
boolean b = val instanceof R(var c);
}
interface ComponentBase {}
record Component() implements ComponentBase {}
sealed interface Base {
ComponentBase c();
}
record R(Component c) implements Base {}
}