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

  • Home
  • SEARCH
  • 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 67765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:18:40+00:00 2026-05-10T19:18:40+00:00

This question is a follow up to: Why can’t I call a method outside

  • 0

This question is a follow up to: Why can’t I call a method outside of an anonymous class of the same name

This previous question answer why, but now I want to know if javac should find run(int bar)? (See previous question to see why run(42) fails)

If it shouldn’t, is it due to a spec? Does it produce ambiguous code? My point is, I think this is a bug. While the previous question explained why this code fails to compile, I feel it should compile if javac searched higher in the tree if it fails to find a match at the current level. IE. If this.run() does not match, it should automatically check NotApplicable.this for a run method.

Also note that foo(int bar) is correctly found. If you give any reason why run(int bar) shouldn’t be found, it must also explain why foo(int bar) is found.

public class NotApplicable {      public NotApplicable() {         new Runnable() {             public void run() {                  // this works just fine, it automatically used NotApplicable.this when it couldn't find this.foo                 foo(42);                  // this fails to compile, javac find this.run(), and it does not match                 run(42);                  // to force javac to find run(int bar) you must use the following                 //NotApplicable.this.run(42);             }         };     }      private void run(int bar) {     }      public void foo(int bar) {     } } 
  • 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. 2026-05-10T19:18:41+00:00Added an answer on May 10, 2026 at 7:18 pm

    This behavior of javac conforms to the spec. See §15.12 Method Invocation Expressions in the Java Language Specification, specifically the paragraph under ‘Compile Time Step 1’ explaining the meaning of an unqualified method invocation:

    If the Identifier appears within the scope (§6.3) of a visible method declaration with that name, then there must be an enclosing type declaration of which that method is a member. Let T be the innermost such type declaration. The class or interface to search is T.

    In other words, the unqualified method name is searched for in all enclosing scopes, and the innermost ‘type declaration’ (which means either a class or an interface declaration) in which the name is found is the one that will be searched for the whole signature (in ‘Compile Time Step 2’).

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

Sidebar

Ask A Question

Stats

  • Questions 226k
  • Answers 226k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Looks like a many-many relationship for "what users have seen… May 13, 2026 at 1:13 am
  • Editorial Team
    Editorial Team added an answer The session data should be stored separately to the data,… May 13, 2026 at 1:13 am
  • Editorial Team
    Editorial Team added an answer There's DJGPP for C/C++. http://www.delorie.com/djgpp/ May 13, 2026 at 1:13 am

Related Questions

This is a follow up to my previous question: Problem passing parameters via Iframe
Here we are again with the next problem in sorting. this is a follow
This is a follow up to one of my previous questions and I have
This is something of a follow-up question to my question here . You can

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.