Reject JDK proxy hint registration for sealed interfaces
Closes gh-28786
This commit is contained in:
@@ -39,17 +39,25 @@ class ProxyHintsTests {
|
||||
|
||||
|
||||
@Test
|
||||
void registerJdkProxyWithInterfaceClass() {
|
||||
this.proxyHints.registerJdkProxy(Function.class);
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
void registerJdkProxyWithSealedInterface() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.proxyHints.registerJdkProxy(SealedInterface.class))
|
||||
.withMessageContaining(SealedInterface.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerJdkProxyWithConcreteClass() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.proxyHints.registerJdkProxy(String.class))
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.proxyHints.registerJdkProxy(String.class))
|
||||
.withMessageContaining(String.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerJdkProxyWithInterface() {
|
||||
this.proxyHints.registerJdkProxy(Function.class);
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerJdkProxyWithTypeReferences() {
|
||||
this.proxyHints.registerJdkProxy(TypeReference.of(Function.class), TypeReference.of("com.example.Advised"));
|
||||
@@ -128,4 +136,11 @@ class ProxyHintsTests {
|
||||
return Arrays.stream(proxiedInterfaces).map(TypeReference::of).toArray(TypeReference[]::new);
|
||||
}
|
||||
|
||||
|
||||
sealed interface SealedInterface {
|
||||
}
|
||||
|
||||
static final class SealedClass implements SealedInterface {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user