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.

Ajc1810Tests.java 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*******************************************************************************
  2. * Copyright (c) 2016 Contributors
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc1810;
  12. import java.io.File;
  13. import org.aspectj.apache.bcel.Constants;
  14. import org.aspectj.apache.bcel.classfile.Attribute;
  15. import org.aspectj.apache.bcel.classfile.JavaClass;
  16. import org.aspectj.testing.XMLBasedAjcTestCase;
  17. import junit.framework.Test;
  18. /**
  19. * @author Andy Clement
  20. */
  21. public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
  22. public void testBinding_500035() {
  23. runTest("ataspectj binding");
  24. }
  25. public void testBinding_500035_2() {
  26. runTest("ataspectj binding 2");
  27. }
  28. public void testBinding_500035_3() {
  29. runTest("ataspectj binding 3 -XnoInline");
  30. }
  31. public void testBinding_500035_4() {
  32. runTest("ataspectj binding 4");
  33. }
  34. public void testGenericsException_501656() {
  35. runTest("generics exception");
  36. }
  37. public void testAIOOBE_502807() {
  38. runTest("unexpected aioobe");
  39. }
  40. public void testInvokeDynamic_490315() {
  41. runTest("indy");
  42. }
  43. public void testAmbigMessage17() throws Exception {
  44. runTest("ambiguous message - 17");
  45. }
  46. public void testAmbigMessage18() throws Exception {
  47. runTest("ambiguous message - 18");
  48. }
  49. // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6
  50. public void testInnerClassesAttributeStructure_493554() throws Exception {
  51. runTest("pertarget");
  52. // Testcode commented out below is for full analysis of the inner class attribute but under
  53. // 493554 we are going to remove that attribute for this class
  54. JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect");
  55. assertNotNull(jc);
  56. assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers());
  57. Attribute[] attributes = jc.getAttributes();
  58. for (Attribute attribute: attributes) {
  59. if (attribute.getName().equals("InnerClasses")) {
  60. fail("Did not expect to find InnerClasses attribute");
  61. }
  62. }
  63. // // Is InnerClasses attribute well formed for the pertarget interface?
  64. // JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect");
  65. // assertNotNull(jc);
  66. // assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers());
  67. // Attribute attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses");
  68. // assertNotNull(attr);
  69. // InnerClasses innerClasses = (InnerClasses)attr;
  70. // InnerClass[] innerClassArray = innerClasses.getInnerClasses();
  71. // assertEquals(1,innerClassArray.length);
  72. // InnerClass innerClass = innerClassArray[0];
  73. // ConstantPool cp = jc.getConstantPool();
  74. //
  75. // // The value of the inner_class_info_index item must be a valid index into the
  76. // // constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info
  77. // // structure representing C.
  78. // int innerClassIndex = innerClass.getInnerClassIndex();
  79. // ConstantClass cc = (ConstantClass)cp.getConstant(innerClassIndex);
  80. // ConstantUtf8 utf8 = cp.getConstantUtf8(cc.getNameIndex());
  81. // assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue());
  82. //
  83. // // The remaining items in the classes array entry give information about C.
  84. // // The value of the outer_class_info_index item must be a valid index into the
  85. // // constant_pool table, and the entry at that index must be a CONSTANT_Class_info
  86. // // structure representing the class or interface of which C is a member.
  87. // int outerClassIndex = innerClass.getOuterClassIndex();
  88. // cc = (ConstantClass)cp.getConstant(outerClassIndex);
  89. // utf8 = cp.getConstantUtf8(cc.getNameIndex());
  90. // assertEquals("example/aspect/FooAspect",utf8.getStringValue());
  91. //
  92. // // The value of the inner_name_index item must be a valid index into the constant_pool table,
  93. // // and the entry at that index must be a CONSTANT_Utf8_info structure (§4.4.7) that represents
  94. // // the original simple name of C, as given in the source code from which this class file was compiled.
  95. // int innerNameIndex = innerClass.getInnerNameIndex();
  96. // utf8 = cp.getConstantUtf8(innerNameIndex);
  97. // assertEquals("ajcMightHaveAspect",utf8.getStringValue());
  98. //
  99. // int innerAccessFlags = innerClass.getInnerAccessFlags();
  100. // assertEquals(Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags);
  101. //
  102. // // Is InnerClasses attribute well formed for the containing type?
  103. // jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect");
  104. // assertNotNull(jc);
  105. // attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses");
  106. // assertNotNull(attr);
  107. // innerClasses = (InnerClasses)attr;
  108. // innerClassArray = innerClasses.getInnerClasses();
  109. // assertEquals(1,innerClassArray.length);
  110. // innerClass = innerClassArray[0];
  111. // cp = jc.getConstantPool();
  112. // System.out.println(innerClass);
  113. //
  114. // // inner class name
  115. // innerClassIndex = innerClass.getInnerClassIndex();
  116. // cc = (ConstantClass)cp.getConstant(innerClassIndex);
  117. // utf8 = cp.getConstantUtf8(cc.getNameIndex());
  118. // assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue());
  119. //
  120. // // outer class name
  121. // outerClassIndex = innerClass.getOuterClassIndex();
  122. // cc = (ConstantClass)cp.getConstant(outerClassIndex);
  123. // utf8 = cp.getConstantUtf8(cc.getNameIndex());
  124. // assertEquals("example/aspect/FooAspect",utf8.getStringValue());
  125. //
  126. // // Simple name
  127. // innerNameIndex = innerClass.getInnerNameIndex();
  128. // utf8 = cp.getConstantUtf8(innerNameIndex);
  129. // assertEquals("ajcMightHaveAspect",utf8.getStringValue());
  130. //
  131. // // inner modifiers
  132. // innerAccessFlags = innerClass.getInnerAccessFlags();
  133. // assertEquals(Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags);
  134. //
  135. // // Reflection work getDeclaredClasses?
  136. //
  137. // // What about other interfaces?
  138. }
  139. // public void testOverweaving_352389() throws Exception {
  140. // runTest("overweaving");
  141. // }
  142. // ---
  143. public static Test suite() {
  144. return XMLBasedAjcTestCase.loadSuite(Ajc1810Tests.class);
  145. }
  146. @Override
  147. protected File getSpecFile() {
  148. return getClassResource("ajc1810.xml");
  149. }
  150. }