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 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. // Basic with execution(* *(@Foo (*))) && @args(ca (*))
  23. public void testParamAnnoBinding_259416_1() {
  24. runTest("param anno binding");
  25. }
  26. // Basic with execution(* *(..)) && args(ca (*))
  27. public void testParamAnnoBinding_259416_2() {
  28. runTest("param anno binding 2");
  29. }
  30. // Basic with execution(* *(..)) && args(*,ca (*))
  31. public void testParamAnnoBinding_259416_3() {
  32. runTest("param anno binding 3");
  33. }
  34. // Basic with execution(* *(..)) && args(*,ca (*)) where target has two parameter annotations and we match the 2nd one
  35. public void testParamAnnoBinding_259416_4() {
  36. runTest("param anno binding 4");
  37. }
  38. // execution(* *(..)) && args(f *,ca (*))
  39. // args(ca1 (*),ca2 (*))
  40. // args(ca(*))
  41. // args(ca1 (f))
  42. // args(ca1 ba1 (*))
  43. // args(ca1 ba1 (f1 f2))
  44. // args(ca1 (*), .., ca2 (*))
  45. public void testBinding_500035() {
  46. runTest("ataspectj binding");
  47. }
  48. public void testBinding_500035_2() {
  49. runTest("ataspectj binding 2");
  50. }
  51. public void testBinding_500035_3() {
  52. runTest("ataspectj binding 3 -XnoInline");
  53. }
  54. public void testBinding_500035_4() {
  55. runTest("ataspectj binding 4");
  56. }
  57. public void testGenericsException_501656() {
  58. runTest("generics exception");
  59. }
  60. public void testAIOOBE_502807() {
  61. runTest("unexpected aioobe");
  62. }
  63. public void testInvokeDynamic_490315() {
  64. runTest("indy");
  65. }
  66. public void testAmbigMessage17() throws Exception {
  67. runTest("ambiguous message - 17");
  68. }
  69. public void testAmbigMessage18() throws Exception {
  70. runTest("ambiguous message - 18");
  71. }
  72. // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6
  73. public void testInnerClassesAttributeStructure_493554() throws Exception {
  74. runTest("pertarget");
  75. // Testcode commented out below is for full analysis of the inner class attribute but under
  76. // 493554 we are going to remove that attribute for this class
  77. JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect");
  78. assertNotNull(jc);
  79. assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers());
  80. Attribute[] attributes = jc.getAttributes();
  81. for (Attribute attribute: attributes) {
  82. if (attribute.getName().equals("InnerClasses")) {
  83. fail("Did not expect to find InnerClasses attribute");
  84. }
  85. }
  86. // // Is InnerClasses attribute well formed for the pertarget interface?
  87. // JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect");
  88. // assertNotNull(jc);
  89. // assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers());
  90. // Attribute attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses");
  91. // assertNotNull(attr);
  92. // InnerClasses innerClasses = (InnerClasses)attr;
  93. // InnerClass[] innerClassArray = innerClasses.getInnerClasses();
  94. // assertEquals(1,innerClassArray.length);
  95. // InnerClass innerClass = innerClassArray[0];
  96. // ConstantPool cp = jc.getConstantPool();
  97. //
  98. // // The value of the inner_class_info_index item must be a valid index into the
  99. // // constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info
  100. // // structure representing C.
  101. // int innerClassIndex = innerClass.getInnerClassIndex();
  102. // ConstantClass cc = (ConstantClass)cp.getConstant(innerClassIndex);
  103. // ConstantUtf8 utf8 = cp.getConstantUtf8(cc.getNameIndex());
  104. // assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue());
  105. //
  106. // // The remaining items in the classes array entry give information about C.
  107. // // The value of the outer_class_info_index item must be a valid index into the
  108. // // constant_pool table, and the entry at that index must be a CONSTANT_Class_info
  109. // // structure representing the class or interface of which C is a member.
  110. // int outerClassIndex = innerClass.getOuterClassIndex();
  111. // cc = (ConstantClass)cp.getConstant(outerClassIndex);
  112. // utf8 = cp.getConstantUtf8(cc.getNameIndex());
  113. // assertEquals("example/aspect/FooAspect",utf8.getStringValue());
  114. //
  115. // // The value of the inner_name_index item must be a valid index into the constant_pool table,
  116. // // and the entry at that index must be a CONSTANT_Utf8_info structure (§4.4.7) that represents
  117. // // the original simple name of C, as given in the source code from which this class file was compiled.
  118. // int innerNameIndex = innerClass.getInnerNameIndex();
  119. // utf8 = cp.getConstantUtf8(innerNameIndex);
  120. // assertEquals("ajcMightHaveAspect",utf8.getStringValue());
  121. //
  122. // int innerAccessFlags = innerClass.getInnerAccessFlags();
  123. // assertEquals(Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags);
  124. //
  125. // // Is InnerClasses attribute well formed for the containing type?
  126. // jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect");
  127. // assertNotNull(jc);
  128. // attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses");
  129. // assertNotNull(attr);
  130. // innerClasses = (InnerClasses)attr;
  131. // innerClassArray = innerClasses.getInnerClasses();
  132. // assertEquals(1,innerClassArray.length);
  133. // innerClass = innerClassArray[0];
  134. // cp = jc.getConstantPool();
  135. // System.out.println(innerClass);
  136. //
  137. // // inner class name
  138. // innerClassIndex = innerClass.getInnerClassIndex();
  139. // cc = (ConstantClass)cp.getConstant(innerClassIndex);
  140. // utf8 = cp.getConstantUtf8(cc.getNameIndex());
  141. // assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue());
  142. //
  143. // // outer class name
  144. // outerClassIndex = innerClass.getOuterClassIndex();
  145. // cc = (ConstantClass)cp.getConstant(outerClassIndex);
  146. // utf8 = cp.getConstantUtf8(cc.getNameIndex());
  147. // assertEquals("example/aspect/FooAspect",utf8.getStringValue());
  148. //
  149. // // Simple name
  150. // innerNameIndex = innerClass.getInnerNameIndex();
  151. // utf8 = cp.getConstantUtf8(innerNameIndex);
  152. // assertEquals("ajcMightHaveAspect",utf8.getStringValue());
  153. //
  154. // // inner modifiers
  155. // innerAccessFlags = innerClass.getInnerAccessFlags();
  156. // assertEquals(Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags);
  157. //
  158. // // Reflection work getDeclaredClasses?
  159. //
  160. // // What about other interfaces?
  161. }
  162. // public void testOverweaving_352389() throws Exception {
  163. // runTest("overweaving");
  164. // }
  165. // ---
  166. public static Test suite() {
  167. return XMLBasedAjcTestCase.loadSuite(Ajc1810Tests.class);
  168. }
  169. @Override
  170. protected File getSpecFile() {
  171. return getClassResource("ajc1810.xml");
  172. }
  173. }