Skip to main content

Java bug? or I guess Netbeans?

4 replies [Last post]
basixp
Offline
Joined: 2012-08-14
Points: 0

I noticed the following behavior in Java and wondered if you ever experienced it.
I had an original function as below

public Double f(String x) {...}

then changed to
public Object f(String x) {...}

seems like compilation is ignoring the fact that the new function now returns Object rather then Double. The runtime complains about a method not supported when I return a String as it looks like it still holds the original signature of which returned Double; it throws method not supported.

when I erase the statement and rewrite the code it seems to pick up proper signature.

could that be a bug in Netbeans?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sylvester.a
Offline
Joined: 2012-07-14
Points: 0

Hello basixp,
looks like you want to override that method/function

public Double f(String x) {...}

with

public Object f(String x) {...}

which is an illegal override and an illegal overload.
A legal override must not change the original signature including the arguments passing to the method/function. Also an overload to be legal, must change at least the type of argument passed into the method/function.

Hope this help,

Sylvester A.

comrad
Offline
Joined: 2004-02-16
Points: 0

I think that you simply encounter a caching problem here. Maybe your classes were already compiled and Netbeans used the compiled version as base for the extraction.

basixp
Offline
Joined: 2012-08-14
Points: 0

comrad,

yeh, almost, I just figured it out, I had some project inter dependencies where
the lib destinations where not setup correctly.

Thanks, Ben.

basixp
Offline
Joined: 2012-08-14
Points: 0

Thought about that, and did clean and build project, and it was same issue.

Thanks, Ben.