Browse Source

added test cases for old jitterbugs

moved passing tests from ajcTestsFailing to ajcTests
tags/V_1_1_b5
wisberg 21 years ago
parent
commit
8312dfbc60

+ 43
- 7
tests/ajcTests.xml View File

@@ -4234,8 +4234,7 @@

<ajc-test dir="new" pr="694" title="after returning advice param"
keywords="from-resolved_10x">
<compile files="AfterReturningParam.java">
</compile>
<compile files="AfterReturningParam.java"/>
<run class="AfterReturningParam"/>
</ajc-test>

@@ -4331,16 +4330,14 @@
<ajc-test dir="new" pr="573"
title="pertarget stack overflow getting name of anonymous (Interface) class"
keywords="from-resolved_10rc3">
<compile files="PR573.java">
</compile>
<compile files="PR573.java"/>
<run class="PR573"/>
</ajc-test>

<ajc-test dir="new" pr="573"
title="pertarget stack overflow getting name of anonymous (Object) class"
keywords="from-resolved_10rc3">
<compile files="PR573_1.java">
</compile>
<compile files="PR573_1.java"/>
<run class="PR573_1"/>
</ajc-test>

@@ -5105,6 +5102,20 @@
<run class="AssertInAdviceBug" vm="1.4"/>
</ajc-test>

<ajc-test dir="new" pr="823"
title="declaring a private method on an inner interface"
keywords="tofix">
<compile files="PrivateMethodOnInnerInterface.java"/>
<run class="PrivateMethodOnInnerInterface"/>
</ajc-test>

<ajc-test dir="new" pr="829"
title="CE expected when declaring fields on arrays" keywords="tofix">
<compile files="ArrayFieldDeclarationCE.java">
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="pureJava" pr="866"
title="non-constant static final fields marked as final in .class">
<compile files="FinalStaticField.java"/>
@@ -5136,6 +5147,31 @@
<run class="AfterReturningInterfaceConstructor"/>
</ajc-test>

<ajc-test dir="bugs" pr="900"
title="after advice on static call join point">
<compile files="AfterStaticCall.java"/>
<run class="AfterStaticCall"/>
</ajc-test>

<ajc-test dir="bugs" pr="901"
title="incompatible class change error"
comment="XXX Jim and Erik found/fixed this - need basis">
<compile files="IncompatibleClassChangeErrorBug.java"/>
<run class="IncompatibleClassChangeErrorBug"/>
</ajc-test>

<ajc-test dir="bugs" pr="903"
title="simple cflow of method execution">
<compile files="ExecutionCflow.java"/>
<run class="ExecutionCflow"/>
</ajc-test>

<ajc-test dir="bugs" pr="909"
title="using instance as class reference to constant field"
comment="XXX need to verify run">
<compile files="InstanceAsClassRefToConstant.java"/>
</ajc-test>

<!-- .................................... option tests -->
<!-- .................................... -warn tests -->
<ajc-test dir="options"
@@ -5249,7 +5285,7 @@
<compile files="Main.java,injar.jar,Aspect.java"
aspectpath="aspectlib1.jar,aspectlib2.jar"/>
<!-- can't run until we support classpath including the above jars
<run class="Main"/>
<run class="Main"/>
-->
</ajc-test>

+ 13
- 64
tests/ajcTestsFailing.xml View File

@@ -1,7 +1,6 @@

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">


<suite>
<ajc-test dir="new" pr="774"
title="interface self-reference in anonymous instance (correct test in knownbugs)"
@@ -21,14 +20,6 @@
</compile>
</ajc-test>

<ajc-test dir="ng"
title="parenthesized type name as qualifying expr is illegal (in j2sdk1.4.1beta)"
keywords="tofix">
<compile files="Parens1.java">
<message kind="error" line="3"/>
</compile>
</ajc-test>

<ajc-test dir="new" title="expect CE for unterminated declare error"
keywords="tofix">
<compile files="UnterminatedDeclareErrorCE.java">
@@ -50,14 +41,6 @@
<compile files="DominatesTypePattern.java"/>
<run class="DominatesTypePattern"/>
</ajc-test>

<ajc-test dir="ng"
title="long-standing bug in javac and ajc about non-verifiable try stmt"
keywords="tofix">
<compile files="TryVerification.java"/>
<run class="TryVerification"/>
</ajc-test>

<ajc-test dir="new"
title="unmatched type name in a declare parents should result in a warning in -Xlint mode"
keywords="tofix">
@@ -88,20 +71,6 @@
<run class="AfterThrowingNonThrowable"/>
</ajc-test>

<ajc-test dir="new" pr="823"
title="declaring a private method on an inner interface"
keywords="tofix">
<compile files="PrivateMethodOnInnerInterface.java"/>
<run class="PrivateMethodOnInnerInterface"/>
</ajc-test>

<ajc-test dir="new" pr="829"
title="CE expected when declaring fields on arrays" keywords="tofix">
<compile files="ArrayFieldDeclarationCE.java">
<message kind="error" line="14"/>
</compile>
</ajc-test>

<ajc-test dir="new" pr="829" title="declare array field using postfix"
keywords="tofix">
<compile files="ArrayFieldDeclaration.java"/>
@@ -173,47 +142,27 @@
</compile>
<run class="pack.ImportInnerFromInterfaceImplementor"/>
</ajc-test>
<ajc-test dir="ng"
title="wrong scope for inner class creation expression">
<compile files="InnerClassCreate.java"/>
<run class="InnerClassCreate"/>
</ajc-test>

<ajc-test dir="ng"
title="definite unassignment versus try-finally">
<compile files="DefiniteUnassignmentTry.java"/>
<run class="DefiniteUnassignmentTry"/>
</ajc-test>

<ajc-test dir="ng"
title="definite assignment with constant subexpression in control-flow ops">
<compile files="DefiniteAssignmentControlFlow.java">
<dir-changes added="DefiniteAssignmentControlFlow"/>
<ajc-test dir="new"
title="if and cflow arg binding">
<compile files="CflowBinding.java">
<message kind="error" line="13"/>
</compile>
<run class="DefiniteAssignmentControlFlow"/>
</ajc-test>

<ajc-test dir="ng"
title="conversion from null">
<compile files="ConvertFromNull.java">
<message kind="error" line="8"/>
<ajc-test dir="bugs" pr="902"
title="circularity in declare dominates">
<compile files="CircularDominates.java">
<message kind="error" line="18"/>
</compile>
</ajc-test>

<ajc-test dir="ng"
title="conflicting throws on inherited abstract methods">
<compile files="ConflictingThrows.java"/>
<run class="ConflictingThrows"/>
</ajc-test>

<ajc-test dir="new"
title="if and cflow arg binding">
<compile files="CflowBinding.java">
<message kind="error" line="13"/>
<ajc-test dir="bugs" pr="906"
title="privileged access to code outside the control of the compiler">
<compile files="PrivilegeBeyondScope.java">
<message kind="error" line="21"/>
</compile>
<run class="PrivilegeBeyondScope"/>
</ajc-test>

</suite>

+ 22
- 0
tests/bugs/AfterStaticCall.java View File

@@ -0,0 +1,22 @@

import org.aspectj.testing.Tester;

/** @testcase PR#900 after advice on static call jp */
public class AfterStaticCall {
public static void main(String[] args) {
Tester.expectEvent("foo()");
Tester.expectEvent("after() : call(void Test.foo())");
foo();
Tester.checkAllEvents();
}

public static void foo() {
Tester.event("foo()");
}
}

aspect LogFooCall {
after() : call(static void foo()) {
Tester.event("after() : call(void Test.foo())");
}
}

+ 29
- 0
tests/bugs/CircularDominates.java View File

@@ -0,0 +1,29 @@

import org.aspectj.testing.Tester;
import java.util.*;

/** @testcase PR#902 circularity in declare dominates */
public class CircularDominates {

public static void main(String[] args) {
foo();
throw new Error("expected compiler error");
}

public static void foo() {
}
}

aspect BugDemoAspect {
declare dominates : B, A, B; // CE 18
}

aspect A {
before() : target(CircularDominates) && call(static void foo(..)) {
}
}

aspect B {
before() : cflowbelow(execution(static void main(String[]))) {
}
}

+ 22
- 0
tests/bugs/ExecutionCflow.java View File

@@ -0,0 +1,22 @@

import org.aspectj.testing.Tester;
import java.util.*;

/** @testcase PR#903 cflow of execution */
public class ExecutionCflow {

static int field;
public static void main(String[] args) {
field = 0;
Tester.expectEvent("before");
Tester.checkAllEvents();
}
}

aspect A {
before() : cflow(execution(static void main(String[])))
&& set(int field) {
Tester.event("before");
}
}

+ 38
- 0
tests/bugs/IncompatibleClassChangeErrorBug.java View File

@@ -0,0 +1,38 @@

import org.aspectj.testing.Tester;
import org.aspectj.lang.*;
import org.aspectj.lang.reflect.*;

/** @testcase PR#901 IncompatibleClassChangeError bug */
public class IncompatibleClassChangeErrorBug {

public static void main(String[] args) {
Tester.expectEvent("printed");
method1();
Tester.checkAllEvents();
}
public static void method1() {
}
}

aspect JoinpointTestAspect {
before() : call(static void method1()) {
printArgs(thisJoinPoint);
// This call is required to reproduce the bug...
printStaticInfo(thisJoinPointStaticPart);
}

private void printArgs(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
// While the original code had a for() loop to print arguments
// bug can be seen without it...
}
private void printStaticInfo(JoinPoint.StaticPart
joinPointStaticPart) {
Tester.check(null != joinPointStaticPart, "null parm");
Tester.event("printed");
}
}

+ 40
- 0
tests/bugs/InstanceAsClassRefToConstant.java View File

@@ -0,0 +1,40 @@

import org.aspectj.testing.Tester;
import java.util.*;

/** @testcase PR#909 instance as class reference to constant */
public class InstanceAsClassRefToConstant {
public static void main(String[] args) {
throw new Error("XXX not set up to run");
}
}

abstract class CWithLongConst {
public static final long MAX = 1000000;
}

class A extends CWithLongConst {
}

class TestCase {
public final static void main(String[] argv) {
A aL = new A();

// bad error
// a) Sanity check:
// stack size is -1 after stmt BreakStmt(label: null) (warning)
for (long l=0; l<2000000; l+=100000) {
if (l > aL.MAX) {
break;
}
}

// b) Sanity check: stack size is -1 after stmt ExprStmt() (warning)
String[] stringsL = null;
for (long k=0; (k<2000000) && (stringsL == null); k+=100000) {
if (k > aL.MAX) {
stringsL = new String[1];
}
}
}
}

+ 26
- 0
tests/bugs/PrivilegeBeyondScope.java View File

@@ -0,0 +1,26 @@

import java.util.Observable;


/** @testcase PR#906 privileged access out of code the compiler controls */
public class PrivilegeBeyondScope {

public static void main (String[] args) {
new C().get();
throw new Error("expected compiler error");
}
}

class C {
Object get() {return null;}
}

privileged aspect A {
Observable observable = new Observable();

after() returning (Object o ) :
execution(Object C.get()) {
observable.setChanged(); // CE 22 (unable to implement privilege outside C
// CE unable to implement privilege outside code the compiler controls
}
}

Loading…
Cancel
Save