Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:48:48+00:00 2026-06-03T19:48:48+00:00

Essential Java Generics states that the output for this code: public interface Foo<T> {

  • 0

Essential Java Generics states that the output for this code:

public interface Foo<T> {
    void foo(T param);
}

public class Bar implements Foo<Bar> {
    // This method will appear twice once with Object as parameter and once with Bar.
    public void foo(Bar param) {
    }

    public static void main(String[] args) {
        for (Method m : Bar.class.getMethods())
            if (m.getName().startsWith("foo"))
                System.out.println(m.toGenericString());
    }
}

is:

public void Bar.foo(Bar)
public volatile void Bar.foo(java.lang.Object)

But when I compiled (1.7 compiler) and run the code, I have:

public void Bar.foo(Bar)
public void Bar.foo(java.lang.Object)

I re-compiled it using a 1.6 compiler. But my output is still the same.

The author’s exact quote is:

$ java Bar
public void Bar.foo(Bar)
public volatile void Bar.foo(java.lang.Object)

So it doesn’t seem like a typo error on his part.

What is causing the output to be different?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:48:50+00:00Added an answer on June 3, 2026 at 7:48 pm

    There is no such thing as a volatile method in Java. Only fields can be volatile.

    See Why make a method volatile in java? for further details.

    As the top answer there explains, the same bit mask (0x00000040) is used for different purposes for fields and for methods. This confuses some older Java tools, causing them to incorrectly mark bridge methods as volatile.

    In other words, there was a bug in the software that the blog writer was using at the time, causing the software to mistakenly include the volatile in the printout. The bug got fixed, and you’re not seeing the erroneous modifier anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();
For ultra-fast code it essential that we keep locality of reference- keep as much
I have a code that is essential to my website and it works in
I have a (Java) class with operations like this: abstract class Holder { def
i wanna create a java application that must perform some essential action (closing of
I have some classes that all implement the same Java interface, which essentially allows
Explanation/preamble In Java, if you declare an abstract class with abstract methods, e.g. public
This is my Javac compiling statement: javac -cp C:\java\code\j3D\j3dcore.jar;C:\java\code\j3D\j3dutils.jar;C:\java\code\j3D\vecmath.jar Simple.java compiles with no problems.
I have a book, Essential ActionScript 3 (O'Reilly), to learn about using that language.
I have the following code which I stripped out of any non-essential lines to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.