I can't get weaver to pass its unit tests

249 views
Skip to first unread message

stanleysf

unread,
Apr 11, 2010, 9:55:00 PM4/11/10
to Thread Weaver
I would really like to use thread-weaver for testing user vs. batch
concurrency in my application.
Unfortunately, I can't get the unit tests to pass.
I get either "array index of bounds" or "bad byte code" in javassist

I am using weaver-0.1 with jdk 1.6.0_18 and these versions of the
dependent libraries.
I have tried both windows and linux and see the same failures in both
places.

javassist-jar=/d1/oss-libs/javassist-3.11.0/javassist.jar
objenesis-jar=/d1/oss-libs/objenesis-1.2/objenesis-1.2.jar
cglib-jar=/d1/oss-libs/cglib/cglib-2.2.jar
easymock-jar=/d1/oss-libs/easymock-2.5.2/easymock-2.5.2.jar
easymockclassextension-jar=/d1/oss-libs/easymockclassextension-2.5.2/
easymockclassextension-2.5.2.jar
junit-jar=/d1/oss-libs/junit/junit-4.8.1.jar
asm-jar=/d0/pdh/head/dev/3rdparty/repo/asm/jars/asm-3.0.jar


First error: running tests from command line:
[junit] Testsuite:
com.google.testing.threadtester.AnnotatedTestRunnerTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.164
sec
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.164
sec
[junit]
[junit] Testcase: testThreadedTests took 0.149 sec
[junit] Caused an ERROR
[junit] java.lang.reflect.InvocationTargetException
[junit] java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
[junit] at
com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:
71)
[junit] at
com.google.testing.threadtester.BaseThreadedTestRunner.runTests(BaseThreadedTestRunner.java:
179)
[junit] at
com.google.testing.threadtester.BaseThreadedTestRunner.runTests(BaseThreadedTestRunner.java:
143)
[junit] at
com.google.testing.threadtester.AnnotatedTestRunnerTest.testThreadedTests(AnnotatedTestRunnerTest.java:
42)
[junit] Caused by: java.lang.reflect.InvocationTargetException
[junit] at
com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:
68)
[junit] Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
[junit] at
javassist.bytecode.stackmap.Tracer.checkParamTypes(Tracer.java:908)
[junit] at
javassist.bytecode.stackmap.Tracer.doInvokeIntfMethod(Tracer.java:826)
[junit] at
javassist.bytecode.stackmap.Tracer.doOpcode148_201(Tracer.java:619)
[junit] at
javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:101)
[junit] at
javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:161)
[junit] at
javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
[junit] at
javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:120)
[junit] at
javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
[junit] at
javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
[junit] at
javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
[junit] at javassist.CtBehavior.insertAt(CtBehavior.java:1135)
[junit] at javassist.CtBehavior.insertAt(CtBehavior.java:1069)
[junit] at
com.google.testing.threadtester.TestInstrumenter.processMethod(TestInstrumenter.java:
840)
[junit] at
com.google.testing.threadtester.TestInstrumenter.processClass(TestInstrumenter.java:
477)
[junit] at
com.google.testing.threadtester.TestInstrumenter.instrument(TestInstrumenter.java:
444)
[junit] at
com.google.testing.instrumentation.InstrumentedClassLoader.findClass(InstrumentedClassLoader.java:
137)
[junit] at
com.google.testing.instrumentation.InstrumentedClassLoader.loadClass(InstrumentedClassLoader.java:
113)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:169)
[junit] at
com.google.testing.threadtester.AnnotatedTestWrapper.runTests(AnnotatedTestWrapper.java:
231)
[junit]

BUILD FAILED


Second error, running some other tests in eclipse:

Invoking "before" method InterleavedRunnerTest.resetSequence
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:
68)
at
com.google.testing.threadtester.ThreadedTestWrapper.runTests(ThreadedTestWrapper.java:
71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.google.testing.threadtester.MethodCaller.invoke(MethodCaller.java:
68)
at
com.google.testing.threadtester.BaseThreadedTestRunner.runTests(BaseThreadedTestRunner.java:
179)
at
com.google.testing.threadtester.BaseThreadedTestRunner.runTests(BaseThreadedTestRunner.java:
143)
at
com.google.testing.threadtester.InterleavedRunnerTest.testThreadedTests(InterleavedRunnerTest.java:
37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:
83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
45)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)
Caused by: java.lang.RuntimeException: Cannot instrument class:
com.google.testing.threadtester.SimpleClass5
at
com.google.testing.threadtester.TestInstrumenter.instrument(TestInstrumenter.java:
446)
at
com.google.testing.instrumentation.InstrumentedClassLoader.findClass(InstrumentedClassLoader.java:
138)
at
com.google.testing.instrumentation.InstrumentedClassLoader.loadClass(InstrumentedClassLoader.java:
113)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at
com.google.testing.threadtester.InterleavedRunnerTest.resetSequence(InterleavedRunnerTest.java:
70)
... 33 more
Caused by: javassist.CannotCompileException: by
javassist.bytecode.BadBytecode: conflict: int and
java.lang.reflect.Method
at javassist.CtBehavior.insertAt(CtBehavior.java:1145)
at javassist.CtBehavior.insertAt(CtBehavior.java:1069)
at
com.google.testing.threadtester.TestInstrumenter.processMethod(TestInstrumenter.java:
840)
at
com.google.testing.threadtester.TestInstrumenter.processClass(TestInstrumenter.java:
477)
at
com.google.testing.threadtester.TestInstrumenter.instrument(TestInstrumenter.java:
444)
... 37 more
Caused by: javassist.bytecode.BadBytecode: conflict: int and
java.lang.reflect.Method
at javassist.bytecode.stackmap.TypeData
$BasicType.setType(TypeData.java:116)
at javassist.bytecode.stackmap.TypeData.setType(TypeData.java:46)
at javassist.bytecode.stackmap.Tracer.checkParamTypes(Tracer.java:
908)
at javassist.bytecode.stackmap.Tracer.doInvokeIntfMethod(Tracer.java:
826)
at javassist.bytecode.stackmap.Tracer.doOpcode148_201(Tracer.java:
619)
at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:101)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:161)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:120)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:
389)
at javassist.CtBehavior.insertAt(CtBehavior.java:1135)
... 41 more

Alasdair Mackintosh

unread,
Apr 12, 2010, 1:41:39 PM4/12/10
to thread...@googlegroups.com
On Sun, Apr 11, 2010 at 6:55 PM, stanleysf <sknu...@purisma.com> wrote:
> I would really like to use thread-weaver for testing user vs. batch
> concurrency in my application.
> Unfortunately, I can't get the unit tests to pass.
> I get either "array index of bounds" or "bad byte code" in javassist

Hi Stanley,

I'll take a look. Might be a day or so before I can get back to you,
as I'm a bit busy at the moment.

Alasdair

Alasdair Mackintosh

unread,
Apr 12, 2010, 3:14:09 PM4/12/10
to thread...@googlegroups.com

This is my setup, and it build and tests OK. I'll try with your
version of Javassist - maybe something's changed?

javassist-jar=/home/build/google3/third_party/java/javassist/v3_8_1/javassist.jar
objenesis-jar=.../objenesis/v1_0/objenesis-1.0.jar
cglib-jar=.../cglib/v2_2/cglib-2.2.jar
easymock-jar=.../easymock/easymock2.4/easymock.jar
easymockclassextension-jar=.../easymockclassextension2.4/easymockclassextension.jar
junit-jar=.../junit/v4_5/junit.jar
asm-jar=.../asm/asm-3.0.jar

Alasdair Mackintosh

unread,
Apr 12, 2010, 3:22:10 PM4/12/10
to thread...@googlegroups.com
On Mon, Apr 12, 2010 at 12:14 PM, Alasdair Mackintosh

<alasdair....@gmail.com> wrote:
> On Mon, Apr 12, 2010 at 10:41 AM, Alasdair Mackintosh
> <alasdair....@gmail.com> wrote:
>> On Sun, Apr 11, 2010 at 6:55 PM, stanleysf <sknu...@purisma.com> wrote:
>>> I would really like to use thread-weaver for testing user vs. batch
>>> concurrency in my application.
>>> Unfortunately, I can't get the unit tests to pass.
>>> I get either "array index of bounds" or "bad byte code" in javassist
>>
>> Hi Stanley,
>>
>> I'll take a look. Might be a day or so before I can get back to you,
>> as I'm a bit busy at the moment.
>>
>> Alasdair
>>
>
> This is my setup, and it build and tests OK. I'll try with your
> version of Javassist - maybe something's changed?
>
> javassist-jar=/home/build/google3/third_party/java/javassist/v3_8_1/javassist.jar

Yes, something has changed. It builds fine with javassist 3.8.1, but
not with version 3.11.

Sigh.

I'll see if I can work out what's going on.

Knutson, Stanley

unread,
Apr 13, 2010, 9:24:48 PM4/13/10
to thread...@googlegroups.com
Thanks for looking at this when you have time. It is not urgent -- I
just wanted to see if we can use this for some repeatable testing of
multi-user issues that have been reported.

Hi Stanley,

Alasdair


--
To unsubscribe, reply using "remove me" as the subject.

Alasdair Mackintosh

unread,
Apr 15, 2010, 6:11:26 PM4/15/10
to thread...@googlegroups.com, sknu...@purisma.com
Hi Stanley,

It's definitely something to do with the version of javassist that
you're using. Is there any way for you to use
v3.8.1, at least until I've had a chance to look into this in more detail?

I'm very busy at work this week, and I'll be away next week, so I'm
not going to have time to dig deeper into this in the immediate
future.

Knutson, Stanley

unread,
Apr 15, 2010, 6:25:04 PM4/15/10
to Alasdair Mackintosh, thread...@googlegroups.com
I certainly can use the older version for now. I won't really be working on this again for a few weeks.

Alasdair Mackintosh

unread,
Jun 11, 2010, 8:25:19 PM6/11/10
to thread...@googlegroups.com, sknu...@purisma.com
Hi Stanley,

I've been digging into this, and it looks like a bug in Javassist. (It
seems to be getting the offsets wrong when it inserts a new fragment
of bytecode at the index where a goto opcode is defined.)

I'm doing a bit more testing on this, and if confirmed I will send a
patch to the Javassist folks.

Alasdair

Knutson, Stanley

unread,
Jun 11, 2010, 10:00:44 PM6/11/10
to Alasdair Mackintosh, thread...@googlegroups.com
Thanks for digging into it. The concept of threadweaver will be great if it works.

Alasdair Mackintosh

unread,
Jun 12, 2010, 4:25:19 PM6/12/10
to Knutson, Stanley, thread...@googlegroups.com
On Fri, Jun 11, 2010 at 7:00 PM, Knutson, Stanley <sknu...@purisma.com> wrote:
> Thanks for digging into it.   The concept of threadweaver will be great if it works.

Well, it should work fine with earlier versions of Javassist ;-)

Unfortunately the current version of Javassist has a bug that
ThreadWeaver is triggering. The bug only manifests itself when
Javassist tries to insert new bytecode at the position occupied by a
GOTO or similar opcode. If you insert before or after this poit it's
fine. Because Threadweaver inserts lots of small additional method
calls into the classes being tested, it's very likely that it will
trigger this bug. Unfortunately, there's no real workaround with the
current version of Javassist, as it's not possible to know in advance
which particular insertion will trigger the problem.

I've posted a thread on this at the Javassist discussion forum. See
http://community.jboss.org/thread/153079?tstart=0

Reply all
Reply to author
Forward
0 new messages