mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 03:43:21 +00:00
8162539: Test fails because it expects a blank between method signature and throws exception
Reviewed-by: coleenp
This commit is contained in:
parent
1c514f5458
commit
085f7a6907
@ -122,7 +122,7 @@ public abstract class Executable extends AccessibleObject
|
||||
sb.append(')');
|
||||
|
||||
if (exceptionTypes.length > 0) {
|
||||
StringJoiner joiner = new StringJoiner(",", "throws ", "");
|
||||
StringJoiner joiner = new StringJoiner(",", " throws ", "");
|
||||
for (Class<?> exceptionType : exceptionTypes) {
|
||||
joiner.add(exceptionType.getTypeName());
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 5033583 6316717 6470106 8161500
|
||||
* @bug 5033583 6316717 6470106 8161500 8162539
|
||||
* @summary Check toGenericString() and toString() methods
|
||||
* @author Joseph D. Darcy
|
||||
*/
|
||||
@ -41,20 +41,11 @@ public class GenericStringTest {
|
||||
ExpectedGenericString egs = ctor.getAnnotation(ExpectedGenericString.class);
|
||||
String actual = ctor.toGenericString();
|
||||
System.out.println(actual);
|
||||
if (! egs.value().equals(actual)) {
|
||||
failures++;
|
||||
System.err.printf("ERROR: Expected generic string ''%s''; got ''%s''.\n",
|
||||
egs.value(), actual);
|
||||
}
|
||||
failures += checkForFailure(egs.value(), actual);
|
||||
|
||||
if (ctor.isAnnotationPresent(ExpectedString.class)) {
|
||||
ExpectedString es = ctor.getAnnotation(ExpectedString.class);
|
||||
String result = ctor.toString();
|
||||
if (! es.value().equals(result)) {
|
||||
failures++;
|
||||
System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n",
|
||||
es.value(), result);
|
||||
}
|
||||
failures += checkForFailure(ctor.getAnnotation(ExpectedString.class).value(),
|
||||
ctor.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +54,15 @@ public class GenericStringTest {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
private static int checkForFailure(String expected, String actual) {
|
||||
if (!expected.equals(actual)) {
|
||||
System.err.printf("ERROR: Expected ''%s'';%ngot ''%s''.\n",
|
||||
expected, actual);
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass1 {
|
||||
@ -75,13 +75,23 @@ class TestClass1 {
|
||||
private TestClass1(int x, int param2) {}
|
||||
|
||||
@ExpectedGenericString(
|
||||
"private TestClass1(java.lang.Object) throws java.lang.RuntimeException")
|
||||
@ExpectedString(
|
||||
"private TestClass1(java.lang.Object) throws java.lang.RuntimeException")
|
||||
private TestClass1(Object o) throws RuntimeException {}
|
||||
|
||||
@ExpectedGenericString(
|
||||
"protected <S,T> TestClass1(S,T) throws java.lang.Exception")
|
||||
@ExpectedString(
|
||||
"protected TestClass1(java.lang.Object,java.lang.Object) throws java.lang.Exception")
|
||||
protected <S, T> TestClass1(S s, T t) throws Exception{}
|
||||
|
||||
@ExpectedGenericString(
|
||||
"<E> TestClass1() throws E")
|
||||
@ExpectedString(
|
||||
"TestClass1() throws java.lang.Exception")
|
||||
<E extends Exception> TestClass1() throws E {}
|
||||
|
||||
@ExpectedGenericString(
|
||||
"TestClass1(java.lang.Object...)")
|
||||
@ExpectedString(
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 5033583 6316717 6470106 8004979 8161500
|
||||
* @bug 5033583 6316717 6470106 8004979 8161500 8162539
|
||||
* @summary Check toGenericString() and toString() methods
|
||||
* @author Joseph D. Darcy
|
||||
*/
|
||||
@ -44,28 +44,16 @@ public class GenericStringTest {
|
||||
String actual = method.toGenericString();
|
||||
System.out.println(actual);
|
||||
if (method.isBridge()) {
|
||||
if (! egs.bridgeValue().equals(actual)) {
|
||||
failures++;
|
||||
System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n",
|
||||
egs.value(), actual);
|
||||
}
|
||||
failures += checkForFailure(egs.bridgeValue(), actual);
|
||||
} else {
|
||||
if (! egs.value().equals(actual)) {
|
||||
failures++;
|
||||
System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n",
|
||||
egs.value(), actual);
|
||||
}
|
||||
failures += checkForFailure(egs.value(), actual);
|
||||
}
|
||||
}
|
||||
|
||||
if (method.isAnnotationPresent(ExpectedString.class)) {
|
||||
ExpectedString es = method.getAnnotation(ExpectedString.class);
|
||||
String actual = method.toString();
|
||||
if (! es.value().equals(actual)) {
|
||||
failures++;
|
||||
System.err.printf("ERROR: Expected ''%s''; got ''%s''.\n",
|
||||
es.value(), actual);
|
||||
}
|
||||
failures += checkForFailure(es.value(), actual);
|
||||
}
|
||||
|
||||
}
|
||||
@ -88,6 +76,15 @@ public class GenericStringTest {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
private static int checkForFailure(String expected, String actual) {
|
||||
if (!expected.equals(actual)) {
|
||||
System.err.printf("ERROR: Expected ''%s'';%ngot ''%s''.\n",
|
||||
expected, actual);
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass1 {
|
||||
@ -115,6 +112,8 @@ class TestClass2<E, F extends Exception> {
|
||||
|
||||
@ExpectedGenericString(
|
||||
"public void TestClass2.method2() throws F")
|
||||
@ExpectedString(
|
||||
"public void TestClass2.method2() throws java.lang.Exception")
|
||||
public void method2() throws F {return;}
|
||||
|
||||
@ExpectedGenericString(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user