Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Which is wrong about Generic, eclipse or javac ?

Thread view: 
Red Orchid - 19 Sep 2006 14:53 GMT
The following code is OK with eclipse (3.3M1).

<code_1>
// This is simple example.

<T>T test(String name) {
       
   try {
       InputStream in = new FileInputStream(name);
       return (T) new ObjectInputStream(in).readObject();
   }
   catch (Exception e) {
   }
       return null;
   }
}

<T>T text() {
       
   return test("data");
}

</code_1>

But, javac(JDK5.0 Update 8) throws this error.

"type parameters of <T>T cannot be determined; no unique maximal
instance exists for type variable T with upper bounds T,java.lang.Object
return test("data");"

I think that javac is wrong because a duplicate code should be
written for removing this error.  A duplicate code is not good
for maintenance.

What is your comment ?
Thanks.
Oliver Wong - 19 Sep 2006 16:19 GMT
> The following code is OK with eclipse (3.3M1).
>
[quoted text clipped - 32 lines]
> What is your comment ?
> Thanks.

   I don't know the answer for sure, but after asking many questions about
generics, Eclipse and javac, the gurus here have told me that Eclipse is
usually "wrong" according to the JLS, even if Eclipse's behaviour is "more
useful" or "more intuitive". This isn't so surprising, as the organization
which writes javac is the same as the organization which writes the JLS.

   - Oliver
myx4t@yahoo.fr - 21 Sep 2006 12:55 GMT
Nice FUD Oliver. <g>

Unfortunately, in this case Eclipse is right, according to the spec,
and javac is wrong.
This is a documented bug in javac; pls check:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.