-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
generic
-
generic
This following example shows, how to create a invalid 'DeclaredType' instance.
Case1<java.lang.String,java.lang.String> is invalid as Case1<T extends List, T1 extends List> was declared.
I am not completely sure, what other complications can cause while using a invalid 'DeclaredType'.
bash-3.00$ ksh compile.sh
element received as Case1
declared type Case1<java.lang.String,java.lang.String>
element received as Case1
declared type Case1<java.lang.String,java.lang.String>
java version "1.6.0-auto"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-292b)
Java HotSpot(TM) Server VM (build 1.6.0-ea-b56, mixed mode)
bash-3.00$ cat Case1.java
import java.util.List;
public class Case1 <T extends List, T1 extends List> {
}
bash-3.00$ cat CaseAP.java
import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
import static javax.lang.model.SourceVersion.*;
import static javax.lang.model.type.TypeKind.*;
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(RELEASE_6)
@SupportedOptions("-verbose")
public class CaseAP extends AbstractProcessor {
public void init(ProcessingEnvironment penv) {
super.init(penv);
}
public boolean process(Set<? extends TypeElement> typeElementSet,
RoundEnvironment renv) {
Elements elementUtils = processingEnv.getElementUtils();
Types types = processingEnv.getTypeUtils();
TypeElement case2 = elementUtils.getTypeElement("Case1");
TypeElement type = elementUtils.getTypeElement("java.lang.String");
if ( case2 != null ) {
System.out.println(" element received as "+case2.toString());
DeclaredType dt = types.getDeclaredType(case2, type.asType(), type.asType());
System.out.println(" declared type "+dt.toString());
}
return true ;
}
}
bash-3.00$
Case1<java.lang.String,java.lang.String> is invalid as Case1<T extends List, T1 extends List> was declared.
I am not completely sure, what other complications can cause while using a invalid 'DeclaredType'.
bash-3.00$ ksh compile.sh
element received as Case1
declared type Case1<java.lang.String,java.lang.String>
element received as Case1
declared type Case1<java.lang.String,java.lang.String>
java version "1.6.0-auto"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-292b)
Java HotSpot(TM) Server VM (build 1.6.0-ea-b56, mixed mode)
bash-3.00$ cat Case1.java
import java.util.List;
public class Case1 <T extends List, T1 extends List> {
}
bash-3.00$ cat CaseAP.java
import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
import static javax.lang.model.SourceVersion.*;
import static javax.lang.model.type.TypeKind.*;
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(RELEASE_6)
@SupportedOptions("-verbose")
public class CaseAP extends AbstractProcessor {
public void init(ProcessingEnvironment penv) {
super.init(penv);
}
public boolean process(Set<? extends TypeElement> typeElementSet,
RoundEnvironment renv) {
Elements elementUtils = processingEnv.getElementUtils();
Types types = processingEnv.getTypeUtils();
TypeElement case2 = elementUtils.getTypeElement("Case1");
TypeElement type = elementUtils.getTypeElement("java.lang.String");
if ( case2 != null ) {
System.out.println(" element received as "+case2.toString());
DeclaredType dt = types.getDeclaredType(case2, type.asType(), type.asType());
System.out.println(" declared type "+dt.toString());
}
return true ;
}
}
bash-3.00$
- duplicates
-
JDK-8055219 Handling of non-standard inputs in javax.lang.model.util.Types
- Open
- relates to
-
JDK-6394614 Please provide a way to validate newly-constructed parameterized types.
- Open
-
JDK-8055219 Handling of non-standard inputs in javax.lang.model.util.Types
- Open