• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I can't find out what's wrong in this code (regarding generics)

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Compiler fails to accept this code with this error message:



I think this error message means <U extends Number> fails to accept <Integer>, but I don't know why.
[ June 10, 2007: Message edited by: Bupjae Lee ]
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code example that you supplied compiled and ran on my development system.

Kaydell
 
Bupjae Lee
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Kaydell Leavitt

Can I ask your development system?

I made that code in Notepad, and I compiled with JDK javac 1.6.0_01 in Command Prompt
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bupjae Lee:
Can I ask your development system?





javac 1.5.0_12

[ hard to get the ^ character positoned correctly ]

[ June 11, 2007: Message edited by: Nicholas Jordan ]
[ June 11, 2007: Message edited by: Nicholas Jordan ]
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried in both 1.5.0_11 and 1.6.0_01 and get the same error.
 
Kaydell Leavitt
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Dear Kaydell Leavitt:
Can I ask your development system?



It compiled under my development system, Eclipse 3.2.2 for Mac OS X, running java 1.5.0_07. Then, when I went back for a second-look, I could have sworn that I was getting an exception. And when I went back to see what kind of exception, the code started working.

I'm consistently getting an output of "10" now.



Kaydell

[Edited to delete inconsistencies]
[ June 11, 2007: Message edited by: Kaydell Leavitt ]
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it with Eclipse under Windows, and it also compiled and ran. I think the issue is that Eclipse doesn't use the pure Java compiler from Sun.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks like a tricky language corner issue, as Sun's compiler and the Eclipse compiler disagree on what's correct. I'm going to move this to our Java in General (Intermediate) forum and call in the big guns.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hm, now I can't really comment without looking egotistical. But EFH asked me to comment, so here I am. I'm pleased he has such a high opinion of me, but I'm pretty sure there are several other regular posters who are at least as qualified. Including (or especially) Dr. Friedman-Hill himself. Anyway...

Thus far, I don't see any reason for the error thrown by Sun's compiler. I would say it looks like a bug. I don't see any good justification for it - it looks like Sun screwed up, period. I will continue to look into it, but so far, I'm not seeing any justification for the behavior of Sun's compiler here.

If anyone else reading this has any further insight, please share it.
[ June 12, 2007: Message edited by: Jim Yingst ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just out of curiosity, what happens if you change "extends" to "super"? Again just curious, not because I remember right now.

Mark
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
super won't work in that context.
reply
    Bookmark Topic Watch Topic
  • New Topic