@@ -0,0 +1,19 @@ | |||
public aspect HasField { | |||
declare parents : hasfield(* printer) implements Printable; | |||
public static void main(String[] args) { | |||
C c = new C(); | |||
if (! (c instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasfield failed"); | |||
} | |||
} | |||
} | |||
class C { | |||
int printer; | |||
} | |||
interface Printable {}; |
@@ -0,0 +1,28 @@ | |||
public aspect HasFieldInherited { | |||
declare parents : D && hasfield(* printer) implements Printable; | |||
public static void main(String[] args) { | |||
C c = new C(); | |||
if ((c instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasfield failed on super"); | |||
} | |||
D d = new D(); | |||
if (!(d instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasfield failed on sub"); | |||
} | |||
} | |||
} | |||
class C { | |||
String printer; | |||
} | |||
class D extends C { | |||
} | |||
interface Printable {}; |
@@ -0,0 +1,19 @@ | |||
public aspect HasMethod { | |||
declare parents : hasmethod(* print(..)) implements Printable; | |||
public static void main(String[] args) { | |||
C c = new C(); | |||
if (! (c instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasmethod failed"); | |||
} | |||
} | |||
} | |||
class C { | |||
public void print() {} | |||
} | |||
interface Printable {}; |
@@ -0,0 +1,28 @@ | |||
public aspect HasMethodInherited { | |||
declare parents : D && hasmethod(* print(..)) implements Printable; | |||
public static void main(String[] args) { | |||
C c = new C(); | |||
if ((c instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasmethod failed on super"); | |||
} | |||
D d = new D(); | |||
if (!(d instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasmethod failed on sub"); | |||
} | |||
} | |||
} | |||
class C { | |||
protected void print() {} | |||
} | |||
class D extends C { | |||
} | |||
interface Printable {}; |
@@ -0,0 +1,17 @@ | |||
public aspect HasMethodViaITD { | |||
declare parents : hasmethod(* foo()) implements I; | |||
// C gets foo via ITD | |||
public void C.foo() {} | |||
declare warning : execution(* I+.bar()) : "hasmethod matched on ITD ok"; | |||
} | |||
interface I {} | |||
class C { | |||
void bar() {} | |||
} |
@@ -0,0 +1,28 @@ | |||
public aspect HasPrivateFieldInherited { | |||
declare parents : D && hasfield(* printer) implements Printable; | |||
public static void main(String[] args) { | |||
C c = new C(); | |||
if ((c instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasfield failed on super"); | |||
} | |||
D d = new D(); | |||
if ((d instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasfield failed on sub"); | |||
} | |||
} | |||
} | |||
class C { | |||
private String printer; | |||
} | |||
class D extends C { | |||
} | |||
interface Printable {}; |
@@ -0,0 +1,28 @@ | |||
public aspect HasPrivateMethodInherited { | |||
declare parents : D && hasmethod(* print(..)) implements Printable; | |||
public static void main(String[] args) { | |||
C c = new C(); | |||
if ((c instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasmethod failed on super"); | |||
} | |||
D d = new D(); | |||
if ((d instanceof Printable)) { | |||
throw new RuntimeException("declare parents : hasmethod failed on sub"); | |||
} | |||
} | |||
} | |||
class C { | |||
private void print() {} | |||
} | |||
class D extends C { | |||
} | |||
interface Printable {}; |
@@ -0,0 +1,57 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2004 IBM | |||
* All rights reserved. This program and the accompanying materials | |||
* are made available under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution, and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Adrian Colyer - initial API and implementation | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
public class HasMember extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(HasMember.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
public void testSimpleDecPHasMethod() { | |||
runTest("declare parents : hasmethod(..) - 1"); | |||
} | |||
public void testSimpleDecPHasMethodInherited() { | |||
runTest("declare parents : hasmethod(..) - 2"); | |||
} | |||
public void testSimpleDecPHasMethodInheritedPrivate() { | |||
runTest("declare parents : hasmethod(..) - 3"); | |||
} | |||
public void testDecPHasMethodViaITD() { | |||
runTest("declare parents : hasmethod(..) - 4"); | |||
} | |||
public void testSimpleDecPHasField() { | |||
runTest("declare parents : hasfield(..) - 1"); | |||
} | |||
public void testSimpleDecPHasFieldInherited() { | |||
runTest("declare parents : hasfield(..) - 2"); | |||
} | |||
public void testSimpleDecPHasFieldInheritedPrivate() { | |||
runTest("declare parents : hasfield(..) - 3"); | |||
} | |||
} |