This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 82153 - Code completion/fix imports not working properly
Summary: Code completion/fix imports not working properly
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: PC Linux
: P1 blocker (vote)
Assignee: Daniel Prusa
URL:
Keywords: REGRESSION
: 82843 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-08 12:58 UTC by kvgeorge1
Modified: 2007-09-26 09:14 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
messages.log (112.17 KB, text/plain)
2006-08-18 09:19 UTC, Jiri Prox
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kvgeorge1 2006-08-08 12:58:36 UTC
I have a fairly large application that I moved over from NB 5.0 that consists of
4  projects and 2 jar libraries.  What is happening is 2 things, though they may
be related...

If I load a simple class with getters/setters for primatives and classes out of
the java.lang and java.util packages, doing a FIX-IMPORTS (ALT-SHFT-F), the
primatives are recognized, but the classes are not, even though they are shown
in the imports section of the code.  This gets worse if I am extending a class
from one of the other projects.  Then things like java.lang.Object are not
recognized, along with, any classes from the libraries, yet they are defined in
the project.

Secondly, if the IDE start to have the above problem, and I am using something
like java.util.List in the class that is clearly defined in the imports section,
if I do an ALT-SHFT-F, java.awt.List is added to the imports section right above
the java.util.List import.  I then have to go back and remove the erroneous
java.awt.List definition for the class to compile correctly.

Again, this is a fairly LARGE application and our legal department would not
allow me to post any intellectual property to this site for showing examples.
Comment 1 Jiri Prox 2006-08-08 13:08:03 UTC
This issue was discused on nbusers:

http://www.netbeans.org/servlets/BrowseList?list=nbusers&by=thread&from=535470
Comment 2 Jan Becicka 2006-08-08 16:19:46 UTC
It looks like your project is not correctly configured. Please check Tools |
Java Platform Manager configuration and project properties.
Let us know, if you find something... Thanks.
Comment 3 Jan Becicka 2006-08-09 07:14:41 UTC
kvgeorge1 wrote:
Ok, after deleting my userdir and re-creating it, it is still not working. 
Also, once the failure occurs, it seems that if a class that is being used is
from an external library, though it is in the classpath, and though it is
defined in the project properties, the IDE does not recognize the classes in it
for IMPORT FIX.  However, compilation occurs without error.  Furthermore, I
noticed that once this occurs, even things like java.lang.Object are not even
recognized.

As if this wasn't enough, if I attempt to do a fix imports, and I am using a
java.util.List object, and it is defined specifically as an import, the IDE
insists on adding a java.awt.List object to the imports area of the code.  For
example:

Before FIXING....

import java.util.List

public class Test {
    List list = new List();
}

After FIXING....

import java.awt.List
import java.util.List

public class Test {
     List list = new List();
}

This is a serious issue.
Comment 4 Jan Becicka 2006-08-09 07:17:03 UTC
And what kind of project do you use? j2se project? project with existing
sources? Project with existing ant script? Thanks
Comment 5 kvgeorge1 2006-08-09 12:02:33 UTC
I use j2se and web applications (Struts).  All of them seem to have the same
issues.  Is there a major change to the private project directories from NB 5.0
-> NB 5.5?
Comment 6 kvgeorge1 2006-08-09 16:14:09 UTC
It definately looks as if any external reference to a class contained in a .jar
file is not being refereneced by the IDE for purposes of fixing imports.  I
created a new class library project.  Checked-out the source from my SVN
repository, added the external library, set the platform to the version of Java
that we are using (jdk 1.4.2).

When I do a fix-imports on a Class that I created extending a Class in the
external .jar file (3rd-party library from HP), the Classes that are being used
are not recognized by the IDE during the fix-imports function.  However, the
Class compiles without errors.

I do not experience this issue if I follow the same steps using NB 5.0, so this
is definately isolated to NB 5.5 beta 2.
Comment 7 kvgeorge1 2006-08-09 16:19:56 UTC
Maybe this will help....here is a Class that I created that I can share with you:

/*
 * TandemDate.java
 *
 * Created on February 17, 2006, 4:46 PM
 */

package com.myco.utils;

import java.util.Date;

/**
 * This class extends <code>java.util.Date</code> with 2 additional
 * methods that will either accept a Date object and return the julian
 * value using the offset for the Tandem server, or accept the julian
 * value and return a new Date object.
 *
 * @author Ken George
 * @see java.util.Date
 */
public class TandemDate extends Date {
    // JulianTS epoch for Tandem
    private static final long julianEpoch = 210866760000000L; // Jan. 1, 1970
00:00:00 GMT.
    
    /**
     * Returns the date in julianTS
     *
     * @param date
     *            The date to convert
     *
     * @return long
     */
    public static long convertToJulianTS(Date date) {
        return ((date.getTime() + julianEpoch) * 1000);
    }
    
    /**
     * Returns the date in Date format
     *
     * @param julianTS
     *            The timestamp to convert
     *
     * @return Date
     */
    public static Date convertToGregorianTS(long julianTS) {
        return new Date((julianTS / 1000) - julianEpoch);
    }    
}


When I do a fix-imports (ALT-SHFT-F), I get the followng error:

No imports found for the following types:
- Date
Comment 8 Jan Becicka 2006-08-17 22:32:46 UTC
jiriprox, can you reproduce that?
Thanks.
Comment 9 kvgeorge1 2006-08-17 22:45:47 UTC
Yes, easily.  I have another thread running on the nbusers list discussing the
same issue recently (today actually), that is about the same information.  It
appears that any class in an external jar file is being ignored, along with, any
class that is not in the immediate package (i.e. java.util.Date, etc.).
Comment 10 Jan Becicka 2006-08-18 06:25:15 UTC
It looks like a regression. I guess, that this regression could not be
introduced by javacore module, since there is only few commits in this module
since 5.0.
Tomasi, I see similar issue in classpath module (issue 82883) and there is also
issue 75469, which might be related.
Comment 11 Jiri Prox 2006-08-18 09:18:03 UTC
Issue 82843 and issue 82513 looks similar as well.  
I can not reproduced it on my machine. But Petr Blaha did it and provided
messages.log.
Comment 12 Jiri Prox 2006-08-18 09:19:05 UTC
Created attachment 33054 [details]
messages.log
Comment 13 Tomas Zezula 2006-08-18 09:37:48 UTC
See: http://www.netbeans.org/issues/show_bug.cgi?id=82843 and there is lots of
exceptions coming from MDR.
Comment 14 Jan Becicka 2006-08-21 10:30:34 UTC
*** Issue 82843 has been marked as a duplicate of this issue. ***
Comment 15 Jan Becicka 2006-08-21 12:28:02 UTC
Steps to reproduce:
1. Open fresh IDE
2. Create new project
3. Wait scan finished
4. Kill the IDE (don't shut down, but kill)
5. Restart ide -> CC is broken

Probably introduced by issue 77982 or related fixes.
Comment 16 Jan Becicka 2006-08-21 13:40:52 UTC
Dan is working on fix.
Comment 17 Daniel Prusa 2006-08-22 15:05:09 UTC
Fixed in trunk.

/cvs/java/javacore/src/org/netbeans/modules/javacore/scanning/ClassUpdater.java
new revision: 1.19; previous revision: 1.18
Comment 18 Daniel Prusa 2006-08-23 13:22:12 UTC
Fixed merged into release55 branch.

/cvs/java/javacore/src/org/netbeans/modules/javacore/scanning/ClassUpdater.java
new revision: 1.11.34.7; previous revision: 1.11.34.6
Comment 19 kvgeorge1 2006-08-23 21:51:29 UTC
I just downloaded the latest daily build (200608230000) and the problem still
exists.  Things like java.util.List are not recognized, but are replaced with
java.awt.List when doing an ALT-SHFT-F (Fix Imports).
Comment 20 Daniel Prusa 2006-08-23 23:22:08 UTC
The fix was merged into release55 branch on August 23, it is not included in
build 200608230000, it will be in 200608240000.
Comment 21 Jiri Prox 2006-08-31 10:31:07 UTC
Reporter, can you verify the fix, please?
Comment 22 kvgeorge1 2006-08-31 15:25:25 UTC
My apologies.  This is indeed fixed.
Comment 23 Quality Engineering 2007-09-20 10:56:35 UTC
Reorganization of java component