hansel-devel Mailing List for Hansel
Brought to you by:
jiriki
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
(42) |
Jul
(9) |
Aug
|
Sep
|
Oct
(5) |
Nov
(1) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(6) |
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
(48) |
Nov
(2) |
Dec
(3) |
| 2005 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
|
|
From: Niklas M. <ji...@us...> - 2007-09-24 20:57:15
|
jiriki 07/09/24 13:57:04
Modified: src/org/hansel TransformingAdapter.java
Log:
Do not instrument "bridge synthetic" methods.
Revision Changes Path
1.5 +2 -1 hansel/src/org/hansel/TransformingAdapter.java
Index: TransformingAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/TransformingAdapter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TransformingAdapter.java 17 Sep 2006 20:12:39 -0000 1.4
+++ TransformingAdapter.java 24 Sep 2007 20:57:04 -0000 1.5
@@ -80,7 +80,8 @@
}
private boolean isSynthetic(int access) {
- return (access & Opcodes.ACC_SYNTHETIC) != 0;
+ return ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ || ((access & Opcodes.ACC_BRIDGE) != 0);
}
private boolean isPrivateEmptyConstructor(String name,
|
|
From: Niklas M. <ji...@us...> - 2007-09-24 20:41:14
|
jiriki 07/09/24 13:40:59
Modified: . build.xml
Log:
Revision Changes Path
1.55 +1 -1 hansel/build.xml
Index: build.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build.xml,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- build.xml 9 Sep 2006 21:18:55 -0000 1.54
+++ build.xml 24 Sep 2007 20:40:59 -0000 1.55
@@ -1,6 +1,6 @@
<project name="hansel-task" default="compile" basedir=".">
- <property name="hansel.version" value="2.0a2"/>
+ <property name="hansel.version" value="2.0a3"/>
<property name="hansel.name" value="hansel"/>
<property name="hansel.home" value="."/>
<property name="hansel.build" value="build"/>
|
|
From: Niklas M. <ji...@us...> - 2007-09-24 20:41:14
|
jiriki 07/09/24 13:41:00
Modified: src/org/hansel HanselCodeAdapter.java
Log:
Revision Changes Path
1.10 +12 -7 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HanselCodeAdapter.java 4 Oct 2006 20:07:12 -0000 1.9
+++ HanselCodeAdapter.java 24 Sep 2007 20:41:00 -0000 1.10
@@ -22,6 +22,7 @@
public class HanselCodeAdapter extends MethodAdapter {
private boolean first;
private int pos;
+ private int currentLine;
private InsnList instructions;
private String className;
private String methodName;
@@ -47,6 +48,7 @@
this.probes = new Vector<Probe>();
this.tryCatchBlocks = tryCatchBlocks;
this.loader = loader;
+ this.currentLine = 0;
}
private void addProbe(Probe probe) {
@@ -93,29 +95,32 @@
}
private ProbeData getProbeData() {
- return new ProbeData(
+ ProbeData probeData = new ProbeData(
className,
methodName,
frames[pos - 1],
pos,
instructions.size(),
- loader);
+ loader);
+ probeData.setLineNumber(currentLine);
+ return probeData;
}
public void visitLineNumber(int line, Label start) {
super.visitLineNumber(line, start);
- checkFirst();
-
-
- int startIndex = Util.findIndex(instructions, start);
+ checkFirst();
+ int startIndex = Util.findIndex(instructions, start);
for (int i=0; i<probes.size(); i++) {
ProbeData pd = probes.get(i).getProbeData();
+
if (startIndex < pd.getPosition()) {
- pd.setLineNumber(line);
+ pd.setLineNumber(line);
}
}
+
+ currentLine = line;
}
public void visitInsn(final int opcode) {
|
|
From: <mu...@o2...> - 2007-09-23 10:27:24
|
Hello=20 Did=20you=20create=20Hansel=20using=20Test=20Driven=20Development?=20 Definition=20from=20wikipedia.org:=20"Test-Driven=20Development=20(TDD)=20= is=20a=20software=20development=20technique=20that=20involves=20repeatedl= y=20first=20writing=20a=20test=20case=20and=20then=20implementing=20only=20= the=20code=20necessary=20to=20pass=20the=20test"=20 =20 Best=20regards, Przemek |
|
From: SourceForge.net <no...@so...> - 2007-02-08 18:21:20
|
Bugs item #1655425, was opened at 2007-02-08 10:21 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=472899&aid=1655425&group_id=54171 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Hansel 2 & Junit 4 Initial Comment: Trying to follow the examples with setting up Hansel 2 based JUnit 4 tests and I am not able to get the code to execute. I have a simple test: package com.eds.junit; import org.hansel.CoverageRunner; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.runner.JUnitCore; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(CoverageRunner.class) @Suite.SuiteClasses({ SomeTest.class }) @CoverageRunner.CoverClasses({ Some.class }) public class SomeTest { public SomeTest() { } @Test public void xyz() { Some some = new Some(); assertTrue("Test", true); } public static void main(String... arguments) { JUnitCore core = new JUnitCore(); //core.addListener(new SomeListener()); core.run(SomeTest.class); } } That tests an even simpler object: package com.eds.junit; public class Some { public Some() { } } When I execute this code following the steps in the tutorial I get errors, the code works fine without Hansel. We have looked into Hansel 1.x and got proof of concepts working with that, now since we are switching to Java 1.5 we want to start looking at Hansel 2. The results that I'm getting are: D:\>java -classpath "D:\Program Files\Oracle\JDeveloperStudio10.1.3.2\jdev\mywor k\JUnit4Application\JUnit4Project\classes;D:\Tools\junit4.1\junit-4.1.ja r;D:\Too ls\hansel-2.0a3\lib\asm-all-3.0_RC1.jar;D:\Tools\hansel-2.0a3\lib\hansel .jar" -j avaagent:D:/Tools/hansel-2.0a3/lib/hansel.jar com.eds.junit.SomeTest *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 831 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 831 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 831 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 831 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 831 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 831 This Assertion Failed error continues on until IllegalState exceptions start to get thrown: java.lang.IllegalStateException: Inconsistent instrumentation: 9 != 8 at org.hansel.HanselCodeAdapter.visitEnd(HanselCodeAdapter.java:312) at org.objectweb.asm.tree.MethodNode.accept(Unknown Source) at org.objectweb.asm.tree.MethodNode.accept(Unknown Source) at org.objectweb.asm.tree.ClassNode.accept(Unknown Source) at org.hansel.Transformer.transform(Transformer.java:47) at sun.instrument.TransformerManager.transform(Unknown Source) at sun.instrument.InstrumentationImpl.transform(Unknown Source) at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method) at sun.instrument.InstrumentationImpl.redefineClasses(Unknown Source) at org.hansel.Startup.init(Startup.java:97) at org.hansel.CoverageRunner.init(CoverageRunner.java:78) at org.hansel.CoverageRunner.getDescription(CoverageRunner.java:116) at org.junit.internal.runners.CompositeRunner.getDescription(CompositeRu nner.java:36) at org.junit.internal.runners.TestClassRunner.getDescription(TestClassRu nner.java:57) at org.hansel.CoverageRunner.getDescription(CoverageRunner.java:119) at org.junit.internal.runners.CompositeRunner.getDescription(CompositeRu nner.java:36) at org.junit.internal.runners.TestClassRunner.getDescription(TestClassRu nner.java:57) at org.hansel.CoverageRunner.getDescription(CoverageRunner.java:119) at org.junit.internal.runners.CompositeRunner.getDescription(CompositeRu This starts an infinite loop. I'm using the latest JUnit 4 release, however I get the same results if I use the JUnit distibution that is packaged with Hansel. Any help would be appreciated. Thanks, Bob Butash (bob...@ed...) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=472899&aid=1655425&group_id=54171 |
|
From: Niklas M. <ji...@us...> - 2006-10-04 20:08:47
|
jiriki 06/10/04 13:08:44
Modified: src/org/hanseltest TestStackBugs.java
Log:
Removed debug output.
Revision Changes Path
1.8 +1 -7 hansel/src/org/hanseltest/TestStackBugs.java
Index: TestStackBugs.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestStackBugs.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestStackBugs.java 4 Oct 2006 20:07:13 -0000 1.7
+++ TestStackBugs.java 4 Oct 2006 20:08:44 -0000 1.8
@@ -56,15 +56,9 @@
HanselFrame[] hanselFrames = new HanselFrame[frames.length];
for (int i=0; i<frames.length; i++) {
hanselFrames[i] = (HanselFrame) frames[i];
- }
-
- System.out.println("---------------------------");
- for (HanselFrame frame : hanselFrames) {
- System.out.println("Hubba: " + frame);
- }
+ }
for (int i=hanselFrames.length - 2; i>0; i--) {
- System.out.println(i + " -> " + hanselFrames[i].getStackSize());
if (hanselFrames[i].getStackSize() > 0) {
return hanselFrames[i].pop().toString();
}
|
|
From: Niklas M. <ji...@us...> - 2006-10-04 20:07:18
|
jiriki 06/10/04 13:07:13
Modified: src/org/hansel/stack StackFactory.java OrOrOp.java
doc coverage.html
src/org/hansel HanselInterpreter.java HanselCodeAdapter.java
Transformer.java
src/org/hanseltest TestStackBugs.java
lib junit.jar
. Readme.html .cvsignore
src/org/hanselexample ExampleJUnit4Test.java
Added: doc eclipse-2.gif tutorial4.html eclipse-1.gif
eclipse.html
Removed: src/org/hansel/stack EmptyStackException.java ComplexOr.java
SymbolicStack.java
src/org/hanseltest/stack SymbolicStackTest.java
StackEntryTest.java StackTest.java
InstructionStats.java
src/org/hanseltest TestBug608057.java
Log:
Documentation/Cleanup.
Revision Changes Path
1.14 +43 -12 hansel/src/org/hansel/stack/StackFactory.java
Index: StackFactory.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/StackFactory.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- StackFactory.java 5 Sep 2004 13:52:53 -0000 1.13
+++ StackFactory.java 4 Oct 2006 20:07:12 -0000 1.14
@@ -1,9 +1,12 @@
-package org.hansel.stack;
+package org.hansel.stack;
+import java.util.Hashtable;
+import java.util.SortedSet;
+import java.util.TreeSet;
public class StackFactory {
- /*private Hashtable result;
+ /* private Hashtable result;
private InstructionList il;
private SortedSet workList;
private MethodGen method;
@@ -52,8 +55,11 @@
wle.getStack());
}
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (NullPointerException e) {
+ logBugWarning(e);
+ } catch (UnsupportedOperationException e) {
+ logBugWarning(e);
+ } catch (EmptyStackException e) {
logBugWarning(e);
}
}
@@ -104,17 +110,27 @@
return true;
}
- private boolean assertTargeters(InstructionTargeter[] targeter) {
- // The "iconst" should be targeted by 1 (!) or 2 (&&, ||) branch instructions
- if (targeter.length > 2) {
+ private boolean isComplexOperator2(InstructionHandle[] instrs) {
+ if (!((instrs[1].getInstruction() instanceof ICONST) &&
+ (instrs[2].getInstruction() instanceof GOTO) &&
+ (instrs[3].getInstruction() instanceof ICONST))) {
+ return false;
+ }
+
+ int value1 = ((ICONST) instrs[1].getInstruction()).getValue().intValue();
+ int value2 = ((ICONST) instrs[3].getInstruction()).getValue().intValue();
+
+ if ((value1 != 0) || (value2 != 1)) {
return false;
}
-
- for (int i=0; i<targeter.length; i++) {
- if (!(targeter[i] instanceof BranchInstruction)) {
- return false;
- }
+
+ if (((IfInstruction) instrs[0].getInstruction()).getTarget() != instrs[3]) {
+ return false;
}
+
+ if (((GOTO) instrs[2].getInstruction()).getTarget() != instrs[4]) {
+ return false;
+ }
return true;
}
@@ -161,6 +177,21 @@
newStack = newStack.push(newEntry);
addWorkList(instructions[4], newStack);
}
+ else if (isComplexOperator2(instructions)) {
+ StackEntry newEntry = new ComplexOr(instructions[1],
+ result,
+ il).getStackEntry();
+ newEntry = new NotOp(newEntry);
+
+ SymbolicStack newStack = stack;
+ int consume = ((IfInstruction) ih.getInstruction()).consumeStack(null);
+ for (int i=0; i<consume; i++) {
+ newStack = newStack.pop();
+ }
+
+ newStack = newStack.push(newEntry);
+ addWorkList(instructions[4], newStack);
+ }
}
private void calculateStackEntries(InstructionHandle ih,
1.4 +1 -30 hansel/src/org/hansel/stack/OrOrOp.java
Index: OrOrOp.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/OrOrOp.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OrOrOp.java 5 Sep 2004 13:52:53 -0000 1.3
+++ OrOrOp.java 4 Oct 2006 20:07:12 -0000 1.4
@@ -43,36 +43,7 @@
i++;
}
}
-
- /* if (op1 instanceof AndAndOp) {
- AndAndOp and1 = (AndAndOp) op1;
- HanselValue and11 = and1.getOperator1();
-
- if (op2 instanceof AndAndOp) {
- AndAndOp and2 = (AndAndOp) op2;
- String term = and2.getOperator1().toString();
-
- HanselValue eliminated = eliminate(and1, term);
- if (eliminated != and1) {
- HanselValue result = new AndAndOp(and2.getOperator1(),
- new OrOrOp(eliminated,
- and2.getOperator2()));
-
- if (result.toString().length() < this.toString().length()) {
- return result.compress();
- }
- }
- } else if (op2 instanceof NotOp) {
- HanselValue notTerm = ((NotOp) op2).getEntry();
- HanselValue eliminated = eliminate(and1, notTerm.toString());
- if (eliminated != and1) {
- return new NotOp(new AndAndOp(eliminated, notTerm));
- }
- }
- }
-
- return super.compress();*/
-
+
return result;
}
1.4 +0 -3 hansel/doc/coverage.html
Index: coverage.html
===================================================================
RCS file: /cvsroot/hansel/hansel/doc/coverage.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- coverage.html 28 Aug 2002 16:58:21 -0000 1.3
+++ coverage.html 4 Oct 2006 20:07:12 -0000 1.4
@@ -26,8 +26,5 @@
with <i>a</i> beeing true, one time with <i>a</i> beeing false. But to
achieve basic block coverage it is sufficient to call the code with <i>a</i>
beeing true.
- <p>
- Starting with version 0.5 hansel supports decision coverage. Older version use
- basic block coverage.
</body>
</html>
\ No newline at end of file
1.1 hansel/doc/eclipse-2.gif
<<Binary file>>
1.1 hansel/doc/tutorial4.html
<html>
<head>
<title> Hansel Tutorial </title>
</head>
<body>
<center><h1> Hansel Tutorial </h1></center>
This tutorial assumes that you are familiar with
<a href="http://www.junit.org"> JUnit 4</a> and shows the way to add
code coverage testing to an existing JUnit TestCase.
<h3> Start </h3>
Let's assume that we want to test the Example class:
<pre>
public class Example {
public int abs(int i) {
if (i > 0) {
return i;
} else {
return -i;
}
}
}
</pre>
We have an existing JUnit4 TestCase:
<pre>
public class ExampleJUnit4Test {
@Test public void absTest() {
Example example = new Example();
assertEquals("abs(1) should be 1.", 1, example.abs(1));
assertEquals("abs(0) should be 0.", 0, example.abs(0));
}
/**
* Test the Example.add() method. This also covers the code of the inner
* class.
*/
@Test public void innerClassTest() {
Example example = new Example();
assertEquals("add(2, 3) should be 5.", 5, example.add(2, 3));
}
}
</pre>
<h3> Adding Code Coverage Testing </h3>
Since we are not sure, that the test covers all lines of the Example class,
we want to make sure and add coverage testing to the test case.
So we create a new coverage suite:
<pre>
@RunWith(CoverageRunner.class)
@Suite.SuiteClasses({ ExampleJUnit4Test.class })
@CoverageRunner.CoverClasses({ Example.class })
public class ExampleJUnit4Suite {
}
</pre>
<h3> Running the Test </h3>
Now we are ready to run the test. Instead of running the test
directly, we start the test suite. Also the parameter
"-javaagent:hansel.jar" has to be passed to the VM running the
Testsuite (how to do this in exlipse is described <a
href="eclipse.html">here</a>).
When running the suite we unfortunatly get an failure:
<pre>
Test 'org.hanselexample.ExampleTest' does not cover line(s) [20] in org.hanselexample.Example.abs(I)I.
</pre>
Looking at the code, the mistake we made is obvious: We didn't test the
absolute value of a negativ number.
After correcting the test method:
<pre>
@Test public void absTest() {
Example example = new Example();
assertEquals("abs(1) should be 1.", 1, example.abs(1));
assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
assertEquals("abs(0) should be 0.", 0, example.abs(0));
}
</pre>
the test runs without any problems.
<h3> Beware </h3>
Covering all the code of a class with a test case does not mean, there are no
bugs. Writing good test cases is still hard, but I hope Hansel will help to
make life a little easier.
</body>
</html>
1.1 hansel/doc/eclipse-1.gif
<<Binary file>>
1.1 hansel/doc/eclipse.html
<html>
<head>
<title> Running Hansel Coverage Suites in Eclipse </title>
</head>
<body>
<center><h1>Running Hansel Coverage Suites in Eclipse</h1></center>
To run a Coverage Suite in eclipse select "Run" from the context menu:
<p>
<img src="eclipse-1.gif"/>
<p>
Then specify the javaagent-parameter in the VM-arguments:
<p>
<img src="eclipse-2.gif"/>
</body>
</html>
1.6 +3 -6 hansel/src/org/hansel/HanselInterpreter.java
Index: HanselInterpreter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselInterpreter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- HanselInterpreter.java 19 Aug 2006 21:07:52 -0000 1.5
+++ HanselInterpreter.java 4 Oct 2006 20:07:12 -0000 1.6
@@ -125,12 +125,7 @@
while (it.hasNext()) {
LocalVariableNode lvn = (LocalVariableNode) it.next();
- /*System.out.println("lvn: " + lvn);
- System.out.println("lvn.index: " + lvn.index);
- System.out.println("indec: " + index);
- System.out.println("indec: " + instructions.size());
- System.out.println("indec: " + instructions.indexOf(lvn.end));
- */
+
// TODO: FixMe....
if ((lvn.index == index) /*&&
(insnIndex > instructions.indexOf(lvn.start)) &&
@@ -290,6 +285,8 @@
if ((cst instanceof Double) || (cst instanceof Long)) {
return new HanselValue(cst.toString(), false, 2);
+ } else if (cst instanceof String) {
+ return new HanselValue("\"" + cst.toString() + "\"", false, 1);
} else {
return new HanselValue(cst.toString(), false, 1);
}
1.9 +3 -1 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HanselCodeAdapter.java 17 Sep 2006 20:12:39 -0000 1.8
+++ HanselCodeAdapter.java 4 Oct 2006 20:07:12 -0000 1.9
@@ -221,7 +221,9 @@
private boolean isExceptionHandler(Label l) {
Iterator it = tryCatchBlocks.iterator();
while (it.hasNext()) {
- if (((TryCatchBlockNode) it.next()).handler.getLabel() == l) {
+ TryCatchBlockNode tryCatchBlockNode = ((TryCatchBlockNode) it.next());
+ if (tryCatchBlockNode.handler.getLabel() == l &&
+ (tryCatchBlockNode.type != null)) {
return true;
}
}
1.7 +1 -1 hansel/src/org/hansel/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Transformer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Transformer.java 17 Sep 2006 20:12:39 -0000 1.6
+++ Transformer.java 4 Oct 2006 20:07:12 -0000 1.7
@@ -51,7 +51,7 @@
classfileBuffer));
byte[] result = cw.toByteArray();
- if (cn.name.endsWith("EventQueue")) {
+ if (cn.name.endsWith("Example")) {
FileOutputStream out = new FileOutputStream("test.class");
out.write(result);
out.close();
1.7 +67 -35 hansel/src/org/hanseltest/TestStackBugs.java
Index: TestStackBugs.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestStackBugs.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestStackBugs.java 5 Sep 2004 13:52:55 -0000 1.6
+++ TestStackBugs.java 4 Oct 2006 20:07:13 -0000 1.7
@@ -1,60 +1,88 @@
package org.hanseltest;
+import java.io.InputStream;
+
import junit.framework.TestCase;
+import org.hansel.HanselFrame;
+import org.hansel.HanselInterpreter;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.MethodNode;
+import org.objectweb.asm.tree.analysis.Analyzer;
+import org.objectweb.asm.tree.analysis.AnalyzerException;
+import org.objectweb.asm.tree.analysis.Frame;
+
/**
* This is a combined testcase for bugs 755796, 755797, 755768, 755798
* and RFE 744114.
*/
public class TestStackBugs extends TestCase {
- /*private ClassLoaderRepository repository;
- private JavaClass javaClass;
- private Method[] methods;
- private ConstantPoolGen cpg;
+ private ClassNode classNode;
+
public TestStackBugs(String name) {
super(name);
}
public void setUp() throws Exception {
- repository = new ClassLoaderRepository(getClass().getClassLoader());
- javaClass = repository.loadClass(Example.class.getName());
- methods = javaClass.getMethods();
- cpg = new ConstantPoolGen(javaClass.getConstantPool());
+ InputStream resourceAsStream = getClass().getResourceAsStream("TestStackBugs$Example.class");
+ ClassReader cr = new ClassReader(resourceAsStream);
+
+ classNode = new ClassNode();
+ cr.accept(classNode, 0);
}
private String getResultToString(String methodName,
- int relIndex) {
- for (int i=0; i<methods.length; i++) {
- if (methods[i].getName().equals(methodName)) {
- MethodGen methodGen = new MethodGen(methods[i], Example.class.getName(),
- cpg);
- InstructionList il = methodGen.getInstructionList();
- InstructionHandle ih = il.getEnd();
- for (int j=0; j<relIndex; j++) {
- ih = ih.getPrev();
+ int relIndex) throws AnalyzerException {
+ for (Object method : classNode.methods) {
+ MethodNode methodNode = (MethodNode) method;
+
+ if (methodNode.name.equals(methodName)) {
+ Analyzer analyzer =
+ new Analyzer(new HanselInterpreter(methodNode.localVariables)) {
+ protected Frame newFrame (final int nLocals, final int nStack) {
+ return new HanselFrame(nLocals, nStack);
+ }
+
+ protected Frame newFrame (final Frame src) {
+ return new HanselFrame((HanselFrame) src);
+ }
+ };
+
+ Frame[] frames = analyzer.analyze(classNode.name, methodNode);
+ HanselFrame[] hanselFrames = new HanselFrame[frames.length];
+ for (int i=0; i<frames.length; i++) {
+ hanselFrames[i] = (HanselFrame) frames[i];
}
- StackFactory sf = new StackFactory(methodGen);
- sf.calculateMethodStacks();
- Hashtable stacks = sf.getResult();
-
- SymbolicStack stack = (SymbolicStack) stacks.get(ih);
- return stack.getTopEntry().toString();
+
+ System.out.println("---------------------------");
+ for (HanselFrame frame : hanselFrames) {
+ System.out.println("Hubba: " + frame);
+ }
+
+ for (int i=hanselFrames.length - 2; i>0; i--) {
+ System.out.println(i + " -> " + hanselFrames[i].getStackSize());
+ if (hanselFrames[i].getStackSize() > 0) {
+ return hanselFrames[i].pop().toString();
+ }
+
+ }
+ throw new IllegalStateException("Didn't find result: " + methodName);
}
}
throw new IllegalArgumentException("Unknown method: " + methodName);
}
-*/
- public void testBug755796() {
- // assertEquals("\"testString\"", getResultToString("bug755796", 0));
+
+ public void testBug755796() throws AnalyzerException {
+ assertEquals("\"testString\"", getResultToString("bug755796", 0));
}
- public void testBug755797() {
- throw new UnsupportedOperationException("Not yet converted");
-/* assertEquals("!(a | b)", getResultToString("bug755797", 1));
+ public void testBug755797() throws AnalyzerException {
+ assertEquals("!(a | b)", getResultToString("bug755797", 1));
assertEquals("!a", getResultToString("bug755797a", 1));
assertEquals("!(a & b)", getResultToString("bug755797b", 1));
assertEquals("!(a && b)", getResultToString("bug755797c", 1));
@@ -63,10 +91,10 @@
assertEquals("a", getResultToString("bug755797f", 1));
assertEquals("a & b", getResultToString("bug755797g", 1));
assertEquals("a && b", getResultToString("bug755797h", 1));
- assertEquals("a || b", getResultToString("bug755797i", 1));*/
+ assertEquals("a || b", getResultToString("bug755797i", 1));
}
- /*public void testBug755768() {
+ public void testBug755768() throws AnalyzerException {
assertEquals("obj1 != obj2", getResultToString("bug755768", 1));
assertEquals("obj1 == obj2", getResultToString("bug755768a", 1));
assertEquals("a >= b", getResultToString("bug755768b", 1));
@@ -75,12 +103,12 @@
assertEquals("a < b", getResultToString("bug755768e", 1));
}
- public void testBug755798() {
+ public void testBug755798() throws AnalyzerException {
assertEquals("c1.getName().length() == 123 == c2.getName().length() == 234",
getResultToString("bug755798", 1));
}
- public void testRFE744114() {
+ public void testRFE744114() throws AnalyzerException {
assertEquals("this.testMethod(true)",
getResultToString("rfe744114", 1));
assertEquals("this.testMethod(false)",
@@ -95,7 +123,7 @@
* 0: ldc #2; //String testString
* 2: areturn
*/
- /* return "testString";
+ return "testString";
}
public void bug755797(boolean a, boolean b) {
@@ -181,6 +209,10 @@
public void rfe744114a() {
boolVar = testMethod(false);
}
+
+ public boolean getResult() {
+ return boolVar;
+ }
}
- */
+
}
1.6 +730 -419 hansel/lib/junit.jar
<<Binary file>>
1.29 +12 -6 hansel/Readme.html
Index: Readme.html
===================================================================
RCS file: /cvsroot/hansel/hansel/Readme.html,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Readme.html 15 Jan 2004 20:38:40 -0000 1.28
+++ Readme.html 4 Oct 2006 20:07:13 -0000 1.29
@@ -5,7 +5,7 @@
</head>
<body>
@logo@
- <center> <h1> Hansel 1.03</h1> </center>
+ <center> <h1> Hansel 2.0</h1> </center>
<h3>About</h3>
<a href="http://hansel.sourceforge.net/"> Hansel </a> is an extension to
<a href="http://www.junit.org"> JUnit </a> that
@@ -26,7 +26,7 @@
<h3>Differences</h3>
What makes Hansel different from other code coverage tools? Most tools
- (that I know of) try to generate code coverage reports from a test-run of all
+ try to generate code coverage reports from a test-run of all
available tests.
<p>
But a much more useful information is how much of the code which a test
@@ -34,6 +34,14 @@
Hansel gives you this information.
<h3>Requirements</h3>
+ <h2>Hansel 2.X</h2>
+ Hansel requires <a href="http://java.sun.com"> Java 1.5 </a>,
+ <a href="http://www.junit.org"> JUnit 4</a> and
+ <a href="http://asm.objectweb.org/"> ASM </a> to run.
+ To build Hansel, <a href="http://jakarta.apache.org/ant/index.html">
+ Ant</a> and JDK 1.5 is needed.
+
+ <h2>Hansel 1.X</h2>
Hansel requires <a href="http://java.sun.com"> Java </a>,
<a href="http://www.junit.org"> JUnit </a> and
<a href="http://jakarta.apache.org/bcel/index.html"> BCEL 5.0 </a> to run.
@@ -41,10 +49,8 @@
Ant</a> and JDK 1.4 is needed.
<h3>Documentation</h3>
- There is a short <a href="doc/tutorial.html"> tutorial </a> on using
- Hansel. When using classloaders
- other than the system classloader, there are some issues. Therefore there is a document on
- <a href="doc/classloaders.html">Hansel and Classloaders</a>.
+ There is a short <a href="doc/tutorial4.html"> tutorial </a> on using
+ Hansel with JUnit 4 (and <a href="doc/tutorial.html"> JUnit 3.8 </a>).
<p>
Also take a look at the <a href="doc/FAQ.html"> FAQ </a>, the documentation of the
<a href="doc/antTask.html"> Ant Task </a> and
1.5 +1 -0 hansel/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /cvsroot/hansel/hansel/.cvsignore,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- .cvsignore 21 Jun 2003 21:28:44 -0000 1.4
+++ .cvsignore 4 Oct 2006 20:07:13 -0000 1.5
@@ -3,3 +3,4 @@
debug
junit*.properties
debugTest.sh
+test.class
1.3 +3 -4 hansel/src/org/hanselexample/ExampleJUnit4Test.java
Index: ExampleJUnit4Test.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanselexample/ExampleJUnit4Test.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExampleJUnit4Test.java 17 Sep 2006 20:12:39 -0000 1.2
+++ ExampleJUnit4Test.java 4 Oct 2006 20:07:13 -0000 1.3
@@ -15,8 +15,8 @@
@Test public void absTest() {
Example example = new Example();
assertEquals("abs(1) should be 1.", 1, example.abs(1));
- //assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
- //assertEquals("abs(0) should be 0.", 0, example.abs(0));
+ assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
+ assertEquals("abs(0) should be 0.", 0, example.abs(0));
}
/**
@@ -26,6 +26,5 @@
@Test public void innerClassTest() {
Example example = new Example();
assertEquals("add(2, 3) should be 5.", 5, example.add(2, 3));
- }
-
+ }
}
|
|
From: Niklas M. <ji...@us...> - 2006-09-17 20:12:45
|
jiriki 06/09/17 13:12:39
Modified: src/org/hansel HanselCodeAdapter.java Transformer.java
ProbeData.java TransformingAdapter.java
ProbeTable.java CoverageRunner.java Probe.java
src/org/hanselexample ExampleJUnit4Test.java
Log:
Fixed JUnit4 Description of CoverageRunner.
Revision Changes Path
1.8 +5 -2 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HanselCodeAdapter.java 9 Sep 2006 21:18:54 -0000 1.7
+++ HanselCodeAdapter.java 17 Sep 2006 20:12:39 -0000 1.8
@@ -30,10 +30,11 @@
private List tryCatchBlocks;
private Probe methodProbe;
private int access;
+ private ClassLoader loader;
public HanselCodeAdapter(int access, String className,
String methodName, InsnList instructions, List tryCatchBlocks, MethodVisitor mv,
- HanselFrame[] frames) {
+ HanselFrame[] frames, ClassLoader loader) {
super(mv);
this.access = access;
@@ -45,6 +46,7 @@
this.frames = frames;
this.probes = new Vector<Probe>();
this.tryCatchBlocks = tryCatchBlocks;
+ this.loader = loader;
}
private void addProbe(Probe probe) {
@@ -96,7 +98,8 @@
methodName,
frames[pos - 1],
pos,
- instructions.size());
+ instructions.size(),
+ loader);
}
public void visitLineNumber(int line, Label start) {
1.6 +1 -1 hansel/src/org/hansel/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Transformer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Transformer.java 19 Aug 2006 21:07:52 -0000 1.5
+++ Transformer.java 17 Sep 2006 20:12:39 -0000 1.6
@@ -42,7 +42,7 @@
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
- TransformingAdapter ta = new TransformingAdapter(cw, cn);
+ TransformingAdapter ta = new TransformingAdapter(cw, cn, loader);
cn.accept(ta);
1.9 +8 -1 hansel/src/org/hansel/ProbeData.java
Index: ProbeData.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeData.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ProbeData.java 25 May 2006 10:40:00 -0000 1.8
+++ ProbeData.java 17 Sep 2006 20:12:39 -0000 1.9
@@ -9,17 +9,20 @@
private int pos;
private int size;
private HanselFrame frame;
+ private ClassLoader loader;
public ProbeData(String classname,
String methodname,
HanselFrame frame,
int pos,
- int size) {
+ int size,
+ ClassLoader loader) {
this.classname = classname;
this.methodname = methodname;
this.pos = pos;
this.size = size;
this.frame = frame;
+ this.loader = loader;
}
public void setLineNumber(int lineNumber) {
@@ -91,4 +94,8 @@
^ (pos << 16)
^ (size);
}
+
+ public Class getTargetClass() throws ClassNotFoundException {
+ return loader.loadClass(getClassName());
+ }
}
1.4 +5 -2 hansel/src/org/hansel/TransformingAdapter.java
Index: TransformingAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/TransformingAdapter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransformingAdapter.java 19 Aug 2006 21:07:52 -0000 1.3
+++ TransformingAdapter.java 17 Sep 2006 20:12:39 -0000 1.4
@@ -13,10 +13,13 @@
public class TransformingAdapter extends ClassAdapter {
private ClassNode classNode;
+ private ClassLoader loader;
- public TransformingAdapter(final ClassVisitor cv, final ClassNode classNode) {
+ public TransformingAdapter(final ClassVisitor cv, final ClassNode classNode,
+ ClassLoader loader) {
super(cv);
this.classNode = classNode;
+ this.loader = loader;
}
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
@@ -69,7 +72,7 @@
mn.instructions, mn.tryCatchBlocks,
cv.visitMethod(access, name, desc, signature,
exceptions),
- hanselFrames);
+ hanselFrames, loader);
} catch (AnalyzerException e) {
e.printStackTrace();
throw new IllegalStateException(classNode.name + "." + name, e);
1.25 +13 -8 hansel/src/org/hansel/ProbeTable.java
Index: ProbeTable.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeTable.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ProbeTable.java 9 Sep 2006 21:18:54 -0000 1.24
+++ ProbeTable.java 17 Sep 2006 20:12:39 -0000 1.25
@@ -172,27 +172,32 @@
clear();
}
- public void run(RunNotifier result, boolean hasErrors) {
+ public void addProbeDescriptions(Description coverageDesc) throws ClassNotFoundException {
+ for (Probe probe : probes) {
+ coverageDesc.addChild(probe.getDescription());
+ }
+ }
+
+ public void run(RunNotifier result, Description coverageDescription, boolean hasErrors)
+ throws ClassNotFoundException {
// Only add coverage problems, if the test did not cause
// any other errors/failures.
if (!hasErrors) {
int covered = getCovered();
- int count = getSize();
+ int count = getSize();
for (Probe probe : probes) {
- probe.run(result);
+ probe.run(result, coverageDescription);
}
if (displayStatistics && (covered != count)) {
String msg = "Coverage Test failed: Only " + covered + " of "
+ count + " probes covered.";
- result.fireTestFailure(new Failure(
- Description.createSuiteDescription("coverage"),
+ result.fireTestFailure(new Failure(coverageDescription,
new AssertionFailedError(msg)));
}
} else {
String msg = "Coverage Failure: No coverage test performed, "
+ "because test failed.";
- result.fireTestFailure(new Failure(
- Description.createSuiteDescription("coverage"),
+ result.fireTestFailure(new Failure(coverageDescription,
new AssertionFailedError(msg)));
}
@@ -231,7 +236,7 @@
}
return covered;
- }
+ }
}
1.2 +48 -17 hansel/src/org/hansel/CoverageRunner.java
Index: CoverageRunner.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/CoverageRunner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CoverageRunner.java 9 Sep 2006 21:18:54 -0000 1.1
+++ CoverageRunner.java 17 Sep 2006 20:12:39 -0000 1.2
@@ -15,6 +15,9 @@
public class CoverageRunner extends Suite {
private ProbeTable probeTable;
private Class[] coveredClasses;
+ private Description desc;
+ private Description coverageDesc;
+ private boolean initialized;
/**
* The <code>CoverClasses</code> annotation specifies the classes to be covered
@@ -33,6 +36,7 @@
super(klass);
this.probeTable = new ProbeTable(null);
this.coveredClasses = getCoveredClasses(klass);
+ this.initialized = false;
}
private static Class[] getCoveredClasses(Class<?> klass) throws InitializationError {
@@ -55,9 +59,8 @@
@Override
public void run(RunNotifier notifier) {
- if (!init(notifier)) {
- return;
- }
+ init();
+
CheckFailureRunListener listener = new CheckFailureRunListener();
notifier.addListener(listener);
super.run(notifier);
@@ -65,31 +68,31 @@
shutdown(notifier, listener.hasFailures());
}
- protected boolean init(RunNotifier result) {
- ProbeTable.setProbeTable(probeTable);
-
+ protected void init() {
+ if (initialized) {
+ return;
+ }
+
try {
+ ProbeTable.setProbeTable(probeTable);
Startup.init(toStringSet(coveredClasses));
+ initialized = true;
} catch (Exception e) {
- result.fireTestFailure(
- new Failure(Description.createSuiteDescription("coverage"), e));
- return false;
+ throw new IllegalStateException(e);
}
-
- return true;
}
protected void shutdown(RunNotifier result, boolean hasErrors) {
try {
loadClasses();
Startup.tearDown();
-
- probeTable.run(result, hasErrors);
+
+ result.fireTestStarted(getCoverageDescription());
+ probeTable.run(result, getCoverageDescription(), hasErrors);
} catch (Exception e) {
- result.fireTestFailure(
- new Failure(Description.createSuiteDescription("coverage"),
- e));
-
+ result.fireTestFailure(new Failure(getCoverageDescription(), e));
+ } finally {
+ result.fireTestFinished(getCoverageDescription());
}
}
@@ -99,4 +102,32 @@
clazz.getDeclaredFields();
}
}
+
+ public Description getCoverageDescription() {
+ if (coverageDesc == null) {
+ coverageDesc = Description.createSuiteDescription("Coverage");
+ }
+
+ return coverageDesc;
+ }
+
+ @Override
+ public Description getDescription() {
+ init();
+
+ if (this.desc == null) {
+ desc = super.getDescription();
+
+ desc.addChild(getCoverageDescription());
+
+ try {
+ probeTable.addProbeDescriptions(getCoverageDescription());
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ return desc;
+ }
+
}
1.24 +14 -8 hansel/src/org/hansel/Probe.java
Index: Probe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Probe.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Probe.java 9 Sep 2006 21:18:54 -0000 1.23
+++ Probe.java 17 Sep 2006 20:12:39 -0000 1.24
@@ -21,6 +21,7 @@
private ProbeData pd;
private int id;
+ private Description description;
/**
* Create a new Probe.
@@ -88,16 +89,13 @@
result.endTest(this);
}
- public void run(RunNotifier result) {
- Description desc = Description.createTestDescription(getClass(),
- toString());
- result.fireTestStarted(desc);
-
+ public void run(RunNotifier result, Description coverageDescription )
+ throws ClassNotFoundException {
+ result.fireTestStarted(getDescription());
if (displayFailure()) {
- result.fireTestFailure(new Failure(desc, new CoverageError(pd)));
+ result.fireTestFailure(new Failure(getDescription(), new CoverageError(pd)));
}
-
- result.fireTestFinished(desc);
+ result.fireTestFinished(getDescription());
}
public String getName() {
@@ -136,4 +134,12 @@
}
}
+
+ public Description getDescription() throws ClassNotFoundException {
+ if (description == null) {
+ description = Description.createTestDescription(
+ pd.getTargetClass(), getName());
+ }
+ return description;
+ }
}
1.2 +3 -3 hansel/src/org/hanselexample/ExampleJUnit4Test.java
Index: ExampleJUnit4Test.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanselexample/ExampleJUnit4Test.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExampleJUnit4Test.java 9 Sep 2006 21:18:55 -0000 1.1
+++ ExampleJUnit4Test.java 17 Sep 2006 20:12:39 -0000 1.2
@@ -15,9 +15,9 @@
@Test public void absTest() {
Example example = new Example();
assertEquals("abs(1) should be 1.", 1, example.abs(1));
- assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
- assertEquals("abs(0) should be 0.", 0, example.abs(0));
- }
+ //assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
+ //assertEquals("abs(0) should be 0.", 0, example.abs(0));
+ }
/**
* Test the Example.add() method. This also covers the code of the inner
|
|
From: Niklas M. <ji...@us...> - 2006-09-09 21:18:58
|
jiriki 06/09/09 14:18:55
Modified: src/org/hansel AntCoverageTask.java CoverageDecorator.java
Probe.java HanselCodeAdapter.java ProbeTable.java
. .classpath build.xml
src/org/hanseltest CoverAssertion.java TestAssertions.java
src/org/hanselexample ExampleTest.java
Added: src/org/hansel CoverageRunner.java
CheckFailureRunListener.java
src/org/hanselexample ExampleJUnit4Suite.java
ExampleJUnit4Test.java
Log:
Added junit 4.0 support.
Revision Changes Path
1.15 +6 -6 hansel/src/org/hansel/AntCoverageTask.java
Index: AntCoverageTask.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/AntCoverageTask.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AntCoverageTask.java 19 Aug 2006 21:07:52 -0000 1.14
+++ AntCoverageTask.java 9 Sep 2006 21:18:54 -0000 1.15
@@ -155,7 +155,7 @@
return testDirectory("Package", packageName);
}
- private void findClasses(String packageName, Set addTo) {
+ private void findClasses(String packageName, Set<Class> addTo) {
File packageFile = getPackageFile(packageName);
File[] classes = packageFile.listFiles(CLASS_FILTER);
@@ -174,9 +174,9 @@
}
- private Set createPackageSet(String path,
+ private Set<String> createPackageSet(String path,
String packageNames) {
- HashSet result = new HashSet();
+ HashSet<String> result = new HashSet<String>();
if (packageNames == null) {
return result;
@@ -299,10 +299,10 @@
return result;
}
- private Set getClassesToCover(Set classes) {
- Set result = createSortedSet();
+ private Set getClassesToCover(Set<Class> classes) {
+ Set<Class> result = createSortedSet();
- Iterator it = classes.iterator();
+ Iterator<Class> it = classes.iterator();
while (it.hasNext()) {
Class next = (Class) it.next();
1.28 +8 -8 hansel/src/org/hansel/CoverageDecorator.java
Index: CoverageDecorator.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/CoverageDecorator.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- CoverageDecorator.java 25 May 2006 10:40:00 -0000 1.27
+++ CoverageDecorator.java 9 Sep 2006 21:18:54 -0000 1.28
@@ -1,11 +1,10 @@
package org.hansel;
-import java.util.HashSet;
import java.util.Arrays;
-import java.util.Vector;
-import junit.framework.TestSuite;
+import java.util.HashSet;
+
import junit.framework.TestResult;
-import junit.runner.TestCaseClassLoader;
+import junit.framework.TestSuite;
import org.hansel.probes.ProbeFilter;
@@ -22,7 +21,7 @@
private String[] classNamesCovered;
private Class[] classesCovered;
- private TestSuite testSuite;
+ //private TestSuite testSuite;
private ProbeTable probeTable;
@@ -53,7 +52,8 @@
private void patchTestClassLoader() {
// Warning: Ugly code.
- if (getClass().getClassLoader() instanceof TestCaseClassLoader) {
+ // TODO: Reimplement for junit4?
+ /* if (getClass().getClassLoader() instanceof TestCaseClassLoader) {
try {
Class tccl = TestCaseClassLoader.class;
java.lang.reflect.Field f = tccl.getDeclaredField("fExcluded");
@@ -65,7 +65,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- }
+ } */
}
/**
* Creates a new CoverageDecorator containing the test instantiated
@@ -117,7 +117,7 @@
ProbeTable.setProbeTable(probeTable);
try {
- Startup.init(new HashSet(Arrays.asList(classNamesCovered)));
+ Startup.init(new HashSet<String>(Arrays.asList(classNamesCovered)));
} catch (Exception e) {
result.addError(this, e);
return false;
1.23 +18 -3 hansel/src/org/hansel/Probe.java
Index: Probe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Probe.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Probe.java 19 Aug 2006 21:07:52 -0000 1.22
+++ Probe.java 9 Sep 2006 21:18:54 -0000 1.23
@@ -7,6 +7,9 @@
import junit.framework.Test;
import junit.framework.TestResult;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
import org.objectweb.asm.MethodVisitor;
/**
@@ -79,19 +82,31 @@
result.startTest(this);
if (displayFailure()) {
- //System.out.println("Probe failed: " + getID() + " " + pd.getMethodName());
- result.addFailure(this, new CoverageError(pd));
+ result.addFailure(this, new CoverageError(pd));
}
result.endTest(this);
}
-
+
+ public void run(RunNotifier result) {
+ Description desc = Description.createTestDescription(getClass(),
+ toString());
+ result.fireTestStarted(desc);
+
+ if (displayFailure()) {
+ result.fireTestFailure(new Failure(desc, new CoverageError(pd)));
+ }
+
+ result.fireTestFinished(desc);
+ }
+
public String getName() {
return pd.getShortClassName() + ":" +
pd.getLineNumber();
}
private class CoverageError extends AssertionFailedError {
+ private static final long serialVersionUID = 1L;
private ProbeData pd;
public CoverageError(ProbeData pd) {
1.7 +21 -2 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HanselCodeAdapter.java 19 Aug 2006 21:07:52 -0000 1.6
+++ HanselCodeAdapter.java 9 Sep 2006 21:18:54 -0000 1.7
@@ -16,6 +16,7 @@
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.LabelNode;
+import org.objectweb.asm.tree.LineNumberNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
public class HanselCodeAdapter extends MethodAdapter {
@@ -68,12 +69,23 @@
}
}
- private boolean isEmptyPrivateConstructor() {
+ private boolean isEmptyPrivateConstructor() {
return "<init>".equals(methodName) &&
((access & Opcodes.ACC_PRIVATE) > 0) &&
- instructions.size() == 5;
+ countRelevantInstructions(instructions) == 3;
}
+ private int countRelevantInstructions(InsnList instructions) {
+ int count = 0;
+ for (AbstractInsnNode node : instructions.toArray()) {
+ if (!(node instanceof LineNumberNode) &&
+ !(node instanceof LabelNode)) {
+ count++;
+ }
+ }
+ return count;
+ }
+
private boolean isStaticConstructor() {
return "<clinit>".equals(methodName);
}
@@ -281,6 +293,13 @@
}
@Override
+ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
+ checkFirst();
+
+ super.visitFrame(type, nLocal, local, nStack, stack);
+ }
+
+ @Override
public void visitEnd() {
super.visitEnd();
1.24 +38 -4 hansel/src/org/hansel/ProbeTable.java
Index: ProbeTable.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeTable.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ProbeTable.java 19 Aug 2006 21:07:52 -0000 1.23
+++ ProbeTable.java 9 Sep 2006 21:18:54 -0000 1.24
@@ -16,6 +16,9 @@
import org.hansel.probes.ProbeFilter;
import org.hansel.probes.SelectProbe;
import org.hansel.probes.UnaryBranchProbe;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
/**
* This class contains a table of currently active Probes.
@@ -28,9 +31,9 @@
private static ProbeTable table;
/** List containing currently active probes. */
- private List probes;
+ private List<Probe> probes;
- private Map probeMap;
+ private Map<ProbeData, Probe> probeMap;
private boolean displayStatistics;
@@ -38,8 +41,8 @@
public ProbeTable(ProbeFilter probeFilter) {
super("Coverage Test");
- this.probes = new Vector();
- this.probeMap = new HashMap();
+ this.probes = new Vector<Probe>();
+ this.probeMap = new HashMap<ProbeData, Probe>();
this.displayStatistics = false;
this.probeFilter = probeFilter;
}
@@ -169,6 +172,35 @@
clear();
}
+ public void run(RunNotifier result, boolean hasErrors) {
+ // Only add coverage problems, if the test did not cause
+ // any other errors/failures.
+ if (!hasErrors) {
+ int covered = getCovered();
+ int count = getSize();
+ for (Probe probe : probes) {
+ probe.run(result);
+ }
+ if (displayStatistics && (covered != count)) {
+ String msg = "Coverage Test failed: Only " + covered + " of "
+ + count + " probes covered.";
+ result.fireTestFailure(new Failure(
+ Description.createSuiteDescription("coverage"),
+ new AssertionFailedError(msg)));
+ }
+ } else {
+ String msg = "Coverage Failure: No coverage test performed, "
+ + "because test failed.";
+ result.fireTestFailure(new Failure(
+ Description.createSuiteDescription("coverage"),
+ new AssertionFailedError(msg)));
+ }
+
+ // Clear the probe table
+ clear();
+ }
+
+
public static void setProbeTable(ProbeTable pt) {
table = pt;
}
@@ -200,4 +232,6 @@
return covered;
}
+
+
}
1.1 hansel/src/org/hansel/CoverageRunner.java
package org.hansel;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.HashSet;
import org.junit.internal.runners.InitializationError;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.Suite;
public class CoverageRunner extends Suite {
private ProbeTable probeTable;
private Class[] coveredClasses;
/**
* The <code>CoverClasses</code> annotation specifies the classes to be covered
* when the test suite is run.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface CoverClasses {
public Class[] value();
}
/**
* Internal use only.
*/
public CoverageRunner(Class<?> klass) throws InitializationError {
super(klass);
this.probeTable = new ProbeTable(null);
this.coveredClasses = getCoveredClasses(klass);
}
private static Class[] getCoveredClasses(Class<?> klass) throws InitializationError {
CoverClasses annotation= klass.getAnnotation(CoverClasses.class);
if (annotation == null)
throw new InitializationError(String.format("class '%s' must have a CoverClasses annotation", klass.getName()));
return annotation.value();
}
private HashSet<String> toStringSet(Class[] classes) {
HashSet<String> coveredClasses = new HashSet<String>();
for (Class clazz : classes) {
coveredClasses.add(clazz.getName());
}
return coveredClasses;
}
@Override
public void run(RunNotifier notifier) {
if (!init(notifier)) {
return;
}
CheckFailureRunListener listener = new CheckFailureRunListener();
notifier.addListener(listener);
super.run(notifier);
shutdown(notifier, listener.hasFailures());
}
protected boolean init(RunNotifier result) {
ProbeTable.setProbeTable(probeTable);
try {
Startup.init(toStringSet(coveredClasses));
} catch (Exception e) {
result.fireTestFailure(
new Failure(Description.createSuiteDescription("coverage"), e));
return false;
}
return true;
}
protected void shutdown(RunNotifier result, boolean hasErrors) {
try {
loadClasses();
Startup.tearDown();
probeTable.run(result, hasErrors);
} catch (Exception e) {
result.fireTestFailure(
new Failure(Description.createSuiteDescription("coverage"),
e));
}
}
private void loadClasses() {
// Make sure all classes are linked, so all probes get created.
for (Class clazz : coveredClasses) {
clazz.getDeclaredFields();
}
}
}
1.1 hansel/src/org/hansel/CheckFailureRunListener.java
package org.hansel;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
public class CheckFailureRunListener extends RunListener {
private boolean failures;
public CheckFailureRunListener() {
failures = false;
}
public boolean hasFailures() {
return failures;
}
@Override
public void testFailure(Failure failure) throws Exception {
failures = true;
}
}
1.2 +1 -1 hansel/.classpath
Index: .classpath
===================================================================
RCS file: /cvsroot/hansel/hansel/.classpath,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .classpath 19 Aug 2006 21:07:52 -0000 1.1
+++ .classpath 9 Sep 2006 21:18:55 -0000 1.2
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/checkstyle-all-2.3.jar"/>
- <classpathentry kind="lib" path="lib/junit.jar"/>
+ <classpathentry sourcepath="/home/jiriki/java/junit4.1/junit-4.1-src.jar" kind="lib" path="lib/junit.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ant"/>
<classpathentry kind="lib" path="classes"/>
1.54 +1 -1 hansel/build.xml
Index: build.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build.xml,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- build.xml 25 May 2006 10:39:59 -0000 1.53
+++ build.xml 9 Sep 2006 21:18:55 -0000 1.54
@@ -1,6 +1,6 @@
<project name="hansel-task" default="compile" basedir=".">
- <property name="hansel.version" value="2.0a1"/>
+ <property name="hansel.version" value="2.0a2"/>
<property name="hansel.name" value="hansel"/>
<property name="hansel.home" value="."/>
<property name="hansel.build" value="build"/>
1.4 +1 -1 hansel/src/org/hanseltest/CoverAssertion.java
Index: CoverAssertion.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/CoverAssertion.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CoverAssertion.java 20 Sep 2002 14:12:04 -0000 1.3
+++ CoverAssertion.java 9 Sep 2006 21:18:55 -0000 1.4
@@ -5,7 +5,7 @@
* @author Niklas Mehner
*/
public class CoverAssertion {
-
+
/**
* Returns i and asserts i > 0.
* @param i some int.
1.12 +3 -3 hansel/src/org/hanseltest/TestAssertions.java
Index: TestAssertions.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestAssertions.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TestAssertions.java 19 Aug 2006 21:07:52 -0000 1.11
+++ TestAssertions.java 9 Sep 2006 21:18:55 -0000 1.12
@@ -46,9 +46,9 @@
TestResult result = new TestResult();
cd.run(result);
- org.hansel.Util.dumpResult(result);
- // Three failures: methods "init", "clinit" and "coverAssertion"
- assertEquals(3, result.failureCount());
+ //org.hansel.Util.dumpResult(result);
+ // Three failures: methods "init" and "coverAssertion"
+ assertEquals(2, result.failureCount());
// No errors
assertEquals(0, result.errorCount());
1.5 +2 -1 hansel/src/org/hanselexample/ExampleTest.java
Index: ExampleTest.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanselexample/ExampleTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExampleTest.java 10 Dec 2002 08:30:25 -0000 1.4
+++ ExampleTest.java 9 Sep 2006 21:18:55 -0000 1.5
@@ -1,3 +1,4 @@
+
package org.hanselexample;
import junit.framework.Test;
@@ -29,7 +30,7 @@
*/
public static Test suite() {
CoverageDecorator cd =
- new CoverageDecorator(ExampleTest.class,
+ new CoverageDecorator(ExampleJUnit4Test.class,
new Class[] { Example.class });
cd.setDisplayStatistics(true);
1.1 hansel/src/org/hanselexample/ExampleJUnit4Suite.java
package org.hanselexample;
import org.hansel.CoverageRunner;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(CoverageRunner.class)
@Suite.SuiteClasses({ ExampleJUnit4Test.class })
@CoverageRunner.CoverClasses({ Example.class })
public class ExampleJUnit4Suite {
}
1.1 hansel/src/org/hanselexample/ExampleJUnit4Test.java
package org.hanselexample;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Coverage Test for the Example class.
* This test covers all lines (including private/anonymous classes)
* of the Example class.
*
* @author Niklas Mehner
*/
public class ExampleJUnit4Test {
@Test public void absTest() {
Example example = new Example();
assertEquals("abs(1) should be 1.", 1, example.abs(1));
assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
assertEquals("abs(0) should be 0.", 0, example.abs(0));
}
/**
* Test the Example.add() method. This also covers the code of the inner
* class.
*/
@Test public void innerClassTest() {
Example example = new Example();
assertEquals("add(2, 3) should be 5.", 5, example.add(2, 3));
}
}
|
|
From: Niklas M. <ji...@us...> - 2006-08-19 21:08:01
|
jiriki 06/08/19 14:07:52
Modified: src/org/hansel/probes NullCmpBranchProbe.java
SelectProbe.java ACmpBranchProbe.java
ProbeFilter.java MethodProbe.java BranchProbe.java
StringProbeFilter.java
src/org/hansel/stack ComplexOr.java PrefixOpEntry.java
SymbolicStack.java NotOp.java ComplexAnd.java
OperatorEntry.java
src/org/hanseltest/stack BinaryOperatorEntryTest.java
bin runExample.bat runExample.sh
src/org/hansel Probe.java TransformingAdapter.java
AntCoverageTask.java Util.java Startup.java
AssertionCoverageDecorator.java
HanselInterpreter.java HanselCodeAdapter.java
Transformer.java ProbeFactory.java ProbeTable.java
src/org/hanseltest TestProbeFilter.java TestAssertions.java
TestSwitchBug.java TestBug753855.java
. build-hansel.xml .project ChangeLog
src/org/hanseltest/probes IntComparatorTest.java
Added: lib asm-all-3.0_RC1.jar
. .classpath pom.xml
Log:
cleanup for hansel2.0a1
Revision Changes Path
1.10 +0 -1 hansel/src/org/hansel/probes/NullCmpBranchProbe.java
Index: NullCmpBranchProbe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/NullCmpBranchProbe.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NullCmpBranchProbe.java 22 Dec 2004 18:27:37 -0000 1.9
+++ NullCmpBranchProbe.java 19 Aug 2006 21:07:51 -0000 1.10
@@ -7,7 +7,6 @@
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
/**
* A probe for a comparing conditional branch. For decision coverage both
1.10 +1 -2 hansel/src/org/hansel/probes/SelectProbe.java
Index: SelectProbe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/SelectProbe.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SelectProbe.java 22 Dec 2004 18:27:37 -0000 1.9
+++ SelectProbe.java 19 Aug 2006 21:07:51 -0000 1.10
@@ -2,10 +2,9 @@
import org.hansel.Probe;
import org.hansel.ProbeData;
+import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
public class SelectProbe extends Probe {
private boolean[] covered;
1.11 +1 -3 hansel/src/org/hansel/probes/ACmpBranchProbe.java
Index: ACmpBranchProbe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/ACmpBranchProbe.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ACmpBranchProbe.java 22 Dec 2004 18:27:37 -0000 1.10
+++ ACmpBranchProbe.java 19 Aug 2006 21:07:51 -0000 1.11
@@ -1,13 +1,11 @@
package org.hansel.probes;
import org.hansel.ProbeData;
-import org.hansel.stack.HanselValue;
import org.hansel.stack.EqOp;
+import org.hansel.stack.HanselValue;
import org.hansel.stack.NeOp;
-
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
/**
* A probe for a comparing conditional branch. For decision coverage both
1.3 +0 -1 hansel/src/org/hansel/probes/ProbeFilter.java
Index: ProbeFilter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/ProbeFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProbeFilter.java 5 Sep 2004 13:52:50 -0000 1.2
+++ ProbeFilter.java 19 Aug 2006 21:07:51 -0000 1.3
@@ -1,7 +1,6 @@
package org.hansel.probes;
import org.hansel.ProbeData;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
public interface ProbeFilter {
public boolean filter(ProbeData probeData);
1.10 +0 -1 hansel/src/org/hansel/probes/MethodProbe.java
Index: MethodProbe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/MethodProbe.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MethodProbe.java 22 Dec 2004 18:27:37 -0000 1.9
+++ MethodProbe.java 19 Aug 2006 21:07:51 -0000 1.10
@@ -4,7 +4,6 @@
import org.hansel.ProbeData;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
/**
* A simple Probe that is placed in the instrumented code.
1.13 +0 -1 hansel/src/org/hansel/probes/BranchProbe.java
Index: BranchProbe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/BranchProbe.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- BranchProbe.java 5 Sep 2004 13:52:50 -0000 1.12
+++ BranchProbe.java 19 Aug 2006 21:07:51 -0000 1.13
@@ -3,7 +3,6 @@
import org.hansel.Probe;
import org.hansel.ProbeData;
import org.hansel.stack.HanselValue;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
/**
1.4 +0 -1 hansel/src/org/hansel/probes/StringProbeFilter.java
Index: StringProbeFilter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/probes/StringProbeFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StringProbeFilter.java 22 Dec 2004 18:27:37 -0000 1.3
+++ StringProbeFilter.java 19 Aug 2006 21:07:51 -0000 1.4
@@ -1,7 +1,6 @@
package org.hansel.probes;
import org.hansel.ProbeData;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
public class StringProbeFilter implements ProbeFilter {
private String filterString;
1.3 +0 -4 hansel/src/org/hansel/stack/ComplexOr.java
Index: ComplexOr.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/ComplexOr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ComplexOr.java 5 Sep 2004 13:52:53 -0000 1.2
+++ ComplexOr.java 19 Aug 2006 21:07:51 -0000 1.3
@@ -1,9 +1,5 @@
package org.hansel.stack;
-import java.util.Hashtable;
-
-import org.hansel.stack.StackFactory;
-import org.hansel.stack.SymbolicStack;
public class ComplexOr {
/*private InstructionHandle trueTarget;
1.6 +0 -1 hansel/src/org/hansel/stack/PrefixOpEntry.java
Index: PrefixOpEntry.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/PrefixOpEntry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PrefixOpEntry.java 22 Dec 2004 18:27:38 -0000 1.5
+++ PrefixOpEntry.java 19 Aug 2006 21:07:51 -0000 1.6
@@ -1,6 +1,5 @@
package org.hansel.stack;
-import org.objectweb.asm.Type;
public class PrefixOpEntry extends OperatorEntry {
private HanselValue entry;
1.23 +0 -2 hansel/src/org/hansel/stack/SymbolicStack.java
Index: SymbolicStack.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/SymbolicStack.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- SymbolicStack.java 5 Sep 2004 13:52:53 -0000 1.22
+++ SymbolicStack.java 19 Aug 2006 21:07:51 -0000 1.23
@@ -1,8 +1,6 @@
package org.hansel.stack;
-import java.util.List;
-import java.util.Vector;
public class SymbolicStack {
1.5 +0 -1 hansel/src/org/hansel/stack/NotOp.java
Index: NotOp.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/NotOp.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NotOp.java 22 Dec 2004 18:27:38 -0000 1.4
+++ NotOp.java 19 Aug 2006 21:07:51 -0000 1.5
@@ -1,6 +1,5 @@
package org.hansel.stack;
-import org.objectweb.asm.Type;
public class NotOp extends PrefixOpEntry {
1.4 +0 -4 hansel/src/org/hansel/stack/ComplexAnd.java
Index: ComplexAnd.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/ComplexAnd.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComplexAnd.java 5 Sep 2004 13:52:53 -0000 1.3
+++ ComplexAnd.java 19 Aug 2006 21:07:51 -0000 1.4
@@ -1,9 +1,5 @@
package org.hansel.stack;
-import java.util.Hashtable;
-
-import org.hansel.stack.StackFactory;
-import org.hansel.stack.SymbolicStack;
public class ComplexAnd {
/*private InstructionList il;
1.6 +0 -1 hansel/src/org/hansel/stack/OperatorEntry.java
Index: OperatorEntry.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/OperatorEntry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- OperatorEntry.java 22 Dec 2004 18:27:38 -0000 1.5
+++ OperatorEntry.java 19 Aug 2006 21:07:51 -0000 1.6
@@ -1,6 +1,5 @@
package org.hansel.stack;
-import org.objectweb.asm.Type;
public class OperatorEntry extends HanselValue {
private int precedence;
1.7 +0 -1 hansel/src/org/hanseltest/stack/BinaryOperatorEntryTest.java
Index: BinaryOperatorEntryTest.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/stack/BinaryOperatorEntryTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BinaryOperatorEntryTest.java 22 Dec 2004 18:27:40 -0000 1.6
+++ BinaryOperatorEntryTest.java 19 Aug 2006 21:07:52 -0000 1.7
@@ -8,7 +8,6 @@
import org.hansel.stack.BinaryOperatorEntry;
import org.hansel.stack.HanselValue;
import org.hansel.stack.OperatorEntry;
-import org.objectweb.asm.Type;
/**
* Test the BinaryOperatorEntry and class.
1.1 hansel/lib/asm-all-3.0_RC1.jar
<<Binary file>>
1.3 +2 -2 hansel/bin/runExample.bat
Index: runExample.bat
===================================================================
RCS file: /cvsroot/hansel/hansel/bin/runExample.bat,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- runExample.bat 17 Jul 2002 08:55:35 -0000 1.2
+++ runExample.bat 19 Aug 2006 21:07:52 -0000 1.3
@@ -1,2 +1,2 @@
-javac -classpath .;../lib/junit.jar;../lib/bcel.jar;../lib/hansel.jar org/hanselexample/*.java
-java -classpath .;../lib/junit.jar;../lib/bcel.jar;../lib/hansel.jar junit.swingui.TestRunner org.hanselexample.ExampleTest
\ No newline at end of file
+javac -classpath .;../lib/junit.jar;../lib/hansel.jar org/hanselexample/*.java
+java -javaagent:../lib/hansel.jar -classpath .;../lib/junit.jar;../lib/asm-all-3.0_RC1.jar;../lib/hansel.jar junit.swingui.TestRunner org.hanselexample.ExampleTest
\ No newline at end of file
1.2 +2 -2 hansel/bin/runExample.sh
Index: runExample.sh
===================================================================
RCS file: /cvsroot/hansel/hansel/bin/runExample.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- runExample.sh 5 Jun 2002 16:37:33 -0000 1.1
+++ runExample.sh 19 Aug 2006 21:07:52 -0000 1.2
@@ -1,4 +1,4 @@
#!/bin/sh
-javac -classpath .:../lib/junit.jar:../lib/bcel.jar:../lib/hansel.jar org/hanselexample/*.java
-java -classpath .:../lib/junit.jar:../lib/bcel.jar:../lib/hansel.jar junit.swingui.TestRunner org.hanselexample.ExampleTest
\ No newline at end of file
+javac -classpath .:../lib/junit.jar:../lib/hansel.jar org/hanselexample/*.java
+java -javaagent:../lib/hansel.jar -classpath .:../lib/junit.jar:../lib/hansel.jar:../lib/asm-all-3.0_RC1.jar junit.swingui.TestRunner org.hanselexample.ExampleTest
\ No newline at end of file
1.22 +1 -1 hansel/src/org/hansel/Probe.java
Index: Probe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Probe.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Probe.java 25 May 2006 10:40:00 -0000 1.21
+++ Probe.java 19 Aug 2006 21:07:52 -0000 1.22
@@ -6,8 +6,8 @@
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestResult;
+
import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
/**
* Abstract super class of all probes.
1.3 +6 -8 hansel/src/org/hansel/TransformingAdapter.java
Index: TransformingAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/TransformingAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransformingAdapter.java 22 Dec 2004 18:27:32 -0000 1.2
+++ TransformingAdapter.java 19 Aug 2006 21:07:52 -0000 1.3
@@ -1,17 +1,15 @@
package org.hansel;
-import java.util.List;
-
import org.objectweb.asm.ClassAdapter;
-import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.Attribute;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.analysis.Analyzer;
-import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.AnalyzerException;
-import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.analysis.Frame;
public class TransformingAdapter extends ClassAdapter {
private ClassNode classNode;
@@ -52,7 +50,7 @@
}
Analyzer analyzer =
- new Analyzer(new HanselInterpreter(mn.instructions, mn.localVariables)) {
+ new Analyzer(new HanselInterpreter(/*mn.instructions, */mn.localVariables)) {
protected Frame newFrame (final int nLocals, final int nStack) {
return new HanselFrame(nLocals, nStack);
}
@@ -83,7 +81,7 @@
}
private boolean isPrivateEmptyConstructor(String name,
- int access, List instructions) {
+ int access, InsnList instructions) {
return ((access & Opcodes.ACC_PRIVATE) != 0)
&& "<init>".equals(name) && (instructions.size() == 6);
}
1.14 +2 -2 hansel/src/org/hansel/AntCoverageTask.java
Index: AntCoverageTask.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/AntCoverageTask.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AntCoverageTask.java 25 May 2006 10:40:00 -0000 1.13
+++ AntCoverageTask.java 19 Aug 2006 21:07:52 -0000 1.14
@@ -227,8 +227,8 @@
return result;
}
- private void addTest(Set testClasses,
- Set resultSet,
+ private void addTest(Set<String> testClasses,
+ Set<Class> resultSet,
Test test) throws ClassNotFoundException {
String className = test.getClass().getName();
if (testClasses.contains(className)) {
1.11 +5 -5 hansel/src/org/hansel/Util.java
Index: Util.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Util.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Util.java 25 May 2006 10:40:00 -0000 1.10
+++ Util.java 19 Aug 2006 21:07:52 -0000 1.11
@@ -1,12 +1,12 @@
package org.hansel;
+import java.util.Enumeration;
+
import junit.framework.TestFailure;
import junit.framework.TestResult;
-import java.util.Enumeration;
-import java.util.List;
-
import org.objectweb.asm.Label;
+import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.LabelNode;
/**
@@ -59,11 +59,11 @@
}
}
- public static int findIndex(List instructions, Label label) {
+ public static int findIndex(InsnList instructions, Label label) {
for (int i=0; i<instructions.size(); i++) {
Object obj = instructions.get(i);
if (obj instanceof LabelNode) {
- if (((LabelNode) obj).label == label) {
+ if (((LabelNode) obj).getLabel() == label) {
return i;
}
}
1.4 +3 -6 hansel/src/org/hansel/Startup.java
Index: Startup.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Startup.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Startup.java 25 May 2006 10:40:00 -0000 1.3
+++ Startup.java 19 Aug 2006 21:07:52 -0000 1.4
@@ -1,21 +1,18 @@
package org.hansel;
-import java.io.FileOutputStream;
-import java.io.InputStream;
import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-import java.lang.instrument.Instrumentation;
import java.lang.instrument.ClassDefinition;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
-import java.util.HashMap;
public class Startup {
private static Instrumentation instrumentation;
1.6 +0 -9 hansel/src/org/hansel/AssertionCoverageDecorator.java
Index: AssertionCoverageDecorator.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/AssertionCoverageDecorator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AssertionCoverageDecorator.java 22 Dec 2004 18:27:32 -0000 1.5
+++ AssertionCoverageDecorator.java 19 Aug 2006 21:07:52 -0000 1.6
@@ -1,14 +1,5 @@
package org.hansel;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Arrays;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.framework.TestResult;
-
import org.hansel.probes.ProbeFilter;
public class AssertionCoverageDecorator extends CoverageDecorator {
1.5 +13 -17 hansel/src/org/hansel/HanselInterpreter.java
Index: HanselInterpreter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselInterpreter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HanselInterpreter.java 25 May 2006 10:40:00 -0000 1.4
+++ HanselInterpreter.java 19 Aug 2006 21:07:52 -0000 1.5
@@ -3,28 +3,24 @@
import java.util.Iterator;
import java.util.List;
-import org.hansel.stack.HanselValue;
import org.hansel.stack.BinaryOperatorEntry;
+import org.hansel.stack.HanselValue;
import org.hansel.stack.PrefixOpEntry;
-
-import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.analysis.DataflowInterpreter;
-import org.objectweb.asm.tree.analysis.Value;
-import org.objectweb.asm.tree.VarInsnNode;
-import org.objectweb.asm.tree.LocalVariableNode;
-import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.IntInsnNode;
-import org.objectweb.asm.tree.IincInsnNode;
-import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
+import org.objectweb.asm.tree.LocalVariableNode;
import org.objectweb.asm.tree.MethodInsnNode;
-import org.objectweb.asm.tree.FieldInsnNode;
-import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.MultiANewArrayInsnNode;
+import org.objectweb.asm.tree.TypeInsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+import org.objectweb.asm.tree.analysis.SourceInterpreter;
+import org.objectweb.asm.tree.analysis.Value;
-public final class HanselInterpreter extends DataflowInterpreter {
+public final class HanselInterpreter extends SourceInterpreter {
private static final int PRECEDENCE_CAST = 1;
private static final int PRECEDENCE_UNARY_MINUS = 1;
private static final int PRECEDENCE_MUL = 2;
@@ -35,12 +31,12 @@
private static final int PRECEDENCE_AND = 7;
private static final int PRECEDENCE_XOR = 8;
private static final int PRECEDENCE_OR = 9;
- private List instructions;
+ //private InsnList instructions;
private List localVariables;
/** Creates a new instance of HanselInterpreter */
- public HanselInterpreter(List instructions, List localVariables) {
- this.instructions = instructions;
+ public HanselInterpreter(/*InsnList instructions, */List localVariables) {
+ //this.instructions = instructions;
this.localVariables = localVariables;
//System.out.println("LocalVars: " + localVariables);
}
@@ -125,7 +121,7 @@
private HanselValue findLocalVar(int index, AbstractInsnNode insn) {
Iterator it = localVariables.iterator();
- int insnIndex = instructions.indexOf(insn);
+ //int insnIndex = instructions.indexOf(insn);
while (it.hasNext()) {
LocalVariableNode lvn = (LocalVariableNode) it.next();
1.6 +83 -62 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- HanselCodeAdapter.java 25 May 2006 10:40:00 -0000 1.5
+++ HanselCodeAdapter.java 19 Aug 2006 21:07:52 -0000 1.6
@@ -1,25 +1,27 @@
package org.hansel;
+import static org.objectweb.asm.Opcodes.ALOAD;
+import static org.objectweb.asm.Opcodes.ASTORE;
+import static org.objectweb.asm.Opcodes.ATHROW;
+import static org.objectweb.asm.Opcodes.MONITOREXIT;
+
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import java.util.Map;
-import java.util.HashMap;
+import org.objectweb.asm.Label;
import org.objectweb.asm.MethodAdapter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Label;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
-import org.objectweb.asm.tree.AbstractInsnNode;
-
-import static org.objectweb.asm.Opcodes.*;
public class HanselCodeAdapter extends MethodAdapter {
private boolean first;
private int pos;
- private List instructions;
+ private InsnList instructions;
private String className;
private String methodName;
private HanselFrame[] frames;
@@ -27,12 +29,12 @@
private List tryCatchBlocks;
private Probe methodProbe;
private int access;
-
+
public HanselCodeAdapter(int access, String className,
- String methodName, List instructions, List tryCatchBlocks, MethodVisitor mv,
- HanselFrame[] frames) {
+ String methodName, InsnList instructions, List tryCatchBlocks, MethodVisitor mv,
+ HanselFrame[] frames) {
super(mv);
-
+
this.access = access;
this.first = true;
this.pos = 0;
@@ -43,20 +45,23 @@
this.probes = new Vector<Probe>();
this.tryCatchBlocks = tryCatchBlocks;
}
-
+
private void addProbe(Probe probe) {
- probe.insertProbeCode(mv);
- probes.add(probe);
+ probe.insertProbeCode(mv);
+ probes.add(probe);
}
-
+
private void checkFirst() {
+ //System.out.println(pos + " -> " + instructions.get(pos) + " : " +
+ // Thread.currentThread().getStackTrace()[3].getMethodName());
pos++;
+
if (!first) {
return;
}
first = false;
-
+
if (!isEmptyPrivateConstructor() && !isStaticConstructor()) {
methodProbe = ProbeFactory.createMethodProbe(getProbeData());
addProbe(methodProbe);
@@ -68,22 +73,24 @@
((access & Opcodes.ACC_PRIVATE) > 0) &&
instructions.size() == 5;
}
-
+
private boolean isStaticConstructor() {
return "<clinit>".equals(methodName);
}
-
+
private ProbeData getProbeData() {
- return new ProbeData(
- className,
- methodName,
- frames[pos - 1],
- pos,
- instructions.size());
+ return new ProbeData(
+ className,
+ methodName,
+ frames[pos - 1],
+ pos,
+ instructions.size());
}
public void visitLineNumber(int line, Label start) {
super.visitLineNumber(line, start);
+ checkFirst();
+
int startIndex = Util.findIndex(instructions, start);
@@ -115,18 +122,18 @@
}
public void visitFieldInsn(final int opcode,
- final String owner,
- final String name,
- final String desc) {
+ final String owner,
+ final String name,
+ final String desc) {
checkFirst();
mv.visitFieldInsn(opcode, owner, name, desc);
}
public void visitMethodInsn(final int opcode,
- final String owner,
- final String name,
- final String desc) {
+ final String owner,
+ final String name,
+ final String desc) {
checkFirst();
mv.visitMethodInsn(opcode, owner, name, desc);
@@ -137,36 +144,38 @@
if (opcode != Opcodes.GOTO) {
addProbe(ProbeFactory.createBranchProbe(getProbeData(),
- opcode));
+ opcode));
}
mv.visitJumpInsn(opcode, label);
}
public void visitLabel(final Label label) {
+ //System.out.println(pos + " -> " + instructions.get(pos) + " : visitLabel");
+
pos++;
mv.visitLabel(label);
-
+
if (isExceptionHandler(label) && !isMonitorExitHandler()) {
addProbe(ProbeFactory.createExceptionProbe(getProbeData(),
- methodProbe));
+ methodProbe));
}
}
-
+
private boolean isMonitorExitHandler() {
if (instructions.size() < pos + 6) {
return false;
}
-
+
if (!isOpcode(pos, ASTORE)) {
return false;
}
-
+
if (!isOpcode(pos + 1, ALOAD)) {
return false;
}
-
+
if (!isOpcode(pos + 2, MONITOREXIT)) {
return false;
}
@@ -174,34 +183,34 @@
if (!isLabel(pos + 3)) {
return false;
}
-
+
if (!isOpcode(pos + 4, ALOAD)) {
return false;
}
-
+
if (!isOpcode(pos + 5, ATHROW)) {
return false;
}
return true;
}
-
+
private boolean isLabel(int pos) {
return (instructions.get(pos) instanceof LabelNode);
}
-
+
private boolean isOpcode(int pos, int opcode) {
return (instructions.get(pos) instanceof AbstractInsnNode)
&& (((AbstractInsnNode) instructions.get(pos)).getOpcode() == opcode);
}
-
+
private boolean isExceptionHandler(Label l) {
Iterator it = tryCatchBlocks.iterator();
while (it.hasNext()) {
- if (((TryCatchBlockNode) it.next()).handler == l) {
+ if (((TryCatchBlockNode) it.next()).handler.getLabel() == l) {
return true;
}
}
-
+
return false;
}
@@ -218,24 +227,24 @@
}
public void visitTableSwitchInsn(final int min,
- final int max,
- final Label dflt,
- final Label labels[]) {
+ final int max,
+ final Label dflt,
+ final Label labels[]) {
checkFirst();
addProbe(ProbeFactory.createSelectProbe(getProbeData(),
- min, max, dflt, labels));
-
+ min, max, dflt, labels));
+
mv.visitTableSwitchInsn(min, max, dflt, labels);
}
public void visitLookupSwitchInsn(final Label dflt,
- final int keys[],
- final Label labels[]) {
+ final int keys[],
+ final Label labels[]) {
checkFirst();
-
+
addProbe(ProbeFactory.createSelectProbe(getProbeData(),
- dflt, keys, labels));
+ dflt, keys, labels));
mv.visitLookupSwitchInsn(dflt, keys, labels);
}
@@ -247,27 +256,39 @@
}
public void visitTryCatchBlock(final Label start, final Label end,
- final Label handler, final String type) {
- checkFirst();
+ final Label handler, final String type) {
+ //checkFirst();
mv.visitTryCatchBlock(start, end, handler, type);
}
-
+
public void visitTypeInsn(int param, String str) {
checkFirst();
-
+
super.visitTypeInsn(param, str);
}
-
+
public void visitAttribute(org.objectweb.asm.Attribute attribute) {
checkFirst();
-
+
super.visitAttribute(attribute);
}
-
+
public void visitMaxs(int param, int param1) {
- checkFirst();
-
+ //checkFirst();
+
super.visitMaxs(param, param1);
}
+
+ @Override
+ public void visitEnd() {
+ super.visitEnd();
+
+ if (pos != frames.length) {
+ throw new IllegalStateException("Inconsistent instrumentation: "
+ + pos + " != " + frames.length);
+ }
+ }
+
+
}
1.5 +6 -7 hansel/src/org/hansel/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Transformer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Transformer.java 25 May 2006 10:40:00 -0000 1.4
+++ Transformer.java 19 Aug 2006 21:07:52 -0000 1.5
@@ -2,16 +2,16 @@
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import java.security.ProtectionDomain;
+import java.lang.instrument.ClassDefinition;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
-import java.lang.instrument.ClassDefinition;
import java.lang.instrument.UnmodifiableClassException;
+import java.security.ProtectionDomain;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
@@ -22,7 +22,6 @@
public Transformer(Set<String> classNames) {
this.classNames = classNames;
- this.redefinedClasses = redefinedClasses;
}
public byte[] transform(ClassLoader loader,
1.17 +8 -9 hansel/src/org/hansel/ProbeFactory.java
Index: ProbeFactory.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeFactory.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ProbeFactory.java 22 Dec 2004 18:27:32 -0000 1.16
+++ ProbeFactory.java 19 Aug 2006 21:07:52 -0000 1.17
@@ -2,24 +2,23 @@
import java.lang.reflect.Constructor;
-import org.hansel.probes.MethodProbe;
-import org.hansel.probes.BranchProbe;
import org.hansel.probes.ACmpBranchProbe;
-import org.hansel.probes.NullCmpBranchProbe;
-import org.hansel.probes.ExceptionProbe;
-import org.hansel.probes.SelectProbe;
-import org.hansel.probes.UnaryBranchProbe;
import org.hansel.probes.BinaryBranchProbe;
-import org.hansel.probes.IntComparator;
+import org.hansel.probes.BranchProbe;
import org.hansel.probes.EQComparator;
+import org.hansel.probes.ExceptionProbe;
import org.hansel.probes.GEComparator;
import org.hansel.probes.GTComparator;
+import org.hansel.probes.IntComparator;
import org.hansel.probes.LEComparator;
import org.hansel.probes.LTComparator;
+import org.hansel.probes.MethodProbe;
import org.hansel.probes.NEComparator;
-import org.objectweb.asm.Opcodes;
+import org.hansel.probes.NullCmpBranchProbe;
+import org.hansel.probes.SelectProbe;
+import org.hansel.probes.UnaryBranchProbe;
import org.objectweb.asm.Label;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
+import org.objectweb.asm.Opcodes;
public class ProbeFactory {
private final static Class[] BRANCH_CLASS_ARGS = { ProbeData.class,
1.23 +3 -6 hansel/src/org/hansel/ProbeTable.java
Index: ProbeTable.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeTable.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ProbeTable.java 5 Sep 2004 13:52:49 -0000 1.22
+++ ProbeTable.java 19 Aug 2006 21:07:52 -0000 1.23
@@ -9,16 +9,13 @@
import junit.framework.TestResult;
import junit.framework.TestSuite;
-
-import org.hansel.Probe;
-import org.hansel.probes.MethodProbe;
-import org.hansel.probes.UnaryBranchProbe;
import org.hansel.probes.ACmpBranchProbe;
import org.hansel.probes.BinaryBranchProbe;
+import org.hansel.probes.MethodProbe;
import org.hansel.probes.NullCmpBranchProbe;
-import org.hansel.probes.SelectProbe;
import org.hansel.probes.ProbeFilter;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
+import org.hansel.probes.SelectProbe;
+import org.hansel.probes.UnaryBranchProbe;
/**
* This class contains a table of currently active Probes.
1.2 +0 -1 hansel/src/org/hanseltest/TestProbeFilter.java
Index: TestProbeFilter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestProbeFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestProbeFilter.java 15 Jan 2004 20:38:41 -0000 1.1
+++ TestProbeFilter.java 19 Aug 2006 21:07:52 -0000 1.2
@@ -5,7 +5,6 @@
import org.hansel.CoverageDecorator;
import org.hansel.probes.StringProbeFilter;
-import org.hansel.ProbeData;
/**
* Test the probe filter interface..
1.11 +0 -1 hansel/src/org/hanseltest/TestAssertions.java
Index: TestAssertions.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestAssertions.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestAssertions.java 22 Dec 2004 18:27:39 -0000 1.10
+++ TestAssertions.java 19 Aug 2006 21:07:52 -0000 1.11
@@ -4,7 +4,6 @@
import junit.framework.TestResult;
import org.hansel.AssertionCoverageDecorator;
-import org.hansel.probes.StringProbeFilter;
import org.hansel.Util;
/**
1.2 +1 -4 hansel/src/org/hanseltest/TestSwitchBug.java
Index: TestSwitchBug.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestSwitchBug.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestSwitchBug.java 18 Oct 2003 21:14:58 -0000 1.1
+++ TestSwitchBug.java 19 Aug 2006 21:07:52 -0000 1.2
@@ -1,12 +1,9 @@
package org.hanseltest;
import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.framework.TestResult;
-import junit.framework.TestFailure;
+
import org.hansel.CoverageDecorator;
-import org.hansel.Util;
/**
* This TestCase tests for a bug when using the jikes compiler and switch statements.
1.7 +0 -4 hansel/src/org/hanseltest/TestBug753855.java
Index: TestBug753855.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestBug753855.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestBug753855.java 28 Dec 2004 17:20:38 -0000 1.6
+++ TestBug753855.java 19 Aug 2006 21:07:52 -0000 1.7
@@ -1,11 +1,7 @@
package org.hanseltest;
-import java.lang.reflect.*;
-
import junit.framework.TestCase;
-import org.hansel.ProbeTable;
-
/**
* Test for Bug 753855. This was caused by assuming the probe code had always the
* same length
1.10 +7 -6 hansel/build-hansel.xml
Index: build-hansel.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build-hansel.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- build-hansel.xml 25 May 2006 10:32:15 -0000 1.9
+++ build-hansel.xml 19 Aug 2006 21:07:52 -0000 1.10
@@ -4,11 +4,11 @@
classpath="lib/checkstyle-all-2.3.jar"/>
<taskdef name="coverage"
classname="org.hansel.AntCoverageTask"
- classpath="lib/asm*.jar:${hansel.classes}"/>
+ classpath="lib/asm-all-3.0_RC1.jar:${hansel.classes}"/>
<path id="hansel.classpath">
<fileset dir="${hansel.lib}">
- <include name="**/asm-all-3.0_beta2.jar"/>
+ <include name="**/asm-all-3.0_RC1.jar"/>
<include name="**/junit.jar"/>
</fileset>
<pathelement path="${hansel.classes}"/>
@@ -73,9 +73,10 @@
packages="${packages}, org.hanseltest.*"
excludepackages="org.hanseltest.*"
stats="true"/>
- </target>
-
- <target name="singletest" depends="jar">
+ </target>
+
+ <target name="singletest" depends="jar"
+ description="Runs a single test specified by: -Dclassname=TestClass.">
<mkdir dir="${hansel.testdocs}"/>
<junit fork="yes">
@@ -86,7 +87,7 @@
<batchtest fork="yes" todir="${hansel.testdocs}">
<fileset dir="${hansel.src}">
- <include name="**/TestBug584900.java" />
+ <include name="**/*${classname}*" />
</fileset>
</batchtest>
</junit>
1.2 +6 -0 hansel/.project
Index: .project
===================================================================
RCS file: /cvsroot/hansel/hansel/.project,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .project 28 Dec 2004 17:20:37 -0000 1.1
+++ .project 19 Aug 2006 21:07:52 -0000 1.2
@@ -5,7 +5,13 @@
<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
1.6 +4 -0 hansel/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvsroot/hansel/hansel/ChangeLog,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ChangeLog 15 Jan 2004 20:38:40 -0000 1.5
+++ ChangeLog 19 Aug 2006 21:07:52 -0000 1.6
@@ -1,3 +1,7 @@
+Version 2.0a1
+ (2006-08-19) jiriki
+ - Converted to jdk1.5
+ - Use asm instead of bcel
Version 1.03
(2004-01-15) jiriki
Implemented ProbeFilter.
1.1 hansel/.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/checkstyle-all-2.3.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ant"/>
<classpathentry kind="lib" path="classes"/>
<classpathentry sourcepath="/home/jiriki/java/asm-3.0_RC1/src.zip" kind="lib" path="lib/asm-all-3.0_RC1.jar"/>
<classpathentry kind="output" path="eclipse"/>
</classpath>
1.1 hansel/pom.xml
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>hansel.sourceforge.net</groupId>
<artifactId>hansel</artifactId>
<version>2.0b1</version>
<description>Code Coverage extension for JUnit 3.x.</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
1.6 +3 -8 hansel/src/org/hanseltest/probes/IntComparatorTest.java
Index: IntComparatorTest.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/probes/IntComparatorTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- IntComparatorTest.java 22 Dec 2004 18:27:39 -0000 1.5
+++ IntComparatorTest.java 19 Aug 2006 21:07:52 -0000 1.6
@@ -1,19 +1,14 @@
package org.hanseltest.probes;
-import junit.framework.Test;
import junit.framework.TestCase;
-
-import org.hansel.CoverageDecorator;
-import org.hansel.probes.IntComparator;
import org.hansel.probes.EQComparator;
-import org.hansel.probes.NEComparator;
-import org.hansel.probes.GTComparator;
import org.hansel.probes.GEComparator;
-import org.hansel.probes.LTComparator;
+import org.hansel.probes.GTComparator;
import org.hansel.probes.LEComparator;
+import org.hansel.probes.LTComparator;
+import org.hansel.probes.NEComparator;
import org.hansel.stack.HanselValue;
-import org.objectweb.asm.Type;
/**
* Tests for the org.hansel.probe.*Comparator classes.
|
|
From: Niklas M. <ji...@us...> - 2006-05-25 10:40:14
|
jiriki 06/05/25 03:40:00
Modified: . build-task.xml build.xml
src/org/hansel AntCoverageTask.java CoverageDecorator.java
HanselCodeAdapter.java HanselFrame.java
HanselInterpreter.java Probe.java ProbeData.java
Startup.java Transformer.java Util.java
src/org/hanseltest CoverSimple.java
Removed: lib asm-analysis.jar asm-attrs.jar asm-tree.jar
asm-util.jar asm.jar
src/org/hansel/stack ArgsEntry.java InvokeEntry.java
InvokeStaticEntry.java
Log:
converted to asm3.0-beta2
Revision Changes Path
1.3 +13 -2 hansel/build-task.xml
Index: build-task.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build-task.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- build-task.xml 30 Sep 2002 19:14:24 -0000 1.2
+++ build-task.xml 25 May 2006 10:39:59 -0000 1.3
@@ -2,7 +2,16 @@
<property name="hansel.build" value="build"/>
<property name="hansel.classes" value="build/classes"/>
<property name="hansel.src" value="src"/>
-
+
+ <path id="task.classpath">
+ <fileset dir="${hansel.lib}">
+ <include name="**/asm*.jar"/>
+ <include name="**/junit.jar"/>
+ </fileset>
+ <pathelement path="${hansel.classes}"/>
+ <pathelement path="${hansel.testclass}"/>
+ </path>
+
<target name="init">
<mkdir dir="${hansel.build}"/>
</target>
@@ -14,6 +23,8 @@
debug="true"
deprecation="on"
target="1.2"
- includes="org/hansel/AntCoverageTask.java"/>
+ includes="org/hansel/AntCoverageTask.java">
+ <classpath refid="task.classpath"/>
+ </javac>
</target>
</project>
\ No newline at end of file
1.53 +13 -2 hansel/build.xml
Index: build.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build.xml,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- build.xml 25 May 2006 10:32:15 -0000 1.52
+++ build.xml 25 May 2006 10:39:59 -0000 1.53
@@ -17,7 +17,16 @@
<property name="hansel.testclass" value="${hansel.home}/classes"/>
<property name="packages" value="org.hansel.*"/>
-
+
+ <path id="task.classpath">
+ <fileset dir="${hansel.lib}">
+ <include name="**/asm*.jar"/>
+ <include name="**/junit.jar"/>
+ </fileset>
+ <pathelement path="${hansel.classes}"/>
+ <pathelement path="${hansel.testclass}"/>
+ </path>
+
<target name="init">
<mkdir dir="${hansel.build}"/>
<mkdir dir="${hansel.dist}"/>
@@ -29,7 +38,9 @@
classpath="lib/asm-all-3.0_beta2.jar:lib/bcel.jar"
debug="true"
deprecation="on"
- includes="org/hansel/AntCoverageTask.java"/>
+ includes="org/hansel/AntCoverageTask.java">
+ <classpath refid="task.classpath"/>
+ </javac>
</target>
<target name="compile" depends="init">
1.13 +4 -4 hansel/src/org/hansel/AntCoverageTask.java
Index: AntCoverageTask.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/AntCoverageTask.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- AntCoverageTask.java 22 Dec 2004 18:27:31 -0000 1.12
+++ AntCoverageTask.java 25 May 2006 10:40:00 -0000 1.13
@@ -3,8 +3,9 @@
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
-import java.lang.reflect.Modifier;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.text.NumberFormat;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashSet;
@@ -13,14 +14,13 @@
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;
-import java.text.NumberFormat;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
@@ -184,7 +184,7 @@
packageNames = packageNames.replace('.',
File.separatorChar);
- Stack stack = new Stack();
+ Stack<String> stack = new Stack<String>();
StringTokenizer st = new StringTokenizer(packageNames, ",");
while (st.hasMoreTokens()) {
stack.push(st.nextToken().trim());
1.27 +4 -3 hansel/src/org/hansel/CoverageDecorator.java
Index: CoverageDecorator.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/CoverageDecorator.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- CoverageDecorator.java 22 Dec 2004 18:27:32 -0000 1.26
+++ CoverageDecorator.java 25 May 2006 10:40:00 -0000 1.27
@@ -90,8 +90,8 @@
* @param classesCovered Classes that have to be covered.
*/
public CoverageDecorator(Class testClass,
- Class[] classesCovered,
- ProbeFilter probeFilter) {
+ Class[] classesCovered,
+ ProbeFilter probeFilter) {
this(classesCovered, probeFilter);
addTestSuite(testClass);
@@ -138,7 +138,7 @@
}
public void run(TestResult result) {
-
+ //System.out.println("Running test.");
if (!init(result)) {
return;
}
@@ -146,6 +146,7 @@
super.run(result);
shutdown(result);
+ //System.out.println("Exiting test.");
}
private void loadClasses() {
1.5 +253 -252 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HanselCodeAdapter.java 28 Dec 2004 17:20:36 -0000 1.4
+++ HanselCodeAdapter.java 25 May 2006 10:40:00 -0000 1.5
@@ -17,256 +17,257 @@
import static org.objectweb.asm.Opcodes.*;
public class HanselCodeAdapter extends MethodAdapter {
- private boolean first;
- private int pos;
- private List instructions;
- private String className;
- private String methodName;
- private HanselFrame[] frames;
- private List<Probe> probes;
- private List tryCatchBlocks;
- private Map<Label, Integer> labelPos;
- private Probe methodProbe;
- private int access;
-
- public HanselCodeAdapter(int access, String className,
- String methodName, List instructions, List tryCatchBlocks, MethodVisitor mv,
- HanselFrame[] frames) {
- super(mv);
-
- this.access = access;
- this.first = true;
- this.pos = 0;
- this.instructions = instructions;
- this.className = className;
- this.methodName = methodName;
- this.frames = frames;
- this.probes = new Vector<Probe>();
- this.labelPos = new HashMap<Label, Integer>();
- this.tryCatchBlocks = tryCatchBlocks;
- }
-
- private void addProbe(Probe probe) {
- probe.insertProbeCode(mv);
- probes.add(probe);
- }
-
- private void checkFirst() {
- pos++;
-
- if (!first) {
- return;
- }
- first = false;
-
- if (!isEmptyPrivateConstructor()) {
- methodProbe = ProbeFactory.createMethodProbe(getProbeData());
- addProbe(methodProbe);
- }
- }
-
- private boolean isEmptyPrivateConstructor() {
- return "<init>".equals(methodName) &&
- ((access & Opcodes.ACC_PRIVATE) > 0) &&
- instructions.size() == 5;
- }
-
- private ProbeData getProbeData() {
- return new ProbeData(
- className,
- methodName,
- frames[pos - 1],
- pos,
- instructions.size());
- }
-
- public void visitLineNumber(int line, Label start) {
- super.visitLineNumber(line, start);
-
- int pos = labelPos.get(start);
-
- for (int i=0; i<probes.size(); i++) {
- ProbeData pd = probes.get(i).getProbeData();
- if (pos < pd.getPosition()) {
- pd.setLineNumber(line);
- }
- }
- }
-
- public void visitInsn(final int opcode) {
- checkFirst();
-
- mv.visitInsn(opcode);
- }
-
- public void visitIntInsn(final int opcode, final int operand) {
- checkFirst();
-
- mv.visitIntInsn(opcode, operand);
- }
-
- public void visitVarInsn(final int opcode, final int var) {
- checkFirst();
-
- mv.visitVarInsn(opcode, var);
- }
-
- public void visitFieldInsn(final int opcode,
- final String owner,
- final String name,
- final String desc) {
- checkFirst();
-
- mv.visitFieldInsn(opcode, owner, name, desc);
- }
-
- public void visitMethodInsn(final int opcode,
- final String owner,
- final String name,
- final String desc) {
- checkFirst();
-
- mv.visitMethodInsn(opcode, owner, name, desc);
- }
-
- public void visitJumpInsn(final int opcode, final Label label) {
- checkFirst();
-
- if (opcode != Opcodes.GOTO) {
- addProbe(ProbeFactory.createBranchProbe(getProbeData(),
- opcode));
- }
-
- mv.visitJumpInsn(opcode, label);
- }
-
- public void visitLabel(final Label label) {
- pos++;
-
- mv.visitLabel(label);
-
- labelPos.put(label, pos);
-
- if (isExceptionHandler(label) && !isMonitorExitHandler()) {
- addProbe(ProbeFactory.createExceptionProbe(getProbeData(),
- methodProbe));
- }
- }
-
- private boolean isMonitorExitHandler() {
- if (instructions.size() < pos + 6) {
- return false;
- }
-
- if (!isOpcode(pos, ASTORE)) {
- return false;
- }
-
- if (!isOpcode(pos + 1, ALOAD)) {
- return false;
- }
-
- if (!isOpcode(pos + 2, MONITOREXIT)) {
- return false;
- }
-
- if (!isLabel(pos + 3)) {
- return false;
- }
-
- if (!isOpcode(pos + 4, ALOAD)) {
- return false;
- }
-
- if (!isOpcode(pos + 5, ATHROW)) {
- return false;
- }
- return true;
- }
-
- private boolean isLabel(int pos) {
- return (instructions.get(pos) instanceof LabelNode);
- }
-
- private boolean isOpcode(int pos, int opcode) {
- return (instructions.get(pos) instanceof AbstractInsnNode)
- && (((AbstractInsnNode) instructions.get(pos)).getOpcode() == opcode);
- }
-
- private boolean isExceptionHandler(Label l) {
- Iterator it = tryCatchBlocks.iterator();
- while (it.hasNext()) {
- if (((TryCatchBlockNode) it.next()).handler == l) {
- return true;
- }
- }
-
- return false;
- }
-
- public void visitLdcInsn(final Object cst) {
- checkFirst();
-
- mv.visitLdcInsn(cst);
- }
-
- public void visitIincInsn(final int var, final int increment) {
- checkFirst();
-
- mv.visitIincInsn(var, increment);
- }
-
- public void visitTableSwitchInsn(final int min,
- final int max,
- final Label dflt,
- final Label labels[]) {
- checkFirst();
-
- addProbe(ProbeFactory.createSelectProbe(getProbeData(),
- min, max, dflt, labels));
-
- mv.visitTableSwitchInsn(min, max, dflt, labels);
- }
-
- public void visitLookupSwitchInsn(final Label dflt,
- final int keys[],
- final Label labels[]) {
- checkFirst();
-
- addProbe(ProbeFactory.createSelectProbe(getProbeData(),
- dflt, keys, labels));
-
- mv.visitLookupSwitchInsn(dflt, keys, labels);
- }
-
- public void visitMultiANewArrayInsn(final String desc, final int dims) {
- checkFirst();
-
- mv.visitMultiANewArrayInsn(desc, dims);
- }
-
- public void visitTryCatchBlock(final Label start, final Label end,
- final Label handler, final String type) {
- checkFirst();
-
- mv.visitTryCatchBlock(start, end, handler, type);
- }
-
- public void visitTypeInsn(int param, String str) {
- checkFirst();
-
- super.visitTypeInsn(param, str);
- }
-
- public void visitAttribute(org.objectweb.asm.Attribute attribute) {
- checkFirst();
-
- super.visitAttribute(attribute);
- }
-
- public void visitMaxs(int param, int param1) {
- checkFirst();
-
- super.visitMaxs(param, param1);
- }
+ private boolean first;
+ private int pos;
+ private List instructions;
+ private String className;
+ private String methodName;
+ private HanselFrame[] frames;
+ private List<Probe> probes;
+ private List tryCatchBlocks;
+ private Probe methodProbe;
+ private int access;
+
+ public HanselCodeAdapter(int access, String className,
+ String methodName, List instructions, List tryCatchBlocks, MethodVisitor mv,
+ HanselFrame[] frames) {
+ super(mv);
+
+ this.access = access;
+ this.first = true;
+ this.pos = 0;
+ this.instructions = instructions;
+ this.className = className;
+ this.methodName = methodName;
+ this.frames = frames;
+ this.probes = new Vector<Probe>();
+ this.tryCatchBlocks = tryCatchBlocks;
+ }
+
+ private void addProbe(Probe probe) {
+ probe.insertProbeCode(mv);
+ probes.add(probe);
+ }
+
+ private void checkFirst() {
+ pos++;
+
+ if (!first) {
+ return;
+ }
+ first = false;
+
+ if (!isEmptyPrivateConstructor() && !isStaticConstructor()) {
+ methodProbe = ProbeFactory.createMethodProbe(getProbeData());
+ addProbe(methodProbe);
+ }
+ }
+
+ private boolean isEmptyPrivateConstructor() {
+ return "<init>".equals(methodName) &&
+ ((access & Opcodes.ACC_PRIVATE) > 0) &&
+ instructions.size() == 5;
+ }
+
+ private boolean isStaticConstructor() {
+ return "<clinit>".equals(methodName);
+ }
+
+ private ProbeData getProbeData() {
+ return new ProbeData(
+ className,
+ methodName,
+ frames[pos - 1],
+ pos,
+ instructions.size());
+ }
+
+ public void visitLineNumber(int line, Label start) {
+ super.visitLineNumber(line, start);
+
+ int startIndex = Util.findIndex(instructions, start);
+
+
+ for (int i=0; i<probes.size(); i++) {
+ ProbeData pd = probes.get(i).getProbeData();
+ if (startIndex < pd.getPosition()) {
+ pd.setLineNumber(line);
+ }
+ }
+ }
+
+ public void visitInsn(final int opcode) {
+ checkFirst();
+
+ mv.visitInsn(opcode);
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ checkFirst();
+
+ mv.visitIntInsn(opcode, operand);
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ checkFirst();
+
+ mv.visitVarInsn(opcode, var);
+ }
+
+ public void visitFieldInsn(final int opcode,
+ final String owner,
+ final String name,
+ final String desc) {
+ checkFirst();
+
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ public void visitMethodInsn(final int opcode,
+ final String owner,
+ final String name,
+ final String desc) {
+ checkFirst();
+
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ checkFirst();
+
+ if (opcode != Opcodes.GOTO) {
+ addProbe(ProbeFactory.createBranchProbe(getProbeData(),
+ opcode));
+ }
+
+ mv.visitJumpInsn(opcode, label);
+ }
+
+ public void visitLabel(final Label label) {
+ pos++;
+
+ mv.visitLabel(label);
+
+ if (isExceptionHandler(label) && !isMonitorExitHandler()) {
+ addProbe(ProbeFactory.createExceptionProbe(getProbeData(),
+ methodProbe));
+ }
+ }
+
+ private boolean isMonitorExitHandler() {
+ if (instructions.size() < pos + 6) {
+ return false;
+ }
+
+ if (!isOpcode(pos, ASTORE)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 1, ALOAD)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 2, MONITOREXIT)) {
+ return false;
+ }
+
+ if (!isLabel(pos + 3)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 4, ALOAD)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 5, ATHROW)) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isLabel(int pos) {
+ return (instructions.get(pos) instanceof LabelNode);
+ }
+
+ private boolean isOpcode(int pos, int opcode) {
+ return (instructions.get(pos) instanceof AbstractInsnNode)
+ && (((AbstractInsnNode) instructions.get(pos)).getOpcode() == opcode);
+ }
+
+ private boolean isExceptionHandler(Label l) {
+ Iterator it = tryCatchBlocks.iterator();
+ while (it.hasNext()) {
+ if (((TryCatchBlockNode) it.next()).handler == l) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ checkFirst();
+
+ mv.visitLdcInsn(cst);
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ checkFirst();
+
+ mv.visitIincInsn(var, increment);
+ }
+
+ public void visitTableSwitchInsn(final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[]) {
+ checkFirst();
+
+ addProbe(ProbeFactory.createSelectProbe(getProbeData(),
+ min, max, dflt, labels));
+
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ public void visitLookupSwitchInsn(final Label dflt,
+ final int keys[],
+ final Label labels[]) {
+ checkFirst();
+
+ addProbe(ProbeFactory.createSelectProbe(getProbeData(),
+ dflt, keys, labels));
+
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ checkFirst();
+
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+
+ public void visitTryCatchBlock(final Label start, final Label end,
+ final Label handler, final String type) {
+ checkFirst();
+
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+
+ public void visitTypeInsn(int param, String str) {
+ checkFirst();
+
+ super.visitTypeInsn(param, str);
+ }
+
+ public void visitAttribute(org.objectweb.asm.Attribute attribute) {
+ checkFirst();
+
+ super.visitAttribute(attribute);
+ }
+
+ public void visitMaxs(int param, int param1) {
+ checkFirst();
+
+ super.visitMaxs(param, param1);
+ }
}
1.4 +0 -1 hansel/src/org/hansel/HanselFrame.java
Index: HanselFrame.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselFrame.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HanselFrame.java 25 May 2006 10:32:17 -0000 1.3
+++ HanselFrame.java 25 May 2006 10:40:00 -0000 1.4
@@ -8,7 +8,6 @@
import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.Value;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
/**
*
1.4 +4 -1 hansel/src/org/hansel/HanselInterpreter.java
Index: HanselInterpreter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselInterpreter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HanselInterpreter.java 28 Dec 2004 17:20:36 -0000 1.3
+++ HanselInterpreter.java 25 May 2006 10:40:00 -0000 1.4
@@ -7,6 +7,7 @@
import org.hansel.stack.BinaryOperatorEntry;
import org.hansel.stack.PrefixOpEntry;
+import org.objectweb.asm.Label;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.analysis.DataflowInterpreter;
@@ -16,6 +17,7 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.IincInsnNode;
+import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
@@ -127,7 +129,6 @@
while (it.hasNext()) {
LocalVariableNode lvn = (LocalVariableNode) it.next();
-
/*System.out.println("lvn: " + lvn);
System.out.println("lvn.index: " + lvn.index);
System.out.println("indec: " + index);
@@ -146,6 +147,8 @@
return new HanselValue("Unknown local: " + index, false, 1);
}
+
+
private int getSize(String desc) {
return Type.getType(desc).getSize();
}
1.21 +2 -1 hansel/src/org/hansel/Probe.java
Index: Probe.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Probe.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Probe.java 22 Dec 2004 18:27:32 -0000 1.20
+++ Probe.java 25 May 2006 10:40:00 -0000 1.21
@@ -78,7 +78,8 @@
public void run(TestResult result) {
result.startTest(this);
- if (displayFailure()) {
+ if (displayFailure()) {
+ //System.out.println("Probe failed: " + getID() + " " + pd.getMethodName());
result.addFailure(this, new CoverageError(pd));
}
1.8 +1 -7 hansel/src/org/hansel/ProbeData.java
Index: ProbeData.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeData.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ProbeData.java 25 May 2006 10:32:20 -0000 1.7
+++ ProbeData.java 25 May 2006 10:40:00 -0000 1.8
@@ -1,8 +1,6 @@
package org.hansel;
import org.hansel.stack.HanselValue;
-import org.objectweb.asm.tree.analysis.AnalyzerException;
-import org.objectweb.asm.tree.analysis.Value;
public class ProbeData {
private String classname;
@@ -64,11 +62,7 @@
public HanselValue getStackEntry(int depth) {
if (frame != null) {
- //try {
- return (HanselValue) frame.getStack(depth);
- //} catch (AnalyzerException e) {
- // throw new IllegalStateException(e);
- //}
+ return (HanselValue) frame.getStack(depth);
} else {
return new HanselValue("<unknown>", false, 1);
}
1.3 +18 -8 hansel/src/org/hansel/Startup.java
Index: Startup.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Startup.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Startup.java 22 Dec 2004 18:27:32 -0000 1.2
+++ Startup.java 25 May 2006 10:40:00 -0000 1.3
@@ -11,6 +11,8 @@
import java.lang.instrument.UnmodifiableClassException;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.List;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
@@ -24,6 +26,11 @@
public static void premain(String options, Instrumentation instrumentation) {
Startup.instrumentation = instrumentation;
+
+ // load class, otherwise the class is loaded in transform(...) and might cause
+ // a deadlock.
+ new ClassKey(null, null);
+
instrumentation.addTransformer(new ClassBufferCache());
}
@@ -58,12 +65,14 @@
transformer = new Transformer(classNames);
instrumentation.addTransformer(transformer);
+ List<ClassDefinition> redefine = new ArrayList<ClassDefinition>();
+
for (int i=0; i<allClasses.length; i++) {
String className = allClasses[i].getName();
if (classNames.contains(className)) {
// Workaround for bug 5092850: Link class by calling getDeclaredFields.
- allClasses[i].getDeclaredFields();
+ //allClasses[i].getDeclaredFields();
byte[] classfileBuffer = map.get(new ClassKey(allClasses[i].getName().replace('.', '/'),
allClasses[i].getClassLoader()));
@@ -82,12 +91,13 @@
allClasses[i],
allClasses[i].getProtectionDomain(),
classfileBuffer);*/
- instrumentation.redefineClasses(new ClassDefinition[] {
- new ClassDefinition(allClasses[i], classfileBuffer/*newClassDefinition*/)});
+ redefine.add(new ClassDefinition(allClasses[i], classfileBuffer/*newClassDefinition*/));
+
}
}
}
-
+
+ instrumentation.redefineClasses(redefine.toArray(new ClassDefinition[redefine.size()]));
}
@@ -111,9 +121,9 @@
public static void tearDown()
throws ClassNotFoundException, UnmodifiableClassException {
- /*instrumentation.removeTransformer(transformer);
+ instrumentation.removeTransformer(transformer);
transformer.undo(instrumentation);
- transformer = null;*/
+ transformer = null;
}
private static class ClassKey {
@@ -153,8 +163,8 @@
ProtectionDomain protectionDomain,
byte[] classfileBuffer) {
//System.out.println("Transforming: " + new ClassKey(className, loader));
- map.put(new ClassKey(className, loader), classfileBuffer);
- return null;
+ map.put(new ClassKey(className, loader), classfileBuffer);
+ return null;
}
}
}
1.4 +20 -10 hansel/src/org/hansel/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Transformer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Transformer.java 25 May 2006 10:32:20 -0000 1.3
+++ Transformer.java 25 May 2006 10:40:00 -0000 1.4
@@ -47,19 +47,20 @@
cn.accept(ta);
+ //System.out.println("Redefining class: " + className + " " + loader);
redefinedClasses.add(new ClassEntry(className, loader,
classfileBuffer));
byte[] result = cw.toByteArray();
- /*if (cn.name.endsWith("Lock")) {
- Thread.dumpStack();
- FileOutputStream out = new FileOutputStream("test.class");
- out.write(result);
- out.close();
- }*/
-
+ if (cn.name.endsWith("EventQueue")) {
+ FileOutputStream out = new FileOutputStream("test.class");
+ out.write(result);
+ out.close();
+ }
+ //System.out.println("Success: " + className);
+
return result;
- } catch (Exception e) {
+ } catch (Throwable e) {
e.printStackTrace();
throw new IllegalClassFormatException(e.getMessage());
}
@@ -71,7 +72,7 @@
ClassDefinition[] oldClasses =
new ClassDefinition[redefinedClasses.size()];
- for (int i=0; i<oldClasses.length; i++) {
+ for (int i=0; i<oldClasses.length; i++) {
oldClasses[i] =
redefinedClasses.get(i).toClassDefinition();
}
@@ -89,10 +90,19 @@
this.cl = cl;
this.classname = classname;
this.classBuffer = classBuffer;
+
+ /*try {
+ if (classname.endsWith("EventQueue")) {
+ FileOutputStream out = new FileOutputStream("testHansel.class");
+ out.write(classBuffer);
+ out.close();
+ }} catch (Exception e) {
+ e.printStackTrace();
+ } */
}
public ClassDefinition toClassDefinition() throws ClassNotFoundException {
- return new ClassDefinition(cl.loadClass(classname),
+ return new ClassDefinition(cl.loadClass(classname.replace('/', '.')),
classBuffer);
}
}
1.10 +17 -0 hansel/src/org/hansel/Util.java
Index: Util.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Util.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Util.java 18 Oct 2003 15:39:45 -0000 1.9
+++ Util.java 25 May 2006 10:40:00 -0000 1.10
@@ -4,6 +4,10 @@
import junit.framework.TestResult;
import java.util.Enumeration;
+import java.util.List;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.tree.LabelNode;
/**
* Class containing utility methods.
@@ -53,5 +57,18 @@
TestFailure failure = (TestFailure) e.nextElement();
failure.thrownException().printStackTrace();
}
+ }
+
+ public static int findIndex(List instructions, Label label) {
+ for (int i=0; i<instructions.size(); i++) {
+ Object obj = instructions.get(i);
+ if (obj instanceof LabelNode) {
+ if (((LabelNode) obj).label == label) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
}
}
1.3 +0 -1 hansel/src/org/hanseltest/CoverSimple.java
Index: CoverSimple.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/CoverSimple.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CoverSimple.java 5 Sep 2004 13:52:55 -0000 1.2
+++ CoverSimple.java 25 May 2006 10:40:00 -0000 1.3
@@ -1,6 +1,5 @@
package org.hanseltest;
-import java.util.logging.Logger;
/**
* Simple code to be covered bythe testcases.
|
|
From: Niklas M. <ji...@us...> - 2006-05-25 10:32:22
|
jiriki 06/05/25 03:32:21
Modified: src/org/hansel HanselFrame.java ProbeData.java
Transformer.java
Log:
Updated to asm 3.0beta2.
Revision Changes Path
1.3 +1 -1 hansel/src/org/hansel/HanselFrame.java
Index: HanselFrame.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselFrame.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HanselFrame.java 22 Dec 2004 18:27:32 -0000 1.2
+++ HanselFrame.java 25 May 2006 10:32:17 -0000 1.3
@@ -25,7 +25,7 @@
super(frame);
}
- public void push(Value value) throws AnalyzerException {
+ public void push(Value value) {
assert value != null : "Value may not be null.";
super.push(value);
}
1.7 +4 -4 hansel/src/org/hansel/ProbeData.java
Index: ProbeData.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/ProbeData.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProbeData.java 22 Dec 2004 18:27:32 -0000 1.6
+++ ProbeData.java 25 May 2006 10:32:20 -0000 1.7
@@ -64,11 +64,11 @@
public HanselValue getStackEntry(int depth) {
if (frame != null) {
- try {
+ //try {
return (HanselValue) frame.getStack(depth);
- } catch (AnalyzerException e) {
- throw new IllegalStateException(e);
- }
+ //} catch (AnalyzerException e) {
+ // throw new IllegalStateException(e);
+ //}
} else {
return new HanselValue("<unknown>", false, 1);
}
1.3 +2 -2 hansel/src/org/hansel/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/Transformer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Transformer.java 22 Dec 2004 18:27:32 -0000 1.2
+++ Transformer.java 25 May 2006 10:32:20 -0000 1.3
@@ -38,10 +38,10 @@
try {
ClassReader cr = new ClassReader(new ByteArrayInputStream(classfileBuffer));
- ClassWriter cw = new ClassWriter(true);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES + ClassWriter.COMPUTE_MAXS);
ClassNode cn = new ClassNode();
- cr.accept(cn, false);
+ cr.accept(cn, 0);
TransformingAdapter ta = new TransformingAdapter(cw, cn);
|
|
From: Niklas M. <ji...@us...> - 2006-05-25 10:32:21
|
jiriki 06/05/25 03:32:17 Added: lib asm-all-3.0_beta2.jar Log: Updated to asm 3.0beta2. Revision Changes Path 1.1 hansel/lib/asm-all-3.0_beta2.jar <<Binary file>> |
|
From: Niklas M. <ji...@us...> - 2006-05-25 10:32:20
|
jiriki 06/05/25 03:32:16
Modified: . build-hansel.xml build.xml
Log:
Updated to asm 3.0beta2.
Revision Changes Path
1.9 +2 -6 hansel/build-hansel.xml
Index: build-hansel.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build-hansel.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- build-hansel.xml 22 Dec 2004 18:27:08 -0000 1.8
+++ build-hansel.xml 25 May 2006 10:32:15 -0000 1.9
@@ -4,15 +4,11 @@
classpath="lib/checkstyle-all-2.3.jar"/>
<taskdef name="coverage"
classname="org.hansel.AntCoverageTask"
- classpath="lib/bcel.jar:${hansel.classes}"/>
+ classpath="lib/asm*.jar:${hansel.classes}"/>
<path id="hansel.classpath">
<fileset dir="${hansel.lib}">
- <include name="**/asm.jar"/>
- <include name="**/asm-analysis.jar"/>
- <include name="**/asm-tree.jar"/>
- <include name="**/asm-util.jar"/>
- <include name="**/asm-attrs.jar"/>
+ <include name="**/asm-all-3.0_beta2.jar"/>
<include name="**/junit.jar"/>
</fileset>
<pathelement path="${hansel.classes}"/>
1.52 +1 -1 hansel/build.xml
Index: build.xml
===================================================================
RCS file: /cvsroot/hansel/hansel/build.xml,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- build.xml 22 Dec 2004 18:27:30 -0000 1.51
+++ build.xml 25 May 2006 10:32:15 -0000 1.52
@@ -26,7 +26,7 @@
<!-- Compile the ant task. -->
<javac srcdir="${hansel.src}"
destdir="${hansel.classes}"
- classpath="lib/asm.jar:lib/asm-attrs.jar:lib/asm-tree.jar:lib/asm-analysis.jar:lib/bcel.jar"
+ classpath="lib/asm-all-3.0_beta2.jar:lib/bcel.jar"
debug="true"
deprecation="on"
includes="org/hansel/AntCoverageTask.java"/>
|
|
From: SourceForge.net <no...@so...> - 2005-02-23 16:17:31
|
Bugs item #1149921, was opened at 2005-02-23 16:17 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=472899&aid=1149921&group_id=54171 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Merten Schumann (merten) Assigned to: Nobody/Anonymous (nobody) Summary: problem with <java package>.getSpecificationVersion() Initial Comment: Hello, in latest Hansel 1.02, I could not run my tests (strange failures happened, from my TestCase's setUp() methods, something like java.lang.ExceptionInInitializerError. Found the reason to be this code in a static initialize in one of my classes: Package pack = Package.getPackage("bla.blu.bli"); String vers = pack.getSpecificationVersion(); The second line of code did not work with Hansel ... No idea if it's only preventing Hansel from working when placed in a static initializer ... Works great besides from my issue with this special packages stuff!!! :-) cu Merten ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=472899&aid=1149921&group_id=54171 |
|
From: Niklas M. <ji...@us...> - 2004-12-28 17:20:45
|
jiriki 04/12/28 09:20:38
Modified: src/org/hansel HanselCodeAdapter.java HanselInterpreter.java
src/org/hansel/stack ArgsEntry.java
src/org/hanseltest TestBug753855.java
Added: . .project
Log:
Fixed linenumber bug,.
Revision Changes Path
1.4 +254 -248 hansel/src/org/hansel/HanselCodeAdapter.java
Index: HanselCodeAdapter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselCodeAdapter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HanselCodeAdapter.java 22 Dec 2004 18:27:32 -0000 1.3
+++ HanselCodeAdapter.java 28 Dec 2004 17:20:36 -0000 1.4
@@ -3,6 +3,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
+import java.util.Map;
+import java.util.HashMap;
import org.objectweb.asm.MethodAdapter;
import org.objectweb.asm.MethodVisitor;
@@ -15,252 +17,256 @@
import static org.objectweb.asm.Opcodes.*;
public class HanselCodeAdapter extends MethodAdapter {
- private boolean first;
- private int pos;
- private List instructions;
- private String className;
- private String methodName;
- private HanselFrame[] frames;
- private List<Probe> probes;
- private List tryCatchBlocks;
- private Probe methodProbe;
- private int access;
-
- public HanselCodeAdapter(int access, String className,
- String methodName, List instructions, List tryCatchBlocks, MethodVisitor mv,
- HanselFrame[] frames) {
- super(mv);
-
- this.access = access;
- this.first = true;
- this.pos = 0;
- this.instructions = instructions;
- this.className = className;
- this.methodName = methodName;
- this.frames = frames;
- this.probes = new Vector<Probe>();
- this.tryCatchBlocks = tryCatchBlocks;
- }
-
- private void addProbe(Probe probe) {
- probe.insertProbeCode(mv);
- probes.add(probe);
- }
-
- private void checkFirst() {
- pos++;
-
- if (!first) {
- return;
- }
- first = false;
-
- if (!isEmptyPrivateConstructor()) {
- methodProbe = ProbeFactory.createMethodProbe(getProbeData());
- addProbe(methodProbe);
- }
- }
-
- private boolean isEmptyPrivateConstructor() {
- return "<init>".equals(methodName) &&
- ((access & Opcodes.ACC_PRIVATE) > 0) &&
- instructions.size() == 5;
- }
-
- private ProbeData getProbeData() {
- return new ProbeData(
- className,
- methodName,
- frames[pos - 1],
- pos,
- instructions.size());
- }
-
- public void visitLineNumber(int line, Label start) {
- super.visitLineNumber(line, start);
-
- int startIndex = instructions.indexOf(start);
-
- for (int i=0; i<probes.size(); i++) {
- ProbeData pd = probes.get(i).getProbeData();
- if (startIndex < pd.getPosition()) {
- pd.setLineNumber(line);
- }
- }
- }
-
- public void visitInsn(final int opcode) {
- checkFirst();
-
- mv.visitInsn(opcode);
- }
-
- public void visitIntInsn(final int opcode, final int operand) {
- checkFirst();
-
- mv.visitIntInsn(opcode, operand);
- }
-
- public void visitVarInsn(final int opcode, final int var) {
- checkFirst();
-
- mv.visitVarInsn(opcode, var);
- }
-
- public void visitFieldInsn(final int opcode,
- final String owner,
- final String name,
- final String desc) {
- checkFirst();
-
- mv.visitFieldInsn(opcode, owner, name, desc);
- }
-
- public void visitMethodInsn(final int opcode,
- final String owner,
- final String name,
- final String desc) {
- checkFirst();
-
- mv.visitMethodInsn(opcode, owner, name, desc);
- }
-
- public void visitJumpInsn(final int opcode, final Label label) {
- checkFirst();
-
- if (opcode != Opcodes.GOTO) {
- addProbe(ProbeFactory.createBranchProbe(getProbeData(),
- opcode));
- }
-
- mv.visitJumpInsn(opcode, label);
- }
-
- public void visitLabel(final Label label) {
- pos++;
-
- mv.visitLabel(label);
-
- if (isExceptionHandler(label) && !isMonitorExitHandler()) {
- addProbe(ProbeFactory.createExceptionProbe(getProbeData(),
- methodProbe));
- }
- }
-
- private boolean isMonitorExitHandler() {
- if (instructions.size() < pos + 6) {
- return false;
- }
-
- if (!isOpcode(pos, ASTORE)) {
- return false;
- }
-
- if (!isOpcode(pos + 1, ALOAD)) {
- return false;
- }
-
- if (!isOpcode(pos + 2, MONITOREXIT)) {
- return false;
- }
-
- if (!isLabel(pos + 3)) {
- return false;
- }
-
- if (!isOpcode(pos + 4, ALOAD)) {
- return false;
- }
-
- if (!isOpcode(pos + 5, ATHROW)) {
- return false;
- }
- return true;
- }
-
- private boolean isLabel(int pos) {
- return (instructions.get(pos) instanceof LabelNode);
- }
-
- private boolean isOpcode(int pos, int opcode) {
- return (instructions.get(pos) instanceof AbstractInsnNode)
- && (((AbstractInsnNode) instructions.get(pos)).getOpcode() == opcode);
- }
-
- private boolean isExceptionHandler(Label l) {
- Iterator it = tryCatchBlocks.iterator();
- while (it.hasNext()) {
- if (((TryCatchBlockNode) it.next()).handler == l) {
- return true;
- }
- }
-
- return false;
- }
-
- public void visitLdcInsn(final Object cst) {
- checkFirst();
-
- mv.visitLdcInsn(cst);
- }
-
- public void visitIincInsn(final int var, final int increment) {
- checkFirst();
-
- mv.visitIincInsn(var, increment);
- }
-
- public void visitTableSwitchInsn(final int min,
- final int max,
- final Label dflt,
- final Label labels[]) {
- checkFirst();
-
- addProbe(ProbeFactory.createSelectProbe(getProbeData(),
- min, max, dflt, labels));
-
- mv.visitTableSwitchInsn(min, max, dflt, labels);
- }
-
- public void visitLookupSwitchInsn(final Label dflt,
- final int keys[],
- final Label labels[]) {
- checkFirst();
-
- addProbe(ProbeFactory.createSelectProbe(getProbeData(),
- dflt, keys, labels));
-
- mv.visitLookupSwitchInsn(dflt, keys, labels);
- }
-
- public void visitMultiANewArrayInsn(final String desc, final int dims) {
- checkFirst();
-
- mv.visitMultiANewArrayInsn(desc, dims);
- }
-
- public void visitTryCatchBlock(final Label start, final Label end,
- final Label handler, final String type) {
- checkFirst();
-
- mv.visitTryCatchBlock(start, end, handler, type);
- }
-
- public void visitTypeInsn(int param, String str) {
- checkFirst();
-
- super.visitTypeInsn(param, str);
- }
-
- public void visitAttribute(org.objectweb.asm.Attribute attribute) {
- checkFirst();
-
- super.visitAttribute(attribute);
- }
-
- public void visitMaxs(int param, int param1) {
- checkFirst();
-
- super.visitMaxs(param, param1);
- }
+ private boolean first;
+ private int pos;
+ private List instructions;
+ private String className;
+ private String methodName;
+ private HanselFrame[] frames;
+ private List<Probe> probes;
+ private List tryCatchBlocks;
+ private Map<Label, Integer> labelPos;
+ private Probe methodProbe;
+ private int access;
+
+ public HanselCodeAdapter(int access, String className,
+ String methodName, List instructions, List tryCatchBlocks, MethodVisitor mv,
+ HanselFrame[] frames) {
+ super(mv);
+
+ this.access = access;
+ this.first = true;
+ this.pos = 0;
+ this.instructions = instructions;
+ this.className = className;
+ this.methodName = methodName;
+ this.frames = frames;
+ this.probes = new Vector<Probe>();
+ this.labelPos = new HashMap<Label, Integer>();
+ this.tryCatchBlocks = tryCatchBlocks;
+ }
+
+ private void addProbe(Probe probe) {
+ probe.insertProbeCode(mv);
+ probes.add(probe);
+ }
+
+ private void checkFirst() {
+ pos++;
+
+ if (!first) {
+ return;
+ }
+ first = false;
+
+ if (!isEmptyPrivateConstructor()) {
+ methodProbe = ProbeFactory.createMethodProbe(getProbeData());
+ addProbe(methodProbe);
+ }
+ }
+
+ private boolean isEmptyPrivateConstructor() {
+ return "<init>".equals(methodName) &&
+ ((access & Opcodes.ACC_PRIVATE) > 0) &&
+ instructions.size() == 5;
+ }
+
+ private ProbeData getProbeData() {
+ return new ProbeData(
+ className,
+ methodName,
+ frames[pos - 1],
+ pos,
+ instructions.size());
+ }
+
+ public void visitLineNumber(int line, Label start) {
+ super.visitLineNumber(line, start);
+
+ int pos = labelPos.get(start);
+
+ for (int i=0; i<probes.size(); i++) {
+ ProbeData pd = probes.get(i).getProbeData();
+ if (pos < pd.getPosition()) {
+ pd.setLineNumber(line);
+ }
+ }
+ }
+
+ public void visitInsn(final int opcode) {
+ checkFirst();
+
+ mv.visitInsn(opcode);
+ }
+
+ public void visitIntInsn(final int opcode, final int operand) {
+ checkFirst();
+
+ mv.visitIntInsn(opcode, operand);
+ }
+
+ public void visitVarInsn(final int opcode, final int var) {
+ checkFirst();
+
+ mv.visitVarInsn(opcode, var);
+ }
+
+ public void visitFieldInsn(final int opcode,
+ final String owner,
+ final String name,
+ final String desc) {
+ checkFirst();
+
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ }
+
+ public void visitMethodInsn(final int opcode,
+ final String owner,
+ final String name,
+ final String desc) {
+ checkFirst();
+
+ mv.visitMethodInsn(opcode, owner, name, desc);
+ }
+
+ public void visitJumpInsn(final int opcode, final Label label) {
+ checkFirst();
+
+ if (opcode != Opcodes.GOTO) {
+ addProbe(ProbeFactory.createBranchProbe(getProbeData(),
+ opcode));
+ }
+
+ mv.visitJumpInsn(opcode, label);
+ }
+
+ public void visitLabel(final Label label) {
+ pos++;
+
+ mv.visitLabel(label);
+
+ labelPos.put(label, pos);
+
+ if (isExceptionHandler(label) && !isMonitorExitHandler()) {
+ addProbe(ProbeFactory.createExceptionProbe(getProbeData(),
+ methodProbe));
+ }
+ }
+
+ private boolean isMonitorExitHandler() {
+ if (instructions.size() < pos + 6) {
+ return false;
+ }
+
+ if (!isOpcode(pos, ASTORE)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 1, ALOAD)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 2, MONITOREXIT)) {
+ return false;
+ }
+
+ if (!isLabel(pos + 3)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 4, ALOAD)) {
+ return false;
+ }
+
+ if (!isOpcode(pos + 5, ATHROW)) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isLabel(int pos) {
+ return (instructions.get(pos) instanceof LabelNode);
+ }
+
+ private boolean isOpcode(int pos, int opcode) {
+ return (instructions.get(pos) instanceof AbstractInsnNode)
+ && (((AbstractInsnNode) instructions.get(pos)).getOpcode() == opcode);
+ }
+
+ private boolean isExceptionHandler(Label l) {
+ Iterator it = tryCatchBlocks.iterator();
+ while (it.hasNext()) {
+ if (((TryCatchBlockNode) it.next()).handler == l) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void visitLdcInsn(final Object cst) {
+ checkFirst();
+
+ mv.visitLdcInsn(cst);
+ }
+
+ public void visitIincInsn(final int var, final int increment) {
+ checkFirst();
+
+ mv.visitIincInsn(var, increment);
+ }
+
+ public void visitTableSwitchInsn(final int min,
+ final int max,
+ final Label dflt,
+ final Label labels[]) {
+ checkFirst();
+
+ addProbe(ProbeFactory.createSelectProbe(getProbeData(),
+ min, max, dflt, labels));
+
+ mv.visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ public void visitLookupSwitchInsn(final Label dflt,
+ final int keys[],
+ final Label labels[]) {
+ checkFirst();
+
+ addProbe(ProbeFactory.createSelectProbe(getProbeData(),
+ dflt, keys, labels));
+
+ mv.visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ public void visitMultiANewArrayInsn(final String desc, final int dims) {
+ checkFirst();
+
+ mv.visitMultiANewArrayInsn(desc, dims);
+ }
+
+ public void visitTryCatchBlock(final Label start, final Label end,
+ final Label handler, final String type) {
+ checkFirst();
+
+ mv.visitTryCatchBlock(start, end, handler, type);
+ }
+
+ public void visitTypeInsn(int param, String str) {
+ checkFirst();
+
+ super.visitTypeInsn(param, str);
+ }
+
+ public void visitAttribute(org.objectweb.asm.Attribute attribute) {
+ checkFirst();
+
+ super.visitAttribute(attribute);
+ }
+
+ public void visitMaxs(int param, int param1) {
+ checkFirst();
+
+ super.visitMaxs(param, param1);
+ }
}
1.3 +10 -2 hansel/src/org/hansel/HanselInterpreter.java
Index: HanselInterpreter.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/HanselInterpreter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HanselInterpreter.java 22 Dec 2004 18:27:32 -0000 1.2
+++ HanselInterpreter.java 28 Dec 2004 17:20:36 -0000 1.3
@@ -40,6 +40,7 @@
public HanselInterpreter(List instructions, List localVariables) {
this.instructions = instructions;
this.localVariables = localVariables;
+ //System.out.println("LocalVars: " + localVariables);
}
public Value binaryOperation(AbstractInsnNode insn, Value value1, Value value2) {
@@ -127,9 +128,16 @@
while (it.hasNext()) {
LocalVariableNode lvn = (LocalVariableNode) it.next();
- if ((lvn.index == index) &&
+ /*System.out.println("lvn: " + lvn);
+ System.out.println("lvn.index: " + lvn.index);
+ System.out.println("indec: " + index);
+ System.out.println("indec: " + instructions.size());
+ System.out.println("indec: " + instructions.indexOf(lvn.end));
+ */
+ // TODO: FixMe....
+ if ((lvn.index == index) /*&&
(insnIndex > instructions.indexOf(lvn.start)) &&
- (insnIndex < instructions.indexOf(lvn.end))) {
+ (insnIndex < instructions.indexOf(lvn.end))*/) {
//System.err.println("Returning local var for: " + index + " " + lvn.desc + " " + getSize(lvn.desc));
return new HanselValue(lvn.name, isBool(lvn.desc), getSize(lvn.desc));
}
1.6 +2 -1 hansel/src/org/hansel/stack/ArgsEntry.java
Index: ArgsEntry.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/ArgsEntry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ArgsEntry.java 5 Sep 2004 13:52:53 -0000 1.5
+++ ArgsEntry.java 28 Dec 2004 17:20:37 -0000 1.6
@@ -12,7 +12,8 @@
List args,
Type[] argTypes,
Type type) {
- super(name, type);
+ // TODO: Checkparameters.
+ super(name, false, 1);
this.args = args;
this.argTypes = argTypes;
}
1.1 hansel/.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hansel</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
1.6 +0 -2 hansel/src/org/hanseltest/TestBug753855.java
Index: TestBug753855.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestBug753855.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestBug753855.java 5 Sep 2004 13:52:55 -0000 1.5
+++ TestBug753855.java 28 Dec 2004 17:20:38 -0000 1.6
@@ -4,8 +4,6 @@
import junit.framework.TestCase;
-
-import org.hansel.Instrumenter;
import org.hansel.ProbeTable;
/**
|
|
From: Niklas M. <ji...@us...> - 2004-12-22 18:31:43
|
jiriki 04/12/22 10:31:36 Added: lib asm-attrs.jar Log: Fixed some bugs (hansel2) Revision Changes Path 1.1 hansel/lib/asm-attrs.jar <<Binary file>> |
|
From: <har...@gm...> - 2004-12-17 23:05:53
|
Hi all - I am not at all happy with the various CoverageDecorator constructors (which is the main reason why I myself don't use Hansel really!). Currently, we have the following state of affairs: There are parameters for * A test class * Classes to be covered - for real-world examples, this requires long long lists of classes to be maintained; and anonymous classes can be handled only very awkwardly (using Class.forName()) * Prefixes (Strings) to be excluded * a flag indicating "use default ignores" - can be set to false * ProbeFilters to exclude some probes dynamically. Many of these are optional. For technical reasons, it is not possible to set any parameters *after* creating the CoverageDecorator, hence we are going to be flooded by 2^n different constructor versions ... a nightmare, IMO. I would like to change this - and in that course break all existing hansel test suites: that's why I ask! - to: * Required: A test class * Required: A list of regular expressions or "wildcard expressions" indicating the classes to be covered * Optional: A list of regular expressions or "wildcard expressions" indicating classes not to be covered [empty by default] * Optional: An additional flag whether to use the "default ignores" should apply [true be default]. * Optional: A ProbeFilter [default null]. We would end up with theoretically 2^3=8 constructors, which I would limit to the following 4: CD(Class testClass, String[] coveredClassPatterns); CD(Class testClass, String[] coveredClassPatterns, String[] ignoredClassPatterns); CD(Class testClass, String[] coveredClassPatterns, String[] ignoredClassPatterns, boolean useDefaultIgnores); CD(Class testClass, String[] coveredClassPatterns, String[] ignoredClassPatterns, boolean useDefaultIgnores, ProbeFilter filter); --------------- First question to you all: Is this ok????????????????? --------------- Re regexp or wildcard expressions: * RegExp would mean using JDK1.4.x - easier to implement, more general, more limited in use (the commercial projects I'm working one are mostly still on JDK1.3 - thx to IBM's lagging behind), "funny semantics" if used with standard "import syntax": com.mycompany.* would also match comXmyCompany.SomeClass [note the X!]. In practice, this is not of much concern, I'd say... * Wildcard expressions (* means any char sequence, everything else is taken literally) would also work for JDK1.3, are a little bit more work for me, are - I think - general enough, match the import syntax of Java. --------------- Second question: RegExp or wildcard expressions - which would you prefer? --------------- - I would try to implement it and get the build and test cases running again over the holidays for hansel 1.X ... Regards Harald M. Mueller |
|
From: Niklas M. <nik...@fr...> - 2004-11-26 22:35:49
|
Hi!
> I have added a little suite() logic to the CoverageDecorator (but not
> yet the Assertion...Decorator). Here is an example of what now works -
> if I have overlooked that it previously also was possible, please show
> me what I didn"t see:
No, this did not work before. But your solution has a problem, too:
It causes an endless recursion for tests that return a coverage
decorator of themselfes in the suite() method:
[junit] at org.hanselexample.ExampleTest.suite(ExampleTest.java:31)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:585)
[junit] at
org.hansel.CoverageDecorator.createInstrumentedTest(CoverageDecorator.java:146)
[junit] at
org.hansel.CoverageDecorator.internalAddTest(CoverageDecorator.java:164)
[junit] at
org.hansel.CoverageDecorator.addTestClass(CoverageDecorator.java:178)
[junit] at org.hansel.CoverageDecorator.<init>(CoverageDecorator.java:95)
[junit] at org.hansel.CoverageDecorator.<init>(CoverageDecorator.java:89)
[junit] at org.hanselexample.ExampleTest.suite(ExampleTest.java:31)
I think a possible fix for this is, to only use the suite() method, when
a test is added using the addTestSuite() method
(see attached version of coverage decorator).
Does this work for you, if you change your example to:
[...]
public static Test suite() {
CoverageDecorator cd = new CoverageDecorator(AllTests.class,
new String[] {"com.companyx.ormapping." });
cd.addTestSuite(AllTests.class);
return cd;
}
[...]
?
regards,
Niklas
|
|
From: Niklas M. <nik...@fr...> - 2004-11-26 21:41:51
|
Hi!
Sorry I didn't reply earlier, but I had much work to do (and on top of
that got unsubscribed from the mailing-list, because my email didn't
work for a few days).
Nice to see, you are almost finished.
>First of all, I pray to god (whichever one you prefer) that I did no
>mess up the CVS repository: My intention was to change things ONLY on
> the rel1 branch, i.e. the version which is compatible with JDK1.4 and
> which uses BCEL.
Everything still seems to work. Also the whole point of using cvs is to
be able to revert changes ;)
> 1. Probe Categories (as described in June last year - Feature Request
> 755788: Add "probe categories").
I'm going to try this :)
> 4. A fix for Bug 1033460: Inner-inner classes not covered
See below: Maybe this is the reason for the endless loop I get when
running the tests?
> 5. Cleaned up all imports and unused variables (no warnings under
> Eclipse standard preferences).
Using an IDE instead of emacs has advantages...
> I. There is still one test with a ! operator failing. I do not yet
> understand the "reverse engineering of expressions" well,
The decompilation/reverse engineering of expression is more or less a hack.
I haven't yet found a way to do this properly. I'll take a look into this.
> J. The build structure does not work with Eclipse (at least 2.x; and as
> I understand Eclipse): I have to make hansel/src a "source path" in
> Eclipse; but if I want to see build.xml, I also have to make hansel
> itself a source path in the Eclipse project. However, this overlap of
> the two trees totally confuses Eclipse. In industry projects where I use
> Eclipse, we have build *parallel* to src - I think hansel should be
> reorganized like this (or someone explains me how to do it in Eclipse).
Actually I'm not sure I understand what you are talking about?
What does "parallel" mean?
> K. I did not succeed in building hansel with the supplied ant builds.
> One error I do not understand at all is a "non-caught
> ClassNotFoundException when calling getSuperClass()" in Instrumenter -
> but this method does not throw that Exception according to the
> Javadoc!?!?
Can you send me the stack trace and the exact way this happens?
regards,
Niklas
P.S.: I just tried to run the tests on the rel1 branch, but there seems
to be an endless loop instrumenting the example file:
ant test
Buildfile: build.xml
init:
test:
compile:
[copy] Copying 2 files to /home/java/hansel1/hansel/build/classes
test:
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example
[junit] [Hansel] INFO: - you can switch off the "Instrumenting ..."
messages with -Dorg.hansel.silent
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example$1
[junit] [Hansel] INFO: Instrumenting
org.hanselexample.Example$ExampleInner
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example$1
[junit] [Hansel] INFO: Instrumenting
org.hanselexample.Example$ExampleInner
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example$1
[junit] [Hansel] INFO: Instrumenting
org.hanselexample.Example$ExampleInner
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example
[junit] [Hansel] INFO: Instrumenting org.hanselexample.Example$1
[junit] [Hansel] INFO: Instrumenting
org.hanselexample.Example$ExampleInner
[...]
Do you have an idea why this happens?
|
|
From: <hmm...@us...> - 2004-10-30 16:56:39
|
hmmueller 04/10/30 09:56:33
Modified: src/org/hanseltest Tag: rel1 TestBug582985.java
Log:
added toString() accessing name to suppress Eclipse 3.x warnings
Revision Changes Path
No revision
No revision
1.3.4.2 +8 -0 hansel/src/org/hanseltest/TestBug582985.java
Index: TestBug582985.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestBug582985.java,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -u -r1.3.4.1 -r1.3.4.2
--- TestBug582985.java 9 Oct 2004 20:39:34 -0000 1.3.4.1
+++ TestBug582985.java 30 Oct 2004 16:56:32 -0000 1.3.4.2
@@ -48,6 +48,10 @@
public CoverMe(String aName) {
name = aName;
}
+
+ public String toString() {
+ return name;
+ }
}
/**
@@ -84,6 +88,10 @@
public CoverMe2(String aName) {
name = aName;
}
+
+ public String toString() {
+ return name;
+ }
}
/**
|
|
From: <hmm...@us...> - 2004-10-30 16:55:58
|
hmmueller 04/10/30 09:55:51
Modified: src/org/hanseltest/probes Tag: rel1 ACmpBranchProbeTest.java
Log:
removed unnecessary field methods
Revision Changes Path
No revision
No revision
1.2.2.2 +0 -3 hansel/src/org/hanseltest/probes/ACmpBranchProbeTest.java
Index: ACmpBranchProbeTest.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/probes/ACmpBranchProbeTest.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- ACmpBranchProbeTest.java 9 Oct 2004 20:44:33 -0000 1.2.2.1
+++ ACmpBranchProbeTest.java 30 Oct 2004 16:55:51 -0000 1.2.2.2
@@ -4,7 +4,6 @@
import junit.framework.TestCase;
import org.apache.bcel.generic.Type;
-import org.apache.bcel.classfile.Method;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionHandle;
@@ -31,13 +30,11 @@
public class ACmpBranchProbeTest extends TestCase {
private ClassLoaderRepository repository;
private JavaClass javaClass;
- private Method[] methods;
private ConstantPoolGen cpg;
public void setUp() throws Exception {
repository = new ClassLoaderRepository(getClass().getClassLoader());
javaClass = repository.loadClass(ACmpBranchProbeTest.class.getName());
- methods = javaClass.getMethods();
cpg = new ConstantPoolGen(javaClass.getConstantPool());
}
|
|
From: <hmm...@us...> - 2004-10-30 16:55:43
|
hmmueller 04/10/30 09:55:29
Modified: src/org/hanseltest Tag: rel1 CoverSwitchBug.java
Log:
added get() for anInt to suppress Eclipse 3.x warnings
Revision Changes Path
No revision
No revision
1.1.2.1 +4 -0 hansel/src/org/hanseltest/CoverSwitchBug.java
Index: CoverSwitchBug.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/CoverSwitchBug.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- CoverSwitchBug.java 18 Oct 2003 21:14:58 -0000 1.1
+++ CoverSwitchBug.java 30 Oct 2004 16:55:28 -0000 1.1.2.1
@@ -16,6 +16,10 @@
break;
}
}
+
+ public int useAnInt() {
+ return anInt;
+ }
}
|
|
From: <hmm...@us...> - 2004-10-30 16:55:14
|
hmmueller 04/10/30 09:55:02
Modified: src/org/hanseltest Tag: rel1 TestStackBugs.java
Log:
added get() for boolVar to suppress Eclipse 3.x warnings
Revision Changes Path
No revision
No revision
1.5.2.1 +4 -1 hansel/src/org/hanseltest/TestStackBugs.java
Index: TestStackBugs.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hanseltest/TestStackBugs.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- TestStackBugs.java 17 Jul 2003 20:30:15 -0000 1.5
+++ TestStackBugs.java 30 Oct 2004 16:55:02 -0000 1.5.2.1
@@ -191,6 +191,9 @@
public void rfe744114a() {
boolVar = testMethod(false);
}
+
+ public boolean get() {
+ return boolVar;
+ }
}
-
}
|
|
From: <hmm...@us...> - 2004-10-30 16:53:37
|
hmmueller 04/10/30 09:53:19
Modified: src/org/hansel/stack Tag: rel1 ComplexOr.java
Log:
commented unnecessary field stack
Revision Changes Path
No revision
No revision
1.1.2.2 +3 -3 hansel/src/org/hansel/stack/ComplexOr.java
Index: ComplexOr.java
===================================================================
RCS file: /cvsroot/hansel/hansel/src/org/hansel/stack/ComplexOr.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ComplexOr.java 9 Oct 2004 20:29:09 -0000 1.1.2.1
+++ ComplexOr.java 30 Oct 2004 16:53:19 -0000 1.1.2.2
@@ -9,12 +9,12 @@
import org.apache.bcel.generic.InstructionTargeter;
import org.apache.bcel.generic.Type;
-import org.hansel.stack.SymbolicStack;
+//import org.hansel.stack.SymbolicStack;
public class ComplexOr {
private InstructionHandle trueTarget;
private Hashtable stackMap;
- private SymbolicStack stack;
+ //private SymbolicStack stack;
private InstructionList il;
public ComplexOr(InstructionHandle trueTarget,
@@ -22,7 +22,7 @@
InstructionList il) {
this.trueTarget = trueTarget;
this.stackMap = stackMap;
- this.stack = (SymbolicStack) stackMap.get(trueTarget);
+ //this.stack = (SymbolicStack) stackMap.get(trueTarget);
this.il = il;
}
|