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 4045026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:21:59+00:00 2026-05-20T13:21:59+00:00

According to Java Generics FAQ http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#FAQ302 a type parameter cannot be forward-referenced in this

  • 0

According to Java Generics FAQ
http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#FAQ302
a type parameter cannot be forward-referenced in this way

<A extends B, B> // error

but it is ok to have

<A extends List<B>, B> // ok

These two examples are verified with the latest jdk 1.6.0_24.

My question is, where in the language spec this is specified, implied, or deductible(i.e. if it is untrue, other things can blow up). I can’t find it anywhere.

Update

In javac7, it is allowed. Intuitively, the order of type parameters doesn’t matter; the type system requires that there’s no cyclic dependencies among type variables: <A extends B, B extends A>. Previously, this can be guaranteed by forbidding forward reference. Apparently javac 7 is improved to relax the ordering, while detecting cycles regardless of ordering.

  • 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-05-20T13:22:00+00:00Added an answer on May 20, 2026 at 1:22 pm

    I’m not sure this is true. I looked over the Java Language Specification and in §6.3 there’s this discussion of the scopes of type parameters:

    The scope of an interface’s type parameter is the entire declaration of the interface including the type parameter section itself. Therefore, type parameters can appear as parts of their own bounds, or as bounds of other type parameters declared in the same section.

    The scope of a method’s type parameter is the entire declaration of the method, including the type parameter section itself. Therefore, type parameters can appear as parts of their own bounds, or as bounds of other type parameters declared in the same section.

    The scope of a constructor’s type parameter is the entire declaration of the constructor, including the type parameter section itself. Therefore, type parameters can appear as parts of their own bounds, or as bounds of other type parameters declared in the same section.

    (My emphasis).

    This suggests that in the declaration

    that B is indeed in scope when writing A extends B.

    Furthermore, §4.4 of the JLS says, when referring to the bound on a type variable, that

    The bound consists of either a type variable, or a class or interface type T

    Which suggests that not only is B in scope in <A extends B, B>, but that it’s a perfectly legal bound on A.

    Finally, to top things off, this code compiles in javac:

    public class Test {
         public static <A extends B, B> A test(B obj) {
             return null;
         }
    }
    

    So I’m pretty sure that this is perfectly legal Java code and that the example you’ve linked to is either wrong or is referring to something else.

    Hope this helps, and let me know if there’s a flaw in my reasoning!

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

Sidebar

Related Questions

No related questions found

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.