Giter VIP home page Giter VIP logo

Comments (4)

algomaster99 avatar algomaster99 commented on May 27, 2024

Hi @honghao12 ! I tried reproducing it, but anImport.toString does evaluate to import static StaticTest3.StaticInnerTest1. This functionality was last touched in #5213 and it was also released in 10.4.0 so it should work on any release after that. However, if it is still not working for you, could you please reproduce the output as a pull request (ideally as a new testcase)?

from spoon.

xzel23 avatar xzel23 commented on May 27, 2024

In what version of Java is import static used to import classes as opposed to fields and methods? Does that even compile with javac? import static StaticTest3.StaticInnerTest1 looks like it should be a compile time error anyway. import StaticTest3.StaticInnerTest1 looks correct.

from spoon.

SirYwell avatar SirYwell commented on May 27, 2024

The relevant part of the JLS regarding that is ยง 7.5.3. It mainly mentions static members, which includes static nested classes. This becomes clear from the following sentence (emphasis mine):

It is permissible for one single-static-import declaration to import several fields, classes, or interfaces with the same name, or several methods with the same name and signature.

I don't know how well we have test coverage for that, but we should make sure that we get imports right for both static nested classes and non-static nested classes.

from spoon.

xzel23 avatar xzel23 commented on May 27, 2024

Today I learned. From what I understand, for a static inner class it makes no real difference anyway, and some coding standards (like Google's) explicitly forbid using a single static import for static one classes ("use normal import instead").

Of course SPOON should handle this correctly. But the result (the missing "static" keyword) should have no negative effect on the resulting code from a practical point of view in (nearly?) all cases.

from spoon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.