Skip to content
Permalink
Browse files
8269753: Misplaced caret in PatternSyntaxException's detail message
Backport-of: bb508e13032c3571c48275391dfeb04c03bbf3a3
  • Loading branch information
GoeLin committed Mar 10, 2022
1 parent eb076ae commit 6fb49c330dc1f7f74bf1977ab4e45b4d123a2c7a
Showing 2 changed files with 24 additions and 3 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@@ -107,7 +107,9 @@ public String getMessage() {
sb.append(pattern);
if (index >= 0 && pattern != null && index < pattern.length()) {
sb.append(System.lineSeparator());
for (int i = 0; i < index; i++) sb.append(' ');
for (int i = 0; i < index; i++) {
sb.append((pattern.charAt(i) == '\t') ? '\t' : ' ');
}
sb.append('^');
}
return sb.toString();
@@ -36,7 +36,7 @@
* 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895
* 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706
* 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812
* 8216332 8214245 8237599 8241055 8247546 8258259 8037397
* 8216332 8214245 8237599 8241055 8247546 8258259 8037397 8269753
*
* @library /test/lib
* @library /lib/testlibrary/java/lang
@@ -198,6 +198,7 @@ public static void main(String[] args) throws Exception {
caseInsensitivePMatch();
surrogatePairOverlapRegion();
droppedClassesWithIntersection();
errorMessageCaretIndentation();


if (failure) {
@@ -5289,5 +5290,23 @@ private static void droppedClassesWithIntersection() {
System.out.println("Compiling intersection pattern is matching digits where it should not");
}

report("Dropped classes with intersection.");

}

//This test is for 8269753
private static void errorMessageCaretIndentation() {
String pattern = "\t**";

try {
var res = Pattern.compile(pattern);
} catch (PatternSyntaxException e) {
var message = e.getMessage();
var sep = System.lineSeparator();
if (!message.contains(sep + "\t ^")){
failCount++;
}
}
report("Correct caret indentation for patterns with tabs");
}
}

1 comment on commit 6fb49c3

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 6fb49c3 Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.