This commit is contained in:
Jesper Wilhelmsson 2021-07-27 00:57:58 +00:00
commit eb6da88817
6 changed files with 114 additions and 15 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac/parser
test
hotspot/jtreg/runtime
jdk/java/awt/Focus/DeiconifiedFrameLoosesFocus
langtools/tools/javac/UnicodeBackslash

@ -85,6 +85,11 @@ public class UnicodeReader {
*/ */
private boolean wasBackslash; private boolean wasBackslash;
/**
* true if the last character was derived from an unicode escape sequence.
*/
private boolean wasUnicodeEscape;
/** /**
* Log for error reporting. * Log for error reporting.
*/ */
@ -105,6 +110,7 @@ public class UnicodeReader {
this.character = '\0'; this.character = '\0';
this.codepoint = 0; this.codepoint = 0;
this.wasBackslash = false; this.wasBackslash = false;
this.wasUnicodeEscape = false;
this.log = sf.log; this.log = sf.log;
nextCodePoint(); nextCodePoint();
@ -161,17 +167,22 @@ public class UnicodeReader {
// Fetch next character. // Fetch next character.
nextCodeUnit(); nextCodeUnit();
// If second backslash is detected. if (character == '\\' && (!wasBackslash || wasUnicodeEscape)) {
if (wasBackslash) { // Is a backslash and may be an unicode escape.
// Treat like a normal character (not part of unicode escape.)
wasBackslash = false;
} else if (character == '\\') {
// May be an unicode escape.
switch (unicodeEscape()) { switch (unicodeEscape()) {
case BACKSLASH -> wasBackslash = true; case BACKSLASH -> {
case VALID_ESCAPE -> wasBackslash = false; wasUnicodeEscape = false;
wasBackslash = !wasBackslash;
}
case VALID_ESCAPE -> {
wasUnicodeEscape = true;
wasBackslash = character == '\\' && !wasBackslash;
}
case BROKEN_ESCAPE -> nextUnicodeInputCharacter(); //skip broken unicode escapes case BROKEN_ESCAPE -> nextUnicodeInputCharacter(); //skip broken unicode escapes
} }
} else {
wasBackslash = false;
wasUnicodeEscape = false;
} }
// Codepoint and character match if not surrogate. // Codepoint and character match if not surrogate.
@ -297,6 +308,7 @@ public class UnicodeReader {
position = pos; position = pos;
width = 0; width = 0;
wasBackslash = false; wasBackslash = false;
wasUnicodeEscape = false;
nextCodePoint(); nextCodePoint();
} }

@ -93,6 +93,7 @@ public class MonitorUsedDeflationThresholdTest {
"MonitorUsedDeflationThresholdTest", "33"); "MonitorUsedDeflationThresholdTest", "33");
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start()); OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
output_detail.shouldHaveExitValue(0);
// This mesg means: // This mesg means:
// - AvgMonitorsPerThreadEstimate == 1 reduced in_use_list_ceiling // - AvgMonitorsPerThreadEstimate == 1 reduced in_use_list_ceiling

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -91,6 +91,7 @@ public class SyncOnValueBasedClassTest {
for (int i = 0; i < logTests.length; i++) { for (int i = 0; i < logTests.length; i++) {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(logTests[i]); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(logTests[i]);
OutputAnalyzer output = ProcessTools.executeProcess(pb); OutputAnalyzer output = ProcessTools.executeProcess(pb);
output.shouldHaveExitValue(0);
checkOutput(output); checkOutput(output);
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,10 @@
* @bug 8166358 * @bug 8166358
* @summary verify that -Xcheck:jni finds a bad utf8 name for class name. * @summary verify that -Xcheck:jni finds a bad utf8 name for class name.
* @library /test/lib * @library /test/lib
* @run main/native/othervm FindClassUtf8 test * @run main/native FindClassUtf8 test
*/ */
import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
@ -42,7 +43,10 @@ public final class FindClassUtf8 {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
if (args.length == 1) { if (args.length == 1) {
// run java -Xcheck:jni FindClassUtf8 and check that the -Xcheck:jni message comes out. // run java -Xcheck:jni FindClassUtf8 and check that the -Xcheck:jni message comes out.
ProcessTools.executeTestJvm("-Xcheck:jni", "-XX:-CreateCoredumpOnCrash", "FindClassUtf8") ProcessTools.executeTestJvm("-Djava.library.path=" + Utils.TEST_NATIVE_PATH,
"-Xcheck:jni",
"-XX:-CreateCoredumpOnCrash",
"FindClassUtf8")
.shouldContain("JNI class name is not a valid UTF8 string") .shouldContain("JNI class name is not a valid UTF8 string")
.shouldNotHaveExitValue(0); // you get a core dump from -Xcheck:jni failures .shouldNotHaveExitValue(0); // you get a core dump from -Xcheck:jni failures
} else { } else {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,9 @@
@run main DeiconifiedFrameLoosesFocus @run main DeiconifiedFrameLoosesFocus
*/ */
import java.awt.*; import java.awt.Frame;
import java.awt.Robot;
import java.awt.Toolkit;
import test.java.awt.regtesthelpers.Util; import test.java.awt.regtesthelpers.Util;
public class DeiconifiedFrameLoosesFocus { public class DeiconifiedFrameLoosesFocus {
@ -41,7 +43,11 @@ public class DeiconifiedFrameLoosesFocus {
public static void main(String[] args) { public static void main(String[] args) {
DeiconifiedFrameLoosesFocus app = new DeiconifiedFrameLoosesFocus(); DeiconifiedFrameLoosesFocus app = new DeiconifiedFrameLoosesFocus();
app.init(); app.init();
app.start(); try {
app.start();
} finally {
frame.dispose();
}
} }
public void init() { public void init() {
@ -61,6 +67,7 @@ public class DeiconifiedFrameLoosesFocus {
frame.setVisible(true); frame.setVisible(true);
Util.waitForIdle(robot); Util.waitForIdle(robot);
robot.delay(1000);
if (!frame.isFocused()) { if (!frame.isFocused()) {
Util.clickOnTitle(frame, robot); Util.clickOnTitle(frame, robot);
@ -79,10 +86,12 @@ public class DeiconifiedFrameLoosesFocus {
frame.setExtendedState(Frame.ICONIFIED); frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(robot); Util.waitForIdle(robot);
robot.delay(500);
frame.setExtendedState(Frame.NORMAL); frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(robot); Util.waitForIdle(robot);
robot.delay(500);
if (!frame.isFocused()) { if (!frame.isFocused()) {
throw new TestFailedException("the Frame didn't regain focus after restoring!"); throw new TestFailedException("the Frame didn't regain focus after restoring!");

@ -0,0 +1,72 @@
/*
* Copyright (c) 2021, 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 8269150
* @summary Unicode \ u 0 0 5 C not treated as an escaping backslash
* @run main UnicodeBackslash
*/
public class UnicodeBackslash {
static boolean failed = false;
public static void main(String... args) {
// id source expected
test("1.1", "\\]", "\\]");
test("1.2", "\u005C\]", "\\]");
test("1.3", "\\u005C]", "\\u005C]");
test("1.4", "\u005C\u005C]", "\\]");
test("2.1", "\\\\]", "\\\\]");
test("2.2", "\u005C\\\]", "\\\\]");
test("2.3", "\\u005C\\]", "\\u005C\\]");
test("2.4", "\\\u005C\]", "\\\\]");
test("2.5", "\\\\u005C]", "\\\\u005C]");
test("3.1", "\u005C\u005C\\]", "\\\\]");
test("3.2", "\u005C\\u005C\]", "\\\\]");
test("3.3", "\u005C\\\u005C]", "\\\\u005C]");
test("3.4", "\\u005C\u005C\]", "\\u005C\\]");
test("3.5", "\\u005C\\u005C]", "\\u005C\\u005C]");
test("3.6", "\\\u005C\u005C]", "\\\\]");
test("4.1", "\u005C\u005C\u005C\]", "\\\\]");
test("4.2", "\u005C\\u005C\u005C]", "\\\\]");
test("4.3", "\u005C\u005C\\u005C]", "\\\\u005C]");
test("4.4", "\\u005C\u005C\u005C]", "\\u005C\\]");
test("5.1", "\u005C\u005C\u005C\u005C]", "\\\\]");
if (failed) {
throw new RuntimeException("Unicode escapes not handled correctly");
}
}
static void test(String id, String source, String expected) {
if (!source.equals(expected)) {
System.err.println(id + ": expected: " + expected + ", found: " + source);
failed = true;
}
}
}