Hi I've a doubt with generics erasure.When the compiler do an "erasure" it always convert type parameterswith Object type?If I've a method in which I pass an Integer object the E typo istranslated with Object or with Integers?
|
|
0
|
|
|
|
Reply
|
xdevel1999 (81)
|
4/24/2007 11:03:36 AM |
|
josh wrote:> Hi I've a doubt with generics erasure.No, you don't. You have a question. A doubt is a suspicion, e.g., about veracity or honesty.> When the compiler do an "erasure" it always convert type parameters> with Object type?No, it never does.> If I've a method in which I pass an Integer object the E typo [sic] is> translated with Object or with Integers?Neither. "Erasure" means that the type parameter goes away entirely.-- Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
4/24/2007 12:07:58 PM
|
|
On 24 Apr, 13:07, Lew <l...@nospam.lewscanon.com> wrote:> josh wrote:> > Hi I've a doubt with generics erasure.>> No, you don't. You have a question. A doubt is a suspicion, e.g., about> veracity or honesty.>> > When the compiler do an "erasure" it always convert type parameters> > with Object type?>> No, it never does.are you sure ? many books doesn't say that!> > If I've a method in which I pass an Integer object the E typo [sic] is> > translated with Object or with Integers?>> Neither. "Erasure" means that the type parameter goes away entirely.are you sure ? I'm reading that!
|
|
0
|
|
|
|
Reply
|
josh
|
4/25/2007 8:28:25 AM
|
|
-----BEGIN PGP SIGNED MESSAGE-----Hash: SHA1josh schreef:> On 24 Apr, 13:07, Lew <l...@nospam.lewscanon.com> wrote:>> josh wrote:>>> Hi I've a doubt with generics erasure.>> No, you don't. You have a question. A doubt is a suspicion, e.g., about>> veracity or honesty.>>>>> When the compiler do an "erasure" it always convert type parameters>>> with Object type?>> No, it never does.> > are you sure ? many books doesn't say that!> > >>> If I've a method in which I pass an Integer object the E typo [sic] is>>> translated with Object or with Integers?>> Neither. "Erasure" means that the type parameter goes away entirely.> > are you sure ? I'm reading that!My guess: you have to read better.H.- --Hendrik Marynshttp://tcl.sfs.uni-tuebingen.de/~hendrik/==================http://aouw.orgAsk smart questions, get good answers:http://www.catb.org/~esr/faqs/smart-questions.html-----BEGIN PGP SIGNATURE-----Version: GnuPG v1.4.5 (GNU/Linux)Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.orgiD4DBQFGLyaqe+7xMGD3itQRAlajAJ9I/DsIpXhOOY2sBEYhZzNdh6IjHACSA2MxxgbyXXaG9eJS0GAUquw32w===7uVt-----END PGP SIGNATURE-----
|
|
0
|
|
|
|
Reply
|
Hendrik
|
4/25/2007 10:00:10 AM
|
|
josh schreef:>>> When the compiler do an "erasure" it always convert type parameters>>> with Object type?Lew wrote:>> No, it never does.josh schreef:> are you sure ? Yes.josh schreef:> many books doesn't say that!Which books? What /do/ they say?josh schreef:>>> If I've a method in which I pass an Integer object the E typo [sic] is>>> translated with Object or with Integers?Lew wrote:>> Neither. "Erasure" means that the type parameter goes away entirely.josh schreef:> are you sure ? Yes. Why else would I risk putting it out here in a public place where everyone can see it? Don't worry, I will let you know if I am unsure, otherwise do not doubt it. (Now you are expressing doubt, by the way. See the differeence? You suspect my answer, so you doubt it. It's still correct, of course, despite your doubts.)josh schreef:> I'm reading that!You're reading what. specifically?As the name indicates, type erasure erases the type parameter. It doesn't convert it.Hint: What is the dictionary definition (in English) of the word "erasure"?<http://en.wiktionary.org/wiki/erasure><http://en.wiktionary.org/wiki/erase>Reference:<http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.6>-- Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
4/25/2007 11:49:58 AM
|
|
Lew wrote:> josh wrote:>> Hi I've a doubt with generics erasure.> > No, you don't.Yes he does. If you're going to correct someone's language, be sure you know what you're talking about, first.> A doubt is a suspicion, e.g., about veracity or honesty. You're wrong.-- John W. Kennedy"Compact is becoming contract,Man only earns and pays." -- Charles Williams. "Bors to Elayne: On the King's Coins"* TagZilla 0.066 * http://tagzilla.mozdev.org
|
|
0
|
|
|
|
Reply
|
John
|
4/26/2007 3:04:55 AM
|
|
Hi josh,apart from the meaning of the word "doubt" (I am no native speaker ;-), I think you are right, in what type erasure does. Consider having a class like this:class Container<T> { T t; void set(T t) { this.t=t; }}Then it is true - AFAIK - that T (in line 1) is "erased" whereas the other T's can be thought of "replaced by Object". (Of course, type erasure does a bit more because there are no casts necessary, which would be the case if you replaced T to Object manually.)Ciao,Ingo
|
|
0
|
|
|
|
Reply
|
Ingo
|
4/26/2007 6:44:30 AM
|
|
On 25 Apr, 13:49, Lew <l...@nospam.lewscanon.com> wrote:> josh schreef:>> >>> When the compiler do an "erasure" it always convert type parameters> >>> with Object type?> Lew wrote:> >> No, it never does.>> josh schreef:>> > are you sure ?>> Yes.>> josh schreef:>> > many books doesn't say that!>> Which books? What /do/ they say?>> josh schreef:>> >>> If I've a method in which I pass an Integer object the E typo [sic] is> >>> translated with Object or with Integers?> Lew wrote:> >> Neither. "Erasure" means that the type parameter goes away entirely.>> josh schreef:>> > are you sure ?>> Yes. Why else would I risk putting it out here in a public place where> everyone can see it? Don't worry, I will let you know if I am unsure,> otherwise do not doubt it. (Now you are expressing doubt, by the way. See> the differeence? You suspect my answer, so you doubt it. It's still correct,> of course, despite your doubts.)>> josh schreef:>> > I'm reading that!>> You're reading what. specifically?>> As the name indicates, type erasure erases the type parameter. It doesn't> convert it.>> Hint: What is the dictionary definition (in English) of the word "erasure"?> <http://en.wiktionary.org/wiki/erasure>> <http://en.wiktionary.org/wiki/erase>>> Reference:> <http://java.sun.com/docs/books/jls/third_edition/html/typesValues.htm...>>> --> Lewok, I post this form Java How To Program 6Ed and so you can understandme why I have some "doubts" andnot some questions!this is from Chapter 18 the listing// generic method printArraypublic static < E > void printArray( E[] inputArray ){ // display array elements for ( E element : inputArray ) System.out.printf( "%s ", element ); System.out.println();} // end method printArrayand this is the phrase:>>> When the compiler translates generic method printArray into Java bytecodes, it removes the typeparameter section and replaces the type parameters with actual types.This process is known as erasure.By default all generic types are replaced with type Object <<<so it is said "removes" and than "replaced" and than look at thatfinal book example:public static void printArray( Object[] inputArray ){ // display array elements for ( Object element : inputArray ) System.out.printf( "%s ", element ); System.out.println();} // end method printArrayRegards
|
|
0
|
|
|
|
Reply
|
josh
|
4/26/2007 6:53:31 AM
|
|
josh wrote:> ok, I post this form Java How To Program 6Ed> > ...> and this is the phrase:> >>>>When the compiler translates generic method printArray into Java bytecodes, it removes the type> > parameter section and replaces the type parameters with actual types.> This process is known as erasure.> By default all generic types are replaced with type Object <<<So what does it say about translating generic *classes* into Java. Don't tell me it says that GenericClass<T> is translated into GenericClass<Object>. Which is where we came in.> so it is said "removes" and than "replaced" and than look at that> final book example:That example being about a generic method not a generic class is consistent with what you've been told here.
|
|
0
|
|
|
|
Reply
|
Esmond
|
4/26/2007 7:07:06 AM
|
|
John W. Kennedy wrote:> Lew wrote:>> josh wrote:>>> Hi I've a doubt with generics erasure.>>>> No, you don't.> > Yes he does. If you're going to correct someone's language, be sure you > know what you're talking about, first.> >> A doubt is a suspicion, e.g., about veracity or honesty. > > You're wrong.No, you're wrong, genius.<http://en.wiktionary.org/wiki/doubt>> Verb> > Infinitive> to doubt> > > Third person singular> doubts> > > Simple past> doubted> > > Past participle> doubted> > > Present participle> doubting> > to doubt (third-person singular simple present doubts, present participle doubting, simple past doubted, past participle doubted)> > 1. To lack confidence in; to disbelieve, question, or suspect.> > He doubted that was really what you meant.> > [edit] -- Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
4/26/2007 11:34:35 AM
|
|
"Lew" <lew@nospam.lewscanon.com> wrote in message news:VqKdnXmLWr7WE63bnZ2dnUVZ_qDinZ2d@comcast.com...> John W. Kennedy wrote:>> Lew wrote:>>> josh wrote:>>>> Hi I've a doubt with generics erasure.>>>>>> No, you don't.>>>> Yes he does. If you're going to correct someone's language, be sure you >> know what you're talking about, first.>>>>> A doubt is a suspicion, e.g., about veracity or honesty.>>>> You're wrong.>> No, you're wrong, genius.This same topic was discussed here a few weeks ago. In Britishand American English, the nouns "doubt" and "question" arenever synonymous, but it seems that in Indian English they canbe. "josh" sounds like an American name, but you never know.
|
|
0
|
|
|
|
Reply
|
Larry
|
4/26/2007 1:25:58 PM
|
|
Lew wrote:> John W. Kennedy wrote:>> Lew wrote:>>> josh wrote:>>>> Hi I've a doubt with generics erasure.>>>>>> No, you don't.>>>> Yes he does. If you're going to correct someone's language, be sure >> you know what you're talking about, first.>>>>> A doubt is a suspicion, e.g., about veracity or honesty. >>>> You're wrong.> > No, you're wrong, genius.> <http://en.wiktionary.org/wiki/doubt>>> Verb>>>> Infinitive>> to doubt>> >>>> Third person singular>> doubts>> >>>> Simple past>> doubted>> >>>> Past participle>> doubted>> >>>> Present participle>> doubting>>>> to doubt (third-person singular simple present doubts, present >> participle doubting, simple past doubted, past participle doubted)>>>> 1. To lack confidence in; to disbelieve, question, or suspect.>>>> He doubted that was really what you meant.>>To begin with, you might want to look up the noun, rather than the verb, since it is the noun that is under discussion. But that's neither here nor there, really, seeing that Wiktionary is far less reliable than Wikipedia to begin with. (A competent encyclopedia article requires the author merely to be knowledgeable on the subject at hand, and literate; a competent dictionary entry requires the author to be a lexicographer.)doubt–noun5. a feeling of uncertainty about the truth, reality, or nature of something.6. distrust.7. a state of affairs such as to occasion uncertainty.8. Obsolete. fear; dread.-- Dictionary.com. Dictionary.com Unabridged (v 1.1). Random House, Inc. http://dictionary.reference.com/browse/doubt (accessed: April 26, 2007).doubtn. 1. A lack of certainty that often leads to irresolution. See Synonyms at uncertainty. 2. A lack of trust. 3. A point about which one is uncertain or skeptical: reassured me by answering my doubts. 4. The condition of being unsettled or unresolved: an outcome still in doubt.-- Dictionary.com. The American Heritage® Dictionary of the English Language, Fourth Edition. Houghton Mifflin Company, 2004. http://dictionary.reference.com/browse/doubt (accessed: April 26, 2007).doubtnoun1. the state of being unsure of something [ant: certainty]2. uncertainty about the truth or factuality or existence of something; "the dubiousness of his claim"; "there is no question about the validity of the enterprise"-- Dictionary.com. WordNet® 3.0. Princeton University. http://dictionary.reference.com/browse/doubt (accessed: April 26, 2007).-- John W. Kennedy"Those in the seat of power oft forget their failings and seek only the obeisance of others! Thus is bad government born! Hold in your heart that you and the people are one, human beings all, and good government shall arise of its own accord! Such is the path of virtue!" -- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)* TagZilla 0.066 * http://tagzilla.mozdev.org
|
|
0
|
|
|
|
Reply
|
John
|
4/26/2007 4:37:12 PM
|
|
"John W. Kennedy" <jwkenne@attglobal.net> wrote in message news:%z4Yh.543$qw6.534@newsfe12.lga...> Definitions of "doubt"None of those definitions are "a interrogative statement" or"a request for information", which is how the OP used theword "doubt". In American and British English, it neverhas that meaning.
|
|
0
|
|
|
|
Reply
|
Larry
|
4/27/2007 12:30:54 PM
|
|
Larry Barowski wrote:> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message > news:%z4Yh.543$qw6.534@newsfe12.lga...>> Definitions of "doubt"> > None of those definitions are "a interrogative statement" or> "a request for information", which is how the OP used the> word "doubt". In American and British English, it never> has that meaning."a feeling of uncertainty about the truth, reality, or nature of something""A lack of certainty that often leads to irresolution. See Synonyms at uncertainty.""the state of being unsure of something [ant: certainty]"The "interrogative statement" and "request for information" exist only in your interpretation.-- John W. KennedyRead the remains of Shakespeare's lost play, now annotated!http://pws.prserv.net/jwkennedy/Double%20Falshood/index.html* TagZilla 0.066 * http://tagzilla.mozdev.org
|
|
0
|
|
|
|
Reply
|
John
|
4/27/2007 7:26:05 PM
|
|
"John W. Kennedy" <jwkenne@attglobal.net> wrote in message news:n8sYh.9$jI1.6@newsfe12.lga...> The "interrogative statement" and "request for information" exist only in > your interpretation.Read the OP again. How else would you interpret "I've a doubtwith generics erasure"? He doesn't seem to doubt that genericserasure exists, and doesn't go on to discuss any sort of doubtrelated to erasure. He does have some questions about howerasure works. The two statements that follow seem to be requestsfor information, and not requests to confirm or deny suspicions.Try this: "I have some doubts about ferrets. Are they in the weaselfamily? How many toes do they have?". "doubts" could be thecorrect word there for the intended meaning, but it would be astrange sequence of sentences.
|
|
0
|
|
|
|
Reply
|
Larry
|
4/27/2007 11:52:37 PM
|
|
Larry Barowski wrote:> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message > news:n8sYh.9$jI1.6@newsfe12.lga...>> The "interrogative statement" and "request for information" exist only in >> your interpretation.> > Read the OP again. How else would you interpret "I've a doubt> with generics erasure"? He doesn't seem to doubt that generics> erasure exists, and doesn't go on to discuss any sort of doubt> related to erasure. He does have some questions about how> erasure works. The two statements that follow seem to be requests> for information, and not requests to confirm or deny suspicions.You keep insisting that "doubt" == "suspicion".> Try this: "I have some doubts about ferrets. Are they in the weasel> family? How many toes do they have?". "doubts" could be the> correct word there for the intended meaning, but it would be a> strange sequence of sentences.Oh God! We mustn't have people making sentences the way YOU wouldn't. I mean, next thing, they'll be trying to marry each other....-- John W. Kennedy"...if you had to fall in love with someone who was evil, I can see why it was her." -- "Alias"* TagZilla 0.066 * http://tagzilla.mozdev.org
|
|
0
|
|
|
|
Reply
|
John
|
4/28/2007 2:21:08 AM
|
|
"John W. Kennedy" <jwkenne@attglobal.net> wrote in message news:qcyYh.402$6l1.367@newsfe12.lga...> Larry Barowski wrote:>> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message >> news:n8sYh.9$jI1.6@newsfe12.lga...>>> The "interrogative statement" and "request for information" exist only >>> in your interpretation.>>>> Read the OP again. How else would you interpret "I've a doubt>> with generics erasure"? He doesn't seem to doubt that generics>> erasure exists, and doesn't go on to discuss any sort of doubt>> related to erasure. He does have some questions about how>> erasure works. The two statements that follow seem to be requests>> for information, and not requests to confirm or deny suspicions.>> You keep insisting that "doubt" == "suspicion".I've never insisted on that, or even hinted at it. The paragraphabove is the first in which I've even used the word.He doesn't go on to discuss any sort of doubt related to erasure,using any definition of "doubt" that you supplied earlier. Hedoes follow with two very direct questions.>> Try this: "I have some doubts about ferrets. Are they in the weasel>> family? How many toes do they have?". "doubts" could be the>> correct word there for the intended meaning, but it would be a>> strange sequence of sentences.>> Oh God! We mustn't have people making sentences the way YOU wouldn't. I > mean, next thing, they'll be trying to marry each other....Your point seems to be that we should assume that disjointedsentences in sequence are just as likely as related ones. I thinkyou'll find that related sentences occur much more frequently,even when they are written by people other than ME.
|
|
0
|
|
|
|
Reply
|
Larry
|
4/28/2007 3:34:57 PM
|
|
John W. Kennedy wrote:> "a feeling of uncertainty about the truth, reality, or nature of something"> > "A lack of certainty that often leads to irresolution. See Synonyms at > uncertainty."> > "the state of being unsure of something [ant: certainty]"> > The "interrogative statement" and "request for information" exist only > in your interpretation.> > Those statements do not the match the OP's original statement. All of them in essence mean that a doubt requires a presumption of truth. The OP's original statements neither presume that the answer is "yes" or "no"; thus, they do not have the fundamental questioning of truth that is necessary for doubt to exist.
|
|
0
|
|
|
|
Reply
|
Joshua
|
4/28/2007 8:53:59 PM
|
|
Joshua Cranmer wrote:> John W. Kennedy wrote:>> "a feeling of uncertainty about the truth, reality, or nature of >> something">>>> "A lack of certainty that often leads to irresolution. See Synonyms at >> uncertainty.">>>> "the state of being unsure of something [ant: certainty]">>>> The "interrogative statement" and "request for information" exist only >> in your interpretation.>>>>> > Those statements do not the match the OP's original statement. All of > them in essence mean that a doubt requires a presumption of truth."Is this a statement that I see before me?" -- Lewis Carroll: "A Tangled Tale"-- John W. Kennedy"I want everybody to be smart. As smart as they can be. A world of ignorant people is too dangerous to live in." -- Garson Kanin. "Born Yesterday"* TagZilla 0.066 * http://tagzilla.mozdev.org
|
|
0
|
|
|
|
Reply
|
John
|
4/29/2007 2:41:53 AM
|
|
Larry Barowski wrote:> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message > news:qcyYh.402$6l1.367@newsfe12.lga...>> Larry Barowski wrote:>>> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message >>> news:n8sYh.9$jI1.6@newsfe12.lga...>>>> The "interrogative statement" and "request for information" exist only >>>> in your interpretation.>>> Read the OP again. How else would you interpret "I've a doubt>>> with generics erasure"? He doesn't seem to doubt that generics>>> erasure exists, and doesn't go on to discuss any sort of doubt>>> related to erasure. He does have some questions about how>>> erasure works. The two statements that follow seem to be requests>>> for information, and not requests to confirm or deny suspicions.>> You keep insisting that "doubt" == "suspicion".> > I've never insisted on that, or even hinted at it. The paragraph> above is the first in which I've even used the word.> > He doesn't go on to discuss any sort of doubt related to erasure,> using any definition of "doubt" that you supplied earlier. He> does follow with two very direct questions.> >>> Try this: "I have some doubts about ferrets. Are they in the weasel>>> family? How many toes do they have?". "doubts" could be the>>> correct word there for the intended meaning, but it would be a>>> strange sequence of sentences.>> Oh God! We mustn't have people making sentences the way YOU wouldn't. I >> mean, next thing, they'll be trying to marry each other....> > Your point seems to be that we should assume that disjointed> sentences in sequence are just as likely as related ones. I think> you'll find that related sentences occur much more frequently,> even when they are written by people other than ME.They are related. He states that he is not clear on how type erasure works with Java generics. Then he asks some questions that he hopes will clarify his understanding. His sentences are somewhat parataxic, but hardly disjointed.-- John W. Kennedy"Those in the seat of power oft forget their failings and seek only the obeisance of others! Thus is bad government born! Hold in your heart that you and the people are one, human beings all, and good government shall arise of its own accord! Such is the path of virtue!" -- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)* TagZilla 0.066 * http://tagzilla.mozdev.org
|
|
0
|
|
|
|
Reply
|
John
|
4/29/2007 2:46:02 AM
|
|
> Read the OP again. How else would you interpret "I've a doubt> with generics erasure"? He doesn't seem to doubt that generics> erasure exists, and doesn't go on to discuss any sort of doubt> related to erasure. He does have some questions about how> erasure works. The two statements that follow seem to be requests> for information, and not requests to confirm or deny suspicions.May I just interject here:In India, the word "doubt" means the same as "question".Maybe it's because "doubt" is easier to pronounce.But people would say things like:* Can I ask a doubt about Linux?* Students, go home and finish the 10 doubts in chapter 1.* Okay, students. Any more doubts before we end the class?In England, they don't say "cell phone" or "tv",they say "mobile" and "telly".In India, they don't say "question"; they say "doubt".The OP's name sounds western, but he very well could beborn and raised in India by his western parents.- JT
|
|
0
|
|
|
|
Reply
|
JT
|
4/30/2007 5:09:52 PM
|
|
|
20 Replies
81 Views
(page loaded in 0.129 seconds)
|