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
8271302: Regex Test Refresh #5092
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2019, 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 | ||
@@ -26,17 +26,17 @@ | ||
* @bug 8223174 | ||
* @summary Pattern.compile() can throw confusing NegativeArraySizeException | ||
* @requires os.maxMemory >= 5g | ||
* @run main/othervm NegativeArraySize -Xms5G -Xmx5G | ||
* @run testng/othervm -Xms5G -Xmx5G NegativeArraySize | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I note that the order of the arguments has changed. Will that work as expected? Had it worked as expected before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new order is consistent with other tests. I had difficulty getting it to run in the original configuration. Perhaps jtreg is more sensitive on order with the testng runner. |
||
*/ | ||
|
||
import org.testng.annotations.Test; | ||
import static org.testng.Assert.assertThrows; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class NegativeArraySize { | ||
public static void main(String[] args) { | ||
try { | ||
Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3)); | ||
throw new AssertionError("expected to throw"); | ||
} catch (OutOfMemoryError expected) { | ||
} | ||
@Test | ||
public static void testNegativeArraySize() { | ||
assertThrows(OutOfMemoryError.class, () -> Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One observation on this regex. Although the regex looks invalid because
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe that behavior is expected after all. From "Mastering Regular Expressions" by Jeffrey E.F. Friedl, 3rd Edition, p. 136:
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comma after 2021, or the copyright headers check won't pass.