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

Linter: Java class blacklist #100

Open
vemv opened this issue Dec 12, 2019 · 1 comment
Open

Linter: Java class blacklist #100

vemv opened this issue Dec 12, 2019 · 1 comment

Comments

@vemv
Copy link
Contributor

vemv commented Dec 12, 2019

Context

There are historical Java classes which are thread-unsafe, and/or have been superseded.

Those classes should be avoided in regular code. At most one could wrap them in a library, so the gotchas are abstracted away.

Task

Create a linter that analyzes :imports (or even a whole namespace - imports aren't mandatory) finding references to a class blacklist: SimpleDateFormat, URL, GregorianCalendar, DecimalFormat, and etc (research).

Acceptance criteria

  • Analyzes :imports with different syntaxes
    • Or better: Uses ns-publics or such to query the currently imported clases
  • Analyzes whole namespaces (each defn, etc), including metadata
    • This is necesary (even if querying ns-publics) since code can refer to classes that were not :imported
  • The blacklist should be configurable
  • .cljs files are excluded

Additional resources

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/URL.html#equals(java.lang.Object)

https://www.callicoder.com/java-simpledateformat-thread-safety-issues/

@vemv
Copy link
Contributor Author

vemv commented Jun 10, 2020

Semi-related, (def foo (java.text.Collator/getInstance)) is correct but potentially slow in a threaded context because it's a synchronized class. It's better but in a defn.

http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/00cd9dc3c2b5/src/share/classes/java/text/Collator.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant