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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:59:44+00:00 2026-06-18T22:59:44+00:00

The java grammar from the Java Language Specification v7 specifies the following grammar rules

  • 0

The java grammar from the Java Language Specification v7 specifies the following grammar rules for constructors:

Primary:
    ...
    new Creator
    ...

Creator:  
    NonWildcardTypeArguments CreatedName ClassCreatorRest
    CreatedName ( ClassCreatorRest | ArrayCreatorRest )

CreatedName:   
    Identifier [TypeArgumentsOrDiamond] { . Identifier [TypeArgumentsOrDiamond] }

ClassCreatorRest: 
    Arguments [ClassBody]

What puzzles me here is the CreatedName rule. By that token, expressions such as

new Class1<Integer>.Class2<Integer>();

would be valid constructors. Which they of course aren’t.

In fact, I can’t find any case were a chain of identifier (e.g. Class1.Class2) would have more than one type parameter list (e.g. <Integer>). Do such cases exist, or does the grammar makes no sense?

For reference, the equivalent grammar rules given in the section 15.9 of the JLS exhibit the same problem (those rules reference the TypeDecl non-terminal, which is defined in section 4.3).

  • 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-18T22:59:45+00:00Added an answer on June 18, 2026 at 10:59 pm

    This rule looks like a trick to allow both in a single rule:

    • new Class1<...>();
    • new Class1.Class2<...>(); // Where Class2 is a static inner class

    The allowed expression: new Class1<Integer>.Class2<Integer>(); will never compile in Java since:

    The member type Class1.Class2 cannot be qualified with a
    parameterized type, since it is static. Remove arguments from
    qualifying type Class1

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

Sidebar

Related Questions

I have the following ANTLR grammar: grammar Tasks; options { language = Java; }
Consider the following simple grammar. grammar test; options { language = Java; output =
Anybody knows a Java implementation of Constraint Grammar for natural language processing? I know
ANTLR generates java source from the grammar file. Generated source has dependency to ANTLR
PARSER GRAMMAR protocol.g grammar protocol; options { language = Java; output = AST; ASTLabelType=CommonTree;
In Antlrworks I get this error: [18:21:03] Checking Grammar Grammar.g... [18:21:26] Grammar.java:12: code too
Is there a BNF or EBNF that describes the grammar for Java's annotations?
Java noob question: Consider the following C array and initializer code: struct { int
Java Internationalization Rules . It says to replace s1.compareTo(s)==0 with Collator.compare(s1,s2)<0 why <0 ?
I'm currently looking for a lexer/parser that generates Scala code from a BNF grammar

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.