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 55383 - TOOLS | SYNCHRONIZE shows false-positives when using Generics
Summary: TOOLS | SYNCHRONIZE shows false-positives when using Generics
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-23 04:32 UTC by _ gtzabari
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2005-02-23 04:32:46 UTC
dev build 200502211900

When I run TOOLS | Synchronize I get a whole bunch
of methods that I am asked to add, but I know for
a fact that the superclass already implements
them. Furthermore, compiling the file works fine
so I know that "synchronize" is wrong.

I am not 100% sure what is special about these
methods that confuses the synchronize tool but
here is roughly what I am doing:

interface MyInterface <Type extends MyInterface<Type>>
{
  public void add(Type child);
}

public abstract class AbstractClass<Type extends
AbstractClass<Type>> implements MyInterface
{
  public void add(Type child)
  {
  }
}

public class ConcreteClass<Type extends
ConcreteClass<Type>> extends AbstractClass
{
}

   If you run "synchronize" on ConcreteClass, it
will suggest adding:

   public void add(Object child);

This seems to be Generics specific and has
something to do with type-erasure because if I
have methods such as:

   public void add(Set<Type> children);

it won't show up as missing on synchronize.
Comment 1 Dusan Balek 2005-02-23 09:15:50 UTC
Reassigning to java module.
Comment 2 Jan Pokorsky 2005-03-29 16:45:00 UTC
I am confused with your example a bit. Why do you introduce generics in your
code (MyInterface<Type ...> and AbstractClass<Type ...>) when you do not use them.

Declarations like this:
  abstract class AbstractClass<Type ...> implements MyInterface {}
or this:
  class ConcreteClass<Type ...> extends AbstractClass {}

simply erase generic type information of the superclass or interface. Is it
intention or the following declarations are what you want?

  abstract class AbstractClass<Type ...> implements MyInterface<Type> {}
  class ConcreteClass<Type ...> extends AbstractClass<Type> {}

Nevertheless there is definitely a bug since the Synchronize and the Override
method tools have to suggest not

  public void add(Object child)

but

  public void add(MyInterface child)

as the MyInterface is the type the compiler translates <Type extends
MyInterface<Type>> to.
Comment 3 _ gtzabari 2005-03-29 19:32:58 UTC
You are right, there was a typo in my original code. It should have read:

public abstract class AbstractClass<Type extends
AbstractClass<Type>> implements MyInterface<Type>
Comment 4 Jan Becicka 2005-08-22 15:55:48 UTC
Tools->Synchronize was removed. This bug is not valid any more.