Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please do not use underscores as Java identifiers in source code #3045

Closed
vemv opened this issue Oct 29, 2023 · 5 comments
Closed

Please do not use underscores as Java identifiers in source code #3045

vemv opened this issue Oct 29, 2023 · 5 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@vemv
Copy link

vemv commented Oct 29, 2023

Describe the bug

The java source code of these libraries, as distributed in e.g. aws-java-sdk-core-1.12.576-sources.jar(/com/amazonaws/internal/ResettableInputStream.java):143 can occasionally use underscores as identifiers.

That's no longer valid after Java 9 and hinders any modern tooling that would want to parse your source code (e.g. for extracting useful info from its doc comments).

Expected Behavior

The Java source code is valid for JDK9+.

Current Behavior

It uses underscores as identifiers, and official tooling (e.g. javax.tools.DocumentationTool) will complain:

error: as of release 9, '_' is a keyword, and may not be used as an identifier

Reproduction Steps

Try running javac and/or other official JDK tools over your source code using a target version >= 9

Possible Solution

Update _ identifiers to e.g. _ignored

Additional Information/Context

No response

AWS Java SDK version used

1.12.576

JDK version used

openjdk version "16.0.1" 2021-04-20

Operating System and version

macOS

@vemv vemv added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 29, 2023
vemv added a commit to clojure-emacs/orchard that referenced this issue Oct 29, 2023
We used to return nil for invalid .java source code.

Now we throw an exception, with the parsing error diagnostics as part of the ex-data.

Note that this doesn't change user-facing behavior, since all exceptions are caught by default in `orchard.java.parser/source-info` / `orchard.java.parser-next/source-info`.

This helps debug faulty .java source code, see e.g. aws/aws-sdk-java#3045
vemv added a commit to clojure-emacs/orchard that referenced this issue Oct 29, 2023
We used to return nil for invalid .java source code.

Now we throw an exception, with the parsing error diagnostics as part of the ex-data.

Note that this doesn't change user-facing behavior, since all exceptions are caught by default in `orchard.java.parser/source-info` / `orchard.java.parser-next/source-info`.

This helps debug faulty .java source code, see e.g. aws/aws-sdk-java#3045
vemv added a commit to clojure-emacs/orchard that referenced this issue Oct 30, 2023
We used to return nil for invalid .java source code.

Now we throw an exception, with the parsing error diagnostics as part of the ex-data.

Note that this doesn't change user-facing behavior, since all exceptions are caught by default in `orchard.java.parser/source-info` / `orchard.java.parser-next/source-info`.

This helps debug faulty .java source code, see e.g. aws/aws-sdk-java#3045
vemv added a commit to clojure-emacs/orchard that referenced this issue Oct 30, 2023
…le (#205)

We used to return nil for invalid .java source code.

Now we throw an exception, with the parsing error diagnostics as part of the ex-data.

Note that this doesn't change user-facing behavior, since all exceptions are caught by default in `orchard.java.parser/source-info` / `orchard.java.parser-next/source-info`.

This helps debug faulty .java source code, see e.g. aws/aws-sdk-java#3045
@debora-ito
Copy link
Member

@vemv I understand the issue, I'll see if we can make the change in ResettableInputStream#mark.

That said, you don't need to compile the Java SDK code to be able to use it. The recommended way to consume the SDK is to add the modules as dependencies, as showed in the Developer Guide - https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-project-maven.html#configuring-maven

<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-s3</artifactId>
  </dependency>
<dependency>

The SDK is compiled against JDK7, so you won't be blocked by this error when consuming as dependencies.

@debora-ito debora-ito added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Oct 30, 2023
@vemv
Copy link
Author

vemv commented Oct 30, 2023

Thanks! Yes, I understand.

My issue is not created from the perspective of a SDK consumer but rather, from the perspective of a tooling maker.

My tooling parses source jars such as aws-java-sdk-core-1.12.576-sources.jar for IDE insights - so the source ideally would be valid.

@debora-ito
Copy link
Member

@vemv We removed the underscore, the change is available in the latest release:

Copy link

This issue is now closed.

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@vemv
Copy link
Author

vemv commented Jul 31, 2024

Thanks - appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants