Volatile methods !

C

Chris Uppal

Here's something that I've just noticed: Try this on a 1.5 Java:

=============
import java.lang.reflect.Method;

public class Test
{
public static void
main(String[] args)
{
Class sbc = java.lang.StringBuilder.class;
for (Method method : sbc.getDeclaredMethods())
{
if (method.getName().equals("append")
&& method.getParameterTypes().length == 1
&& method.getParameterTypes()[0] == char.class)
{
System.out.println(method);
System.out.println("\tbridge: " + method.isBridge());
System.out.println("\tsynthetic: " + method.isSynthetic());
}
}
}
}
=============

Which produces:

=============
public java.lang.StringBuilder java.lang.StringBuilder.append(char)
bridge: false
synthetic: false
public volatile java.lang.Appendable java.lang.StringBuilder.append(char)
throws java.io.IOException
bridge: true
synthetic: true
public volatile java.lang.AbstractStringBuilder
java.lang.StringBuilder.append(char)
bridge: true
synthetic: true
=============

<grining>
Two volatile methods!
<grinning/>

I looks as if Sun are using the same bit to mark these bridge methods as is
used for volatile fields (ACC_VOLATILE == 0x0040). Does anyone know for sure ?
I had been under the impression that they were using a 'Bridge' attribute to
mark those methods.

-- chris
 
Joined
Sep 14, 2007
Messages
1
Reaction score
0
Yes they are, also ACC_TRANSIENT and ACC_VARARGS use the same value.
Everything is explained in the java class format 1.5.
I can't attach the file, but if you google ClassFileFormat-Java5.pdf you should be able to find it.

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top