Clojure

Add classes that were introduced to java.lang in Java 7/8 into DEFAULT_IMPORTS

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.9
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Approval:
    Triaged

Description

Now that Clojure 1.10 alpha-6 dropped support for Java <=7, it seems reasonable to add the classes that were newly introduced to the java.lang package in Java <=8, into Clojure's DEFAULT_IMPORTS.

Here is the list of those classes I'm aware of:

Introduced in Java 7:

  • AutoCloseable
  • ClassValue
  • ReflectiveOperationException
  • BootstrapMethodError
  • SafeVarargs

Introduced in Java 8:

  • FunctionalInterface

Activity

Hide
Ghadi Shayban added a comment -

Besides AutoCloseable, the rest of those classes are rarely used. I'd rather import them explicitly over polluting the ns imports tbh. (Interfaces annotated with FunctionalInterface, an annotation type, are common; using it explicitly isn't)

There is a minor startup time cost to additional classloading, for classes not already loaded by the java.base module. I've experimented with dropping a bunch of rarely used default imports (a breaking change, no doubt).

Show
Ghadi Shayban added a comment - Besides AutoCloseable, the rest of those classes are rarely used. I'd rather import them explicitly over polluting the ns imports tbh. (Interfaces annotated with FunctionalInterface, an annotation type, are common; using it explicitly isn't) There is a minor startup time cost to additional classloading, for classes not already loaded by the java.base module. I've experimented with dropping a bunch of rarely used default imports (a breaking change, no doubt).
Hide
Alex Miller added a comment -

I think we should uphold what has been true and stated in the past - stuff in java.lang is auto-imported. I do not think autoimporting 6 classes will affect startup time.

Show
Alex Miller added a comment - I think we should uphold what has been true and stated in the past - stuff in java.lang is auto-imported. I do not think autoimporting 6 classes will affect startup time.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: