bobobear / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

ClosureTest fails in "testAs()" with IllegalAccessException for Object.finalize during garbage-collection #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run ch.lambdja.ClosureTest
2.  testAs fails
3.

What is the expected output? What do you see instead?
should run. I'm seeing:

ch.lambdaj.function.closure.WrongClosureInvocationException: Error invoking
protected void java.lang.Object.finalize() throws java.lang.Throwable on 12
    at
ch.lambdaj.function.closure.AbstractClosure.closeOne(AbstractClosure.java:51)
    at
ch.lambdaj.function.closure.AbstractClosure$1.invoke(AbstractClosure.java:164)
    at $Proxy5.nonCommutativeDoOnInt(Unknown Source)
    at ch.lambdaj.ClosureTest.testAs(ClosureTest.java:172)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadi
e.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.
java:88)
    at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:5
1)
    at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:46)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:467)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:683)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:390)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:197)
Caused by: java.lang.IllegalAccessException: Class
ch.lambdaj.function.closure.AbstractClosure can not access a member of
class java.lang.Object with modifiers "protected"
    at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at
ch.lambdaj.function.closure.AbstractClosure.closeOne(AbstractClosure.java:49)
    ... 25 more

When running testAs in isolation, it does not fail! This looks like a
threading/gc issue as the error is when finalize should be invoked.

Original issue reported on code.google.com by sebastian.jancke@googlemail.com on 20 Jul 2009 at 4:06

GoogleCodeExporter commented 9 years ago
It is a very subtle problem. I was able to reproduce it just once and only by 
running
the test inside eclipse. Anyway I believe I fixed it on a "conceptual basis", 
but
since I am not able to reproduce it again I cannot be sure. 

Please check if it is ok for you as well, and if so close this ticket.

Original comment by mario.fu...@gmail.com on 20 Jul 2009 at 4:51

GoogleCodeExporter commented 9 years ago
ok, I will check again with your changes.

The problem appeared to me in eclipse and maven. As it is because of timing and 
gc,
it doesn't matter anyway.

Original comment by sebastian.jancke@googlemail.com on 20 Jul 2009 at 10:14

GoogleCodeExporter commented 9 years ago
Works.

Original comment by sebastian.jancke@googlemail.com on 21 Jul 2009 at 11:07