Thanks for the reply, but it still doesn't make sense to me. If you look closely to the example there is a method accessInstanceField() which should be forwarded to the concrete instance. The actually problem I have is similar to the one described by the example.
Here is the real stack trace and code snippet:
Code:
Thread [main] (Suspended (breakpoint at line 126 in WorkLog))
TechnicalContractWorkLog$$EnhancerByCGLIB$$cf97265e(WorkLog<T,WL,VS,PS>).isValidFor(ITwoDimensionalValidity) line: 126
TechnicalContractValidState(ObjectState<RHO,WL>).workLogValidOn(ITwoDimensionalValidity) line: 203
TechnicalContractValidState(ObjectState<RHO,WL>).currentReadWorkLog() line: 81
TechnicalContract(HistorizedObject<VT,WLT>).currentReadVersion() line: 131
TechnicalContract.getSomeValue() line: 48
TwoLifeCyclesTest.changeNonTechnicalContract(Long, TwoDimensionalValidity, long) line: 49
TwoLifeCyclesTest.testAcceptance() line: 69
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
TwoLifeCyclesTest(TestCase).runTest() line: 154
TwoLifeCyclesTest(TestCase).runBare() line: 127
TwoLifeCyclesTest(ConditionalTestCase).runBare() line: 69
TwoLifeCyclesTest(SpringAcceptanceTest).runBare() line: 109
TestResult$1.protect() line: 106
TestResult.runProtected(Test, Protectable) line: 124
TestResult.run(TestCase) line: 109
TwoLifeCyclesTest(TestCase).run(TestResult) line: 118
TestSuite.runTest(Test, TestResult) line: 208
TestSuite.run(TestResult) line: 203
JUnit3TestReference.run(TestExecution) line: 128
TestExecution.run(ITestReference[]) line: 38
RemoteTestRunner.runTests(String[], String, TestExecution) line: 460
RemoteTestRunner.runTests(TestExecution) line: 673
RemoteTestRunner.run() line: 386
RemoteTestRunner.main(String[]) line: 196
Snippet that does not work:
Code:
boolean isValidFor(ITwoDimensionalValidity validity) {
// if (getTwoDimensionalValidity() != null && this instanceof HibernateProxy) {
// System.out.println("Proxy");
// assert(twoDimensionalValidity != null);
// }
return twoDimensionalValidity.isLessOrEqual(validity);
}
Snippet that does work:
Code:
boolean isValidFor(ITwoDimensionalValidity validity) {
// if (getTwoDimensionalValidity() != null && this instanceof HibernateProxy) {
// System.out.println("Proxy");
// assert(twoDimensionalValidity != null);
// }
return getTwoDimensionalValidity().isLessOrEqual(validity);
}
"Sender" of the method isValidFor() which is on another class:
Code:
WL workLogValidOn(ITwoDimensionalValidity twoDimensionalValidity) {
assert (twoDimensionalValidity != null);
WL eachWorkLog = null;
ListIterator<WL> iterator = getWorkLogs().listIterator(getWorkLogs().size());
while (iterator.hasPrevious()) {
eachWorkLog = iterator.previous();
if (eachWorkLog.isValidFor(twoDimensionalValidity)) {
return eachWorkLog;
}
}
return null;
}
The question now is when the workLogValidOn() method calls the isValidFor() which is on a proxied "WorkLog" class, shouldn't the isValidFor() method be forwarded to the concrete instance and not be executed on the proxy? In my case this is not true because the isValidFor() method throws a NullPointerException because twoDimensionalValidity field accessed in isValidFor() method is null.
Thanks.