-
1. Re: NPE in BackedAnnotatedMethod.<init>
mkouba Mar 28, 2014 5:07 AM (in response to alexander.eckert)Hi Alexander,
Java 8 support is on the agenda right now. There are already some issues reported: https://issues.jboss.org/issues/?jql=project%20%3D%20Weld%20and%20labels%20%3D%20java8. Please create a new issue for your use case (simple reproducer app or arquillian test would be helpful).
-
2. Re: NPE in BackedAnnotatedMethod.<init>
mkouba Apr 1, 2014 8:49 AM (in response to alexander.eckert)Alexander, could you also post the full stack trace?
-
3. Re: NPE in BackedAnnotatedMethod.<init>
mkouba Apr 1, 2014 9:43 AM (in response to alexander.eckert)FYI I've created https://issues.jboss.org/browse/WELD-1644.
-
4. Re: NPE in BackedAnnotatedMethod.<init>
mkouba Apr 2, 2014 8:40 AM (in response to alexander.eckert)alexander.eckert I'm not able to reproduce the problem. What version of JDK do you use? In my opinion,
Method.getGenericReturnType()
should not return null for any lambda expression. -
5. Re: NPE in BackedAnnotatedMethod.<init>
alexander.eckert Apr 8, 2014 8:21 AM (in response to mkouba)Just wanted to say that I'll create an issue. But you already did. I hope I can give more details this weekend. I had this problem when running or debugging a unit test with eclipse and testng. Have to try command line.
-
6. Re: Re: NPE in BackedAnnotatedMethod.<init>
alexander.eckert Apr 14, 2014 6:05 PM (in response to alexander.eckert)ulke I've testet it with Oracle JDK 1.8.0 64bit on (Linux) command line and I had no problems.
When running with Eclipse (Kepler SR2) I'll get this stacktrace.
java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) at com.google.common.cache.LocalCache.get(LocalCache.java:3933) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:52) at org.jboss.weld.resources.SharedObjectCache.getTypeClosureHolder(SharedObjectCache.java:80) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMember.initTypeClosure(BackedAnnotatedMember.java:29) at org.jboss.weld.annotated.slim.backed.BackedAnnotated.<init>(BackedAnnotated.java:19) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMember.<init>(BackedAnnotatedMember.java:23) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedCallable.<init>(BackedAnnotatedCallable.java:33) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod.<init>(BackedAnnotatedMethod.java:38) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod.of(BackedAnnotatedMethod.java:32) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:193) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:186) at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:154) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:186) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:186) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:66) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47) at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:83) at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:80) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) at com.google.common.cache.LocalCache.get(LocalCache.java:3934) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:52) at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:80) at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175) at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194) at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:78) at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:60) at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97) at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65) at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:744)
I'll get this when I run TestNG and Weld is used by DeltaSpike. To simplify it, I've written a small sample application.
If I call mvn compile exec:java -Dexec.mainClass="de.eckerta.weld.problem.App" from command line everything is fine.
But if I start from within eclipse I get an exception. In fact it is not important where I start the application, it is imorten where I compile it.
So it probably is a problem with the eclipse compiler.
-
weld.problem.zip 7.4 KB
-
-
7. Re: Re: NPE in BackedAnnotatedMethod.<init>
mkouba Apr 15, 2014 2:57 AM (in response to alexander.eckert)Yes, Eclipse has its own incremental Java compiler. Let me check your sample and verify the weld code...
-
8. Re: NPE in BackedAnnotatedMethod.<init>
mkouba Apr 16, 2014 7:53 AM (in response to alexander.eckert)It looks like an Eclipse compiler bug - for some reason the reflection API is not able to reconstruct the generic return type for a parameterized type.
-
9. Re: Re: NPE in BackedAnnotatedMethod.<init>
gulcher Sep 25, 2014 10:47 AM (in response to mkouba)On Wildfly 8.1.0.Final with patched Weld 2.2.5.Final...
I have the same problem with a Lambda expression like this:
int index = Collections.binarySearch(results, key, (o1, o2) -> {
Date o1ResetTime = CalendarDateUtil.resetTimeOfDate(o1.getDate(), TimeZone.getDefault());
Date o2ResetTime = CalendarDateUtil.resetTimeOfDate(o2.getDate(), TimeZone.getDefault());
int result1 = o1ResetTime.compareTo(o2ResetTime);
if (result1 == 0) {
result1 = o1.getSequence().compareTo(o2.getSequence());
}
return result1;
});
I replaced with old style:
int index = Collections.binarySearch(results, key, new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
Date o1ResetTime = CalendarDateUtil.resetTimeOfDate(o1.getDate(), TimeZone.getDefault());
Date o2ResetTime = CalendarDateUtil.resetTimeOfDate(o2.getDate(), TimeZone.getDefault());
int result = o1ResetTime.compareTo(o2ResetTime);
if (result == 0) {
result = o1.getSequence().compareTo(o2.getSequence());
}
return result;
}
});
-
10. Re: NPE in BackedAnnotatedMethod.<init>
gulcher Sep 26, 2014 3:26 AM (in response to mkouba)Hi Martin,
I think however that if the reflection API cannot construct the generic return type, WELD should throw an exception. To find the cause of the NullPointer Exception there was now no other way then to debug into WELD to find the exact cause of the Exception.
Regards,
Theo Gülcher
-
11. Re: NPE in BackedAnnotatedMethod.<init>
jharting Sep 26, 2014 5:02 AM (in response to gulcher)This is most likely a bug in the eclipse compiler. The API should normally never return null. Therefore, it is not checked by Weld. Weld cannot really check every value returned from a public API for compliance with its contract.