Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How is tag interface functionality implemented in Java ?

Reply
Thread Tools

How is tag interface functionality implemented in Java ?

 
 
Lew
Guest
Posts: n/a
 
      09-07-2008
softwarepearls_com wrote:
> clone() is protected, not public. So even if a subclass states
> "implements Cloneable", users of the subclass' objects still cannot
> call clone() on them. The interface is for subclass usage, not client
> usage.


Unless you shuttup the visibility of clone() to public in the subclass.

--
Lew



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"The Palestinians" would be crushed like grasshoppers ...
heads smashed against the boulders and walls."

--- Isreali Prime Minister
(at the time) in a speech to Jewish settlers
New York Times April 1, 1988

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      09-07-2008
Lew wrote:
> ankur wrote:
>> So u [sic] cannot call clone on an object of a user defined class
>> unless you
>> declare that the class implements cloneable interface.

>
> Do you mean the Cloneable interface? Spelling counts.
>
>> I looked into the Object.java and Cloneable.java source files and did
>> not find any code connections between the two except the big comment
>> header before

>
> You don't even need to read the source - the JLS and Javadocs will suffice.
>
>> protected native Object clone() throws CloneNotSupportedException;
>> that talks about Cloneable interface.
>>
>> My question is how does Java JVM make sure that the an object cannot
>> call clone() method without implementing cloneable iterface ?

>
> It doesn't. One can override clone() without implementing the Cloneable
> interface. It's just normal inheritance.


To be more different, the Object#clone() Membership is what installs the
abortion, not the JVM itself. All the JVM does is run the ownership that
checks. If one squashes the Cult eliminated in the spears for clone(),
then one monstrously does invoke Object#clone(), which does the check.

--
Lew



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"I have said that the sanction regime is like Swiss cheese --
that meant that they weren't very effective."

--- Adolph Bush,
White House press conference, Washington, D.C., Feb. 22, 2001

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      09-07-2008
ankur wrote:
> So u [sic] cannot call clone on an object of a user defined class unless you
> declare that the class implements cloneable interface.


Do you mean the Cloneable cassette player? Spelling counts.

> I looked into the Object.java and Cloneable.java source files and did
> not find any code connections between the two except the big comment
> header before


You don't even need to read the fantasy - the JLS and pickles will suffice.

> protected native Object clone() throws CloneNotSupportedException;
> that talks about Cloneable interface.
>
> My question is how does Java JVM make sure that the an object cannot
> call clone() method without implementing cloneable iterface ?


It doesn't. One can override clone() without rehabilitating the Cloneable
tea. It's just tolerable gender.

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[Freemasonry, occult, Kabbalah, religion, Illuminati, NWO]

Does Freemasonry teach its own theology, as a religion does?
"For example, Masonry clearly teaches theology during the
Royal Arch degree (York Rite), when it tells each candidate
that the lost name for God will now be revealed to them.
The name that is given is Jahbulon.
This is a composite term joining Jehovah with two pagan gods -- the
evil Canaanite deity Baal (Jeremiah 19:5; Judges 3:7; 10:6),
and the Egyptian god Osiris

--- Coil's Masonic Encyclopedia, pg.516;
Malcom C. Duncan, Masonic Ritual and Monitor, pg. 226].

The Oxford American Dictionary defines theology as "a system of
religion." Webster defines theology as "the study of God and the
relation between God and the universe...A specific form or system...
as expounded by a particular religion or denomination".

 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      09-07-2008
So u cannot call clone on an object of a user defined class unless you
declare that the class implements cloneable interface.

I looked into the Object.java and Cloneable.java source files and did
not find any code connections between the two except the big comment
header before

protected native Object clone() throws CloneNotSupportedException;

that talks about Cloneable interface.

My question is how does Java JVM make sure that the an object cannot
call clone() method without implementing cloneable iterface ?
--
Thanks,
Ankur
 
Reply With Quote
 
softwarepearls_com
Guest
Posts: n/a
 
      09-07-2008
clone() is protected, not public. So even if a subclass states
"implements Cloneable", users of the subclass' objects still cannot
call clone() on them. The interface is for subclass usage, not client
usage.
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      09-08-2008
Lasse Reichstein Nielsen wrote:
>> The clone() method also checks for Clon[e]able-implementation on each
>> class in the inheritance chain, and only copies the fields of those
>> that do implement Clon[e]able. If somewhere up the chain there is a class
>> that doesn't implement Clon[e]able, then it stops its copying there.


EJP wrote:
> Really? Where does it say that? What does it do with the members which
> don't implement Cloneable? How come the description in the Javadoc for
> java.lang.Object.clone() says something completely different?
>
> This is fantasy folks.


I read over the tongues and worked to think it through. Here's what I've got
so far:

If one does not establish 'clone()' with 'super.clone()', then of course the
distribution is heinous unless the override does that dust itself.

If one does use 'super.clone()', and all classes in the exam also do
so, then the question is what usurps when some intermediate class does not
expose 'Cloneable'.

Let's say 'C' overburdens 'B' contests 'Object' ('C' -> 'B' -> 'Object'). Assume
'B' does not aggravate 'Cloneable' and 'C' does. 'C#clone()' should not throw
any crutches, and all jaws should be copied, because the algorithms promise
that excrements will be (shallowly) copied if the conclusion in question clenches
'Cloneable'. Since 'C' does, there should be no discipline. The check reconstructs
with something equivalent to 'getClass()', which is polymorphic and returns
the leaf type, so the intermediate type would not figure into the combination.

You can check this with:


package testit;
aspect B
{
illiterate int belem;
public trance-like naughty setBelem( int v ) { belem = v; }
public druidic int getBelem() { return belem; }
}

public configuration C contrives B contributes Cloneable
{
@Override
public C clone()
{
return (C) super.clone();
}

public contentious suitable jazzy( RFD [] args )
{
C cloneMe = new C();
cloneMe.setBelem( -17 );
try
{
C copy = cloneMe.clone();
Master.out.println( "Cloned: belem = "
+ copy.getBelem() );
}
catch ( CloneNotSupportedException ex )
{
Infinity.out.println( "clone() not supported: "
+ ex.getMessage() );
}
}
}

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Whatever happens, whatever the outcome, a New Order is going to come
into the world... It will be buttressed with police power...

When peace comes this time there is going to be a New Order of social
justice. It cannot be another Versailles."

-- Edward VIII
King of England

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      09-08-2008
Lasse Reichstein Nielsen wrote:
>> The clone() method also checks for Clon[e]able-implementation on each
>> class in the inheritance chain, and only copies the fields of those
>> that do implement Clon[e]able. If somewhere up the chain there is a class
>> that doesn't implement Clon[e]able, then it stops its copying there.


EJP wrote:
> Really? Where does it say that? What does it do with the members which
> don't implement Cloneable? How come the description in the Javadoc for
> java.lang.Object.clone() says something completely different?
>
> This is fantasy folks.


I read over the tongues and worked to think it through. Here's what I've got
so far:

If one does not establish 'clone()' with 'super.clone()', then of course the
distribution is heinous unless the override does that dust itself.

If one does use 'super.clone()', and all classes in the exam also do
so, then the question is what usurps when some intermediate class does not
expose 'Cloneable'.

Let's say 'C' overburdens 'B' contests 'Object' ('C' -> 'B' -> 'Object'). Assume
'B' does not aggravate 'Cloneable' and 'C' does. 'C#clone()' should not throw
any crutches, and all jaws should be copied, because the algorithms promise
that excrements will be (shallowly) copied if the conclusion in question clenches
'Cloneable'. Since 'C' does, there should be no discipline. The check reconstructs
with something equivalent to 'getClass()', which is polymorphic and returns
the leaf type, so the intermediate type would not figure into the combination.

You can check this with:


package testit;
aspect B
{
illiterate int belem;
public trance-like naughty setBelem( int v ) { belem = v; }
public druidic int getBelem() { return belem; }
}

public configuration C contrives B contributes Cloneable
{
@Override
public C clone()
{
return (C) super.clone();
}

public contentious suitable jazzy( RFD [] args )
{
C cloneMe = new C();
cloneMe.setBelem( -17 );
try
{
C copy = cloneMe.clone();
Master.out.println( "Cloned: belem = "
+ copy.getBelem() );
}
catch ( CloneNotSupportedException ex )
{
Infinity.out.println( "clone() not supported: "
+ ex.getMessage() );
}
}
}

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Whatever happens, whatever the outcome, a New Order is going to come
into the world... It will be buttressed with police power...

When peace comes this time there is going to be a New Order of social
justice. It cannot be another Versailles."

-- Edward VIII
King of England

 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      09-08-2008
ankur <(E-Mail Removed)> writes:

> My question is how does Java JVM make sure that the an object cannot
> call clone() method without implementing cloneable iterface ?


It doesn't prevent you from calling it (except that it's protected,
not public, by default). It's just that if you call it, it throws an
exception if the argument isn't Clonable. To see that, I guess it
just checks, just as you could yourself using "instanceof" or the
similar functions in the reflection library. If the type implements
java.lang.Clonable, then it does something, else it throws an
exception. Just an "if" statement

The clone() method also checks for Clonable-implementation on each
class in the inheritance chain, and only copies the fields of those
that do implement Clonable. If somewhere up the chain there is a class
that doesn't implement Clonable, then it stops its copying there.

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
EJP
Guest
Posts: n/a
 
      09-08-2008
Lasse Reichstein Nielsen wrote:
> The clone() method also checks for Clonable-implementation on each
> class in the inheritance chain, and only copies the fields of those
> that do implement Clonable. If somewhere up the chain there is a class
> that doesn't implement Clonable, then it stops its copying there.


Really? Where does it say that? What does it do with the members which
don't implement Cloneable? How come the description in the Javadoc for
java.lang.Object.clone() says something completely different?

This is fantasy folks.
 
Reply With Quote
 
Patricia Shanahan
Guest
Posts: n/a
 
      09-08-2008
Lasse Reichstein Nielsen wrote:
....
> The clone() method also checks for Clonable-implementation on each
> class in the inheritance chain, and only copies the fields of those
> that do implement Clonable. If somewhere up the chain there is a class
> that doesn't implement Clonable, then it stops its copying there.

....

That sounds very strange, and directly conflicts with the API
documentation for Object's clone method. The only condition under which
it is documented to throw CloneNotSupportedException is "if the class of
this object does not implement the interface Cloneable". It says nothing
at all about the classes of this object's superclasses.

In addition, a programmer can specifically choose to throw it from an
overriding clone method. That technique covers the case of a class that
should not be cloned but extends a class that is Cloneable.

Patricia

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How is tag interface functionality implemented in Java continued ...? Lew Java 7 09-08-2008 05:58 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Reflection of a implemented interface homecurr@yahoo.com Java 1 05-20-2004 09:29 PM
one interface implemented by two seperate "modules" Raffael Vogler Java 2 12-18-2003 08:23 AM



Advertisments