This discussion is archived
1 2 3 Previous Next 39 Replies Latest reply: Jul 24, 2010 10:59 AM by 794029 Go to original post RSS
  • 30. Re: Generics problem
    794029 Newbie
    Currently Being Moderated
    pete_d wrote:
    00jt wrote:
    pete_d wrote:
    00jt wrote:
    I agree no one should write code like that. But just because it "shouldn't ever happen" doesn't mean that we shouldn't handle it in our resolution algorithm.
    We want our algorithm to be completely correct, that is: if someone coded badly (naming a variable the same as a generic) it would still run the same on our system as it does on Java.
    We can't just say "oh well.. THAT will never happen... lets not worry about that".
    When any specification is silent or ambiguous you have no choice but to make a best effort. It appears that Eclipse and Netbeans have made theirs. I guess you would have to go with your own. I'm inclined to go with the "reference implementation" so at least there is that to lean on.
    My question was if anyone knows if this is specified anywhere.
    To me, the definitive sources are the "reference implementation" and then the JLS in that order. That's just me.
    I would go the opposite..
    If the specification said "X", but the implementation shows "Y". Then i would say, "it was incorrectly implemented."
    Are you suggesting that in the same scenario, you would say "it is incorrectly specified"?

    Also, by "reference implementation" are you talking about getting the name through "getCanonicalName()"? or something like that?

    >
    Perhaps i will just stick with what Javac seems to do.
    Isn't there suppose to be some kind of official test suite to show that an implementation is "Java".
    I am unaware of a suite provided by java. Or are you saying that we (my group) needs to have an official test suite and test it against "java"?

    What i am saying is that: "if it isn't specified in the JLS, then whatever Java does.. that is +right+ ". And whatever Netbeans/Eclipse says is wrong if they do otherwise.

    EDIT.

    Actually, i think it would be simplest if Java just specified that a "type variable" was treated like a "type"
    so that if i had:
    class foo<A>{
       class A{}  // I would like this to be declared as "ambiguous" because "the type A is already defined."
    }
    Edited by: 00jt on Jul 26, 2010 10:02 AM
  • 31. Re: Generics problem
    843793 Newbie
    Currently Being Moderated
    00jt wrote:
    pete_d wrote:
    00jt wrote:
    pete_d wrote:
    00jt wrote:
    I agree no one should write code like that. But just because it "shouldn't ever happen" doesn't mean that we shouldn't handle it in our resolution algorithm.
    We want our algorithm to be completely correct, that is: if someone coded badly (naming a variable the same as a generic) it would still run the same on our system as it does on Java.
    We can't just say "oh well.. THAT will never happen... lets not worry about that".
    When any specification is silent or ambiguous you have no choice but to make a best effort. It appears that Eclipse and Netbeans have made theirs. I guess you would have to go with your own. I'm inclined to go with the "reference implementation" so at least there is that to lean on.
    My question was if anyone knows if this is specified anywhere.
    To me, the definitive sources are the "reference implementation" and then the JLS in that order. That's just me.
    For clarification, when you say "reference implementation" you mean using "getCanonicalName()" or something like that?
    And if you do mean that, i assume you mean when you run it from the command line (not in an IDE).

    Anyhow, if there is a discrepancy between Specification and Implementation... you are saying that it is correctly implemented, and it was incorrectly specified?
    I'm saying the "reference implementation" is the next definitive source of guidance on the matter.
    I would personally say that the specification is correct, and it was incorrectly implemented.
    But here, as you find, the specification does not resolve the matter so the next best guide is the "reference implementation".

    >>
    Perhaps i will just stick with what Javac seems to do.
    Isn't there suppose to be some kind of official test suite to show that an implementation is "Java".
    A suite from Java? I'm not sure.

    I'm just saying that if i can't find the specification in the JLS, then if Java prints "A" then "A" is right. And Netbeans & Eclipse's view is irrelevant (though interesting).
    I think we agree on that.
  • 32. Re: Generics problem
    794029 Newbie
    Currently Being Moderated
    pete_d wrote:
    To me, the definitive sources are the "reference implementation" and then the JLS in that order. That's just me.
    ....
    I'm saying the "reference implementation" is the next definitive source of guidance on the matter.
    contradiction? lol.

    Anyhow, i think we agree - i was just confused with your wording.
  • 33. Re: Generics problem
    EJP Guru
    Currently Being Moderated
    I'd be careful about this. There were quite a few instances in Generics where the Eclipse compiler was correct and the Java JDK compiler turned out to be wrong and was subsequently fixed. This could be another one.
  • 34. Re: Generics problem
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    00jt wrote:
    anyone else have ideas?
    Ask in the generics forum for one.

    Also presumably you are looking for the correct rather than expected behavior. And you might want to consider if your users are going to want the first over the second. Perhaps you might want to allow for a flag to switch it from one to the other.
  • 35. Re: Generics problem
    794029 Newbie
    Currently Being Moderated
    jschell wrote:
    00jt wrote:
    anyone else have ideas?
    Ask in the generics forum for one.

    Also presumably you are looking for the correct rather than expected behavior. And you might want to consider if your users are going to want the first over the second. Perhaps you might want to allow for a flag to switch it from one to the other.
    Might as well.
    And good point.
  • 36. Re: Generics problem
    794029 Newbie
    Currently Being Moderated
    i posted on the Generics fourm here

    I think Netbeans & Javac are wrong.
    I had an example where they are not consistent in their implementation.
  • 37. JCK [was: Generics problem]
    782681 Newbie
    Currently Being Moderated
    00jt wrote:
    pete_d wrote:
    ...
    Isn't there suppose to be some kind of official test suite to show that an implementation is "Java".
    I am unaware of a suite provided by java.
    Are you aware of [Java Compatibility Kit (JCK)|http://en.wikipedia.org/wiki/Technology_Compatibility_Kit#TCK_for_the_Java_platform|explanation]? +"a technology compatibility kit for a particular Java platform"+
    Or are you saying that we (my group) needs to have an official test suite and test it against "java"?...
    For stuff like above, you'd better consult with a lawyer. If you are going to use [Java logo|http://en.wikipedia.org/wiki/File:Java_logo.svg|explanation], your stuff might need to be certified with compatibility kit.
  • 38. Re: JCK [was: Generics problem]
    794029 Newbie
    Currently Being Moderated
    gnat wrote:
    00jt wrote:
    pete_d wrote:
    ...
    Isn't there suppose to be some kind of official test suite to show that an implementation is "Java".
    I am unaware of a suite provided by java.
    Are you aware of [Java Compatibility Kit (JCK)|http://en.wikipedia.org/wiki/Technology_Compatibility_Kit#TCK_for_the_Java_platform|explanation]? +"a technology compatibility kit for a particular Java platform"+
    No.
    Thank you for it.
    >
    Or are you saying that we (my group) needs to have an official test suite and test it against "java"?...
    For stuff like above, you'd better consult with a lawyer. If you are going to use [Java logo|http://en.wikipedia.org/wiki/File:Java_logo.svg|explanation], your stuff might need to be certified with compatibility kit.
    Its all hardware, for embedded systems.. The managers already have it all cleared out i believe.


    Here is a good example of why i think this is a bug with Java itself.

    public class Error<T> {
         class T{
             T  t1 = new Error().new T(); // ERROR, incompatible types with Generic
        }
        class DeeperNesting{   
            class T{
               T t2 = new Error().new DeeperNesting().new T(); // valid, "t2" is the class Error.DepperNesting.T
            }
        }
    }
    t1 and t2 should both be of the class type (not the generic type)
  • 39. This Thread is now moved
    EJP Guru
    Currently Being Moderated
    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.
1 2 3 Previous Next