Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321829

Summary: [jdt-weaving] several NPE when using jdt-weaving without ajdt
Product: [Tools] AJDT Reporter: David Bernard <david.bernard.31+eclipsebugs>
Component: CoreAssignee: AJDT-inbox <AJDT-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: andrew.eisenberg, david.bernard.31+eclipsebugs, juanjoaguililla, maciej, miles, msa
Version: 2.1.0   
Target Milestone: 2.1.1   
Hardware: All   
OS: All   
Whiteboard:

Description David Bernard CLA 2010-08-05 03:53:54 EDT
Build Identifier: I20100608-0911

I'm working for scala-ide. The plugin use jdt-weaving but doesn't require ajdt to be installed.

Then there is no real adapter registered for every org.eclipse.contribution.jdt.itdawareness.*Aspect . So
  new RenameAdapter().getProvider() == null
  searchAdapter.getProvider() == null

But there is no null check. Then some NPE are raised like
~~~
java.lang.NullPointerException
at org.eclipse.jdt.core.search.SearchPattern.createPattern_aroundBody1$advice(SearchPattern.java:338)
at org.eclipse.jdt.core.search.SearchPattern.createPattern(SearchPattern.java:1)
at org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run(JavaSearchQuery.java:124)
at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:91)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
~~~

scala-ide related bugs :
* https://www.assembla.com/spaces/scala-ide/tickets/1000095-jdt-weaving---npe-search-on-java-project
* https://www.assembla.com/spaces/scala-ide/tickets/1000075-jdt-weaving-used-in-sdt-for-eclipse-3-6-breaks-java-refactoring

The bug is also present for eclipse 3.5.2

Reproducible: Always

Steps to Reproduce:
Install only JDT weaving without AJDT (core/ui)
try to do a search by reference in a java file.

I suppose scala-ide installation is not required to reproduce the bug.
Comment 1 Maciej Bilas CLA 2010-08-05 06:29:26 EDT
*** Bug 321844 has been marked as a duplicate of this bug. ***
Comment 2 Andrew Eisenberg CLA 2010-08-05 11:19:30 EDT
We need to be more careful about problems like these.  I'll have a look through the code today.
Comment 3 David Bernard CLA 2010-08-05 11:33:01 EDT
May be method that could return null should return some sort of Option<X> (like in scala) ;-) to informer caller.

(the scala-ide code also have lot of missing null check where integrate with eclipse/jdt API)

Thanks for your time
Comment 4 Andrew Eisenberg CLA 2010-08-05 13:04:41 EDT
In all the cases that I have explored so far, the default should be just to behave as normal.  These adapter objects exist to hook extra functionality into JDT, specifically to add intertype declaration support for things like searching, navigating, and content assist.

When the adapter does not exist (ie- null), the correct behavior is to continue on as usual, and return the JDT results only.
Comment 5 Andrew Eisenberg CLA 2010-08-05 16:54:13 EDT
I just committed a few fixes for the 3.6 branch of AJDT.  I'll be back porting the changes to the 3.5 branch soon.  I believe that all of these fixes will address the problems that you are seeing.   I'll post here when a dev build is available to try out.
Comment 6 David Bernard CLA 2010-08-05 18:07:39 EDT
Thank you
Comment 7 Andrew Eisenberg CLA 2010-08-10 23:04:49 EDT
A new build on the 3.6 stream is available and has all the fixes required.  Please let me know when you get a chance to try this out.  A build on the 3.5 stream will be available soon.

I'm closing this issue now, but feel free to re-open or raise a new issue if you see any more problems.
Comment 8 Andrew Eisenberg CLA 2010-08-10 23:05:22 EDT
fixed.
Comment 9 David Bernard CLA 2010-08-11 04:01:48 EDT
So to test it I should keep JDT weaving from
http://download.eclipse.org/tools/ajdt/36/dev/update ?
(until 2.1.1 release)
Comment 10 David Bernard CLA 2010-08-11 04:19:39 EDT
Andrew,
Do you have an ETA of 2.1.1 release ?
Comment 11 Andrew Eisenberg CLA 2010-08-11 11:10:16 EDT
(In reply to comment #9)
> So to test it I should keep JDT weaving from
> http://download.eclipse.org/tools/ajdt/36/dev/update ?
> (until 2.1.1 release)

Yes.

(In reply to comment #10)
> Andrew,
> Do you have an ETA of 2.1.1 release ?

We are scheduled to release in the middle of October.
Comment 12 Dani Megert CLA 2010-11-03 04:11:50 EDT
*** Bug 328886 has been marked as a duplicate of this bug. ***