Community
Participate
Working Groups
Build ID: I20080516-1333 Steps To Reproduce: public final Object valueOf(Record record) { return ((FastMap.Entry<Object, Object>) record).getKey(); } public final void delete(Record record) { remove(((FastMap.Entry<Object, Object>) record).getKey()); } More information: Internal compiler error java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.CastExpression.checkUnsafeCast(CastExpression.java:335) at org.eclipse.jdt.internal.compiler.ast.Expression.checkCastTypesCompatibility(Expression.java:416) at org.eclipse.jdt.internal.compiler.ast.CastExpression.resolveType(CastExpression.java:495) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:344) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.resolve(ReturnStatement.java:220) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclara tion.java:444) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:191) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java: 403) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1096) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1184) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java: 535) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:743) at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137) at java.lang.Thread.run(Thread.java:619)
We're missing some context to reproduce. Can you please provide the types Record and FastMap?
@Override public synchronized boolean remove(Object key) { _cache.remove(key); _mruList.remove(key); return _map.remove(key) == key; } private FastMap<K,CacheNode> _cache = new FastMap<K,CacheNode>().setKeyComparator(FastComparator.DIRECT); private FastMap<K,V> _map; private FastList<K> _mruList = new FastList<K>();
Please provide a self-contained and complete testcase, e.g. import java.util.*; public class X { public final Object valueOf(Record record) { return ((FastMap.Entry<Object, Object>) record).getKey(); } public final void delete(Record record) { remove(((FastMap.Entry<Object, Object>) record).getKey()); } public synchronized boolean remove(Object key) { return false; } } class Record {} abstract class FastMap implements Map { } The program above does NOT reproduce any problem.
The trace indicates a bound parameterized type for which arguments would be null... this shouldn't occur ever.
Tadas - can you pls provide a self-contained and complete testcase ?
The following java code below doesn't compile under Eclipse 3.4RC2 build I20080523-0100 due to a NullPointerException in CastExpression.checkUnsafeCase:335. Note that line#382 of Expression.java explicitly passes null as the match argument to the method checkUnsafeCase, which is subsequently dereferenced, resulting in a NullPointerException. Hope this helps. - Andy public class Bug233800<T> { public void doesNotCompile(SomeInterface i) { T t = ((SomeDerivedInterface<T>)i).getItem(); } static interface SomeInterface { } static interface SomeDerivedInterface<T> extends SomeInterface { T getItem(); } }
Excellent ! Thanks
Added GenericTypeTest#test1335-1337. This is a regression from 3.4m7 and 3.3.2 (introduced in 3.4rc1).
Created attachment 102193 [details] Proposed patch Missing trivial null check. Some parameterized type may have null argument, denoting non generic members of parameterized types. One thing to ensure is that an unchecked warning is emitted.
Regression came from fix for bug 228291 missing one null check. Also need to backport this fix to 3.3.x maintenance, where bug 228291 was already backported (with this NPE weakness).
Patch looks good: +1 for RC3
+1
Released for 3.4RC3. Fixed
Released to 3.3.x maintenance.
Verified for 3.4RC4 using build I20080530-0100