You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClassFieldOnPrimitiveType.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import org.aspectj.testing.Tester;
  2. public class ClassFieldOnPrimitiveType
  3. {
  4. public static void main(String[] args) { test(); }
  5. public static void test() {
  6. Tester.checkEqual(checkBoolean(), "boolean", "boolean");
  7. Tester.checkEqual(checkChar(), "char", "char");
  8. Tester.checkEqual(checkByte(), "byte", "byte");
  9. Tester.checkEqual(checkShort(), "short", "short");
  10. Tester.checkEqual(checkLong(), "long", "long");
  11. Tester.checkEqual(checkFloat(), "float", "float");
  12. Tester.checkEqual(checkDouble(), "double", "double");
  13. Tester.checkEqual(checkIntArray(), "[Z", "boolean[]");
  14. checkIntArray();
  15. }
  16. public static String checkVoid() {
  17. Class c = void.class;
  18. return c.getName();
  19. }
  20. public static String checkBoolean() {
  21. Class c = boolean.class;
  22. Tester.check(c.isPrimitive(), "check isPrimitive");
  23. return c.getName();
  24. }
  25. public static String checkChar() {
  26. Class c = char.class;
  27. return c.getName();
  28. }
  29. public static String checkByte() {
  30. Class c = byte.class;
  31. return c.getName();
  32. }
  33. public static String checkShort() {
  34. Class c = short.class;
  35. return c.getName();
  36. }
  37. public static String checkInt() {
  38. Class c = int.class;
  39. Tester.check( c == Integer.TYPE, "check Type field");
  40. return c.getName();
  41. }
  42. public static String checkLong() {
  43. Class c = long.class;
  44. return c.getName();
  45. }
  46. public static String checkFloat() {
  47. Class c = float.class;
  48. return c.getName();
  49. }
  50. public static String checkDouble() {
  51. Class c = double.class;
  52. return c.getName();
  53. }
  54. public static String checkIntArray() {
  55. Class c = boolean[].class;
  56. return c.getName();
  57. }
  58. }