--- /dev/null
+class Basic2 {
+ class Inner {
+ }
+}
+
+aspect Targeter {
+ class Basic2.Inner.InnerInner {
+ }
+}
--- /dev/null
+import java.util.*;
+
+public class Choice {
+ public static void main(String []argv) {
+ System.out.println(Keys.CHOICE);
+ }
+}
+
+aspect X {
+ static List<Choice> choices;
+ public static List forClass() {
+ ArrayList al = new ArrayList();
+ return al;
+ }
+ public static class Choice.Keys {
+ public static final Function<Object, Choice> CHOICE = Get.attrOf(choices,"choice");
+ }
+}
+
+class Get {
+ public static <T> Function<Object,T> attrOf(List<T> t,String s) {
+ return null;
+ }
+}
+
+class Function<A,B> {
+
+}
--- /dev/null
+public class FieldAccess {
+ // static String abc = "hello world";
+ public static void main(String []argv) {
+ System.out.println(Inner.number);
+ }
+}
+
+aspect X {
+ public static class FieldAccess.Inner {
+ static int number = 42;
+ public void m() {
+// System.out.println(abc);
+ }
+ }
+}
--- /dev/null
+public class MethodCall {
+ // static String abc = "hello world";
+ public static void main(String []argv) {
+ System.out.println(Inner.m());
+ }
+}
+
+aspect X {
+ public static class MethodCall.Inner {
+ static int number = 42;
+ public static Integer m() {
+ return number;
+ }
+ }
+}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {
+}
+
+aspect X {
+ class Anno.Inner {
+ Inner() {}
+ }
+}
--- /dev/null
+enum EEE {
+ Red,Green,Blue;
+}
+
+aspect X {
+ class EEE.Inner {
+ Inner() {}
+ }
+}
--- /dev/null
+interface OnInterface {
+}
+
+aspect X {
+ static class OnInterface.Inner {
+ Inner() {}
+ }
+}
--- /dev/null
+class OnlyStatic {
+}
+
+aspect X {
+ class OnlyStatic.Inner {
+ Inner() {}
+ }
+}
--- /dev/null
+aspect Targeter {
+ intertype Basic {}
+ //static aspect C {}
+}
--- /dev/null
+aspect Targeter {
+ intertype Basic {
+ static class Foo {
+ }
+ }
+ //static aspect C {}
+}
--- /dev/null
+aspect Targeter {
+ intertype Basic {
+ public void foo() {} // declared on Basic
+ }
+ //static aspect C {}
+}
+
+class Basic {
+ public static void main(String[] argv) {
+ new Basic().foo();
+ }
+}
--- /dev/null
+public class Simplest4 {
+ // static String abc = "hello world";
+ public static void main(String []argv) {
+ System.out.println(Inner.number);
+ }
+}
+
+aspect X {
+ public static class Simplest4.Inner {
+ static int number = 42;
+ public void m() {
+// System.out.println(abc);
+ }
+ }
+}
// $JUnit-BEGIN$
suite.addTest(Ajc169Tests.suite());
suite.addTest(TransparentWeavingTests.suite());
+ suite.addTest(IntertypeTests.suite());
// $JUnit-END$
return suite;
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2010 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc169;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.util.ClassPath;
+import org.aspectj.apache.bcel.util.SyntheticRepository;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * Tests exploring intertype declared inner types and the new intertype syntax.
+ *
+ * @author Andy Clement
+ */
+public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ // inter type declared classes - working scenarios
+ public void testFieldAccess() throws Exception {
+ runTest("field access");
+ }
+
+ public void testMethodAccess() throws Exception {
+ runTest("method access");
+ }
+
+ public void testRooScenario() throws Exception {
+ runTest("choice");
+ }
+
+ // compiler limitation tests
+ public void testNotAllowedOnInterface() throws Exception {
+ runTest("on interface");
+ }
+
+ public void testNotAllowedOnEnum() throws Exception {
+ runTest("on enum");
+ }
+
+ public void testNotAllowedOnAnnotation() throws Exception {
+ runTest("on annotation");
+ }
+
+ public void testOnlyStatic() throws Exception {
+ runTest("only static");
+ }
+
+ // tests for alternate syntax, not yet supported in the grammar
+
+ // intertype {} syntax
+ // public void testWillItParseEmptyIntertype() throws Exception {
+ // runTest("simplest", true);
+ // }
+ //
+ // public void testWithAnInnerClass() throws Exception {
+ // runTest("simplest 2");
+ // }
+ //
+ // public void testIntertypeMethodInNewStyle() throws Exception {
+ // runTest("simplest 3");
+ // }
+ // --
+
+ public SyntheticRepository createRepos(File cpentry) {
+ ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path"));
+ return SyntheticRepository.getInstance(cp);
+ }
+
+ protected JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException {
+ SyntheticRepository repos = createRepos(where);
+ return repos.loadClass(clazzname);
+ }
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(IntertypeTests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc169/intertype.xml");
+ }
+
+}
\ No newline at end of file
--- /dev/null
+AspectDeclaration.buildInterTypeAndPerClause
+
+EclipseTypeMunger.mungeNewInnerClass
+
+EclipseTypeMunger.findOrCreateInterTypeMemberClassFinder
\ No newline at end of file
--- /dev/null
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <ajc-test dir="features169/itdInnerTypes" title="choice">
+ <compile files="Choice.java" options="-1.5"/>
+ <run class="Choice">
+ <stdout>
+ <line text="null"/>
+ </stdout></run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="field access">
+ <compile files="FieldAccess.java" options="-1.5"/>
+ <run class="FieldAccess">
+ <stdout>
+ <line text="42"/>
+ </stdout></run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="method access">
+ <compile files="MethodCall.java" options="-1.5"/>
+ <run class="MethodCall">
+ <stdout>
+ <line text="42"/>
+ </stdout></run>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="only static">
+ <compile files="OnlyStatic.java" options="-1.5">
+ <message kind="error" line="5" text="Intertype declared member types can only be static (compiler limitation)"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="on interface">
+ <compile files="OnInterface.java" options="-1.5">
+ <message kind="error" line="5" text="Cannot declare new member type on 'OnInterface'. New member types can only be specified on classes (compiler limitation)"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="on enum">
+ <compile files="OnEnum.java" options="-1.5">
+ <message kind="error" line="6" text="Cannot declare new member type on 'EEE'. New member types can only be specified on classes (compiler limitation)"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="on annotation">
+ <compile files="OnAnnotation.java" options="-1.5">
+ <message kind="error" line="8" text="Cannot declare new member type on 'Anno'. New member types can only be specified on classes (compiler limitation)"/>
+ </compile>
+ </ajc-test>
+
+ <!--
+ <ajc-test dir="features169/itdInnerTypes" title="simplest 3">
+ <compile files="Simplest3.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="simplest 2">
+ <compile files="Simplest2.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="features169/itdInnerTypes" title="simplest">
+ <compile files="Simplest.java" options="-1.5"/>
+ </ajc-test>
+ -->
+
+</suite>
\ No newline at end of file