undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
42
test/langtools/tools/javac/patterns/AnnotationErrors.java
Normal file
42
test/langtools/tools/javac/patterns/AnnotationErrors.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8300543
|
||||
* @summary Verify error related to annotations and patterns
|
||||
* @compile/fail/ref=AnnotationErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW AnnotationErrors.java
|
||||
*/
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
public class AnnotationErrors {
|
||||
|
||||
private void test(Object o, G<String> g) {
|
||||
boolean b1 = o instanceof @DA R(var s);
|
||||
boolean b2 = o instanceof @DTA R(var s);
|
||||
boolean b3 = o instanceof @TA R(var s);
|
||||
boolean b5 = g instanceof G<@DTA String>(var s);
|
||||
boolean b6 = g instanceof G<@TA String>(var s);
|
||||
switch (o) {
|
||||
case @DA R(var s) when b1 -> {}
|
||||
case @DTA R(var s) when b1 -> {}
|
||||
case @TA R(var s) when b1 -> {}
|
||||
default -> {}
|
||||
}
|
||||
switch (g) {
|
||||
case G<@DTA String>(var s) when b1 -> {}
|
||||
case G<@TA String>(var s) when b1 -> {}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
|
||||
record R(String s) {}
|
||||
record G<T>(T t) {}
|
||||
|
||||
@Target(ElementType.LOCAL_VARIABLE)
|
||||
@interface DA {}
|
||||
@Target({ElementType.TYPE_USE, ElementType.LOCAL_VARIABLE})
|
||||
@interface DTA {}
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface TA {}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue