javax.lang.model.type


1. Get the type of a field

Field field = ...;
TypeMirror fieldType = field.getEnclosingElement().asType();

2. Get the type of a method parameter

Method method = ...;
TypeMirror parameterType = method.getParameters().get(0).asType();

3. Get the type of a method return value

Method method = ...;
TypeMirror returnType = method.getReturnType();

4. Get the type of a class

Class<?> clazz = ...;
TypeMirror classType = TypeMirror.get(clazz);

5. Get the type of an array

Class<?> clazz = ...;
TypeMirror arrayType = TypeMirror.get(clazz.getComponentType()).getArrayType();

6. Get the type of a wildcard

TypeMirror wildcardType = TypeMirror.getWildcardType(WildcardType.Kind.UNBOUNDED);

7. Get the type of a type variable

8. Get the type of a capture variable

9. Get the type of a generic method

10. Get the type of a generic class

11. Get the type of a generic interface

12. Get the type of a parameterized type

13. Get the type of a raw type

14. Get the type of an intersection type

15. Get the type of an union type

16. Get the type of a nested type

17. Get the type of an annotation

18. Get the type of an enum constant

19. Get the type of a package

20. Get the type of a type parameter

21. Get the type of a method receiver

22. Get the type of a method exception

23. Get the type of a method type parameter

24. Get the type of a constructor argument

25. Get the type of a constructor exception

26. Get the type of a constructor type parameter

27. Get the type of a type cast

28. Get the type of an instanceof expression

29. Get the type of a new array expression

30. Get the type of a new class expression

31. Get the type of a parenthesized expression

32. Get the type of a switch statement

33. Get the type of a synchronized statement

34. Get the type of a try statement

35. Get the type of a throw statement

36. Get the type of a while statement

37. Get the type of a do-while statement

38. Get the type of a for-each statement

39. Get the type of a for statement

40. Get the type of a break statement

41. Get the type of a continue statement

42. Get the type of a return statement

43. Get the type of a variable

44. Get the type of an expression statement

45. Get the type of a block statement

46. Get the type of an if statement

47. Get the type of an else if statement

48. Get the type of an else statement

49. Get the type of a switch-case statement

50. Get the type of a switch-default statement