newbie: "reference to object is ambiguous" error

L

LaCo

Hi!
I have this error compilling my application that I have created with
netbeans:

JFrameSample.java:164: reference to Object is ambiguous, both class
org.omg.CORBA.Object in org.omg.CORBA and class java.lang.Object
in java.lang match
new Object [][] {
^
1 error

How can I fix it? I need both: org.omg.CORBA and java.lang.*
any ideas?

Thanks!
LaCo
 
G

Guest

LaCo said:
JFrameSample.java:164: reference to Object is ambiguous, both class
org.omg.CORBA.Object in org.omg.CORBA and class java.lang.Object
in java.lang match
new Object [][] {
^
1 error

How can I fix it? I need both: org.omg.CORBA and java.lang.*
any ideas?

Rewrite your:
new Object [][]
as:
new java.lang.Object [][]

- Dario
 
C

Christophe Vanfleteren

LaCo said:
Hi!
I have this error compilling my application that I have created with
netbeans:

JFrameSample.java:164: reference to Object is ambiguous, both class
org.omg.CORBA.Object in org.omg.CORBA and class java.lang.Object
in java.lang match
new Object [][] {
^
1 error

How can I fix it? I need both: org.omg.CORBA and java.lang.*
any ideas?

You'll need to fully qualify one of the classes, and only import the other
(int this case you don't need to import java.lang.Object, since the
compiler does that for you).

....
//"normal" object
Object[] bla = Object[10];

//CORBA object:
org.omg.CORBA.Object bli = new org.omg.CORBA.Object(...);
....
 
S

Sudsy

LaCo said:
Hi!
I have this error compilling my application that I have created with
netbeans:

JFrameSample.java:164: reference to Object is ambiguous, both class
org.omg.CORBA.Object in org.omg.CORBA and class java.lang.Object
in java.lang match
new Object [][] {
^
1 error

How can I fix it? I need both: org.omg.CORBA and java.lang.*
any ideas?

This is one of those situations which perfectly illustrate why it's
not a good idea to use wild-card imports. You probably have something
like this:

import org.omg.CORBA.*;

What you SHOULD be doing (IMHO) is only importing the classes you're
actually going to use. IDEs like Eclipse will handle all of this for
you, BTW.
If you truly need both org.omg.CORBA.Object and java.lang.Object
(note that you don't have to import the java.lang classes) then all
the other responders have provided the answer: use the fully-qualified
class name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top