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

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

Prescreened by: Alex Miller

Environment

None

Activity

Show:
David Bürgin
April 21, 2019, 10:15 AM

Several nested classes in java.lang are also not yet auto-imported. Some of them are though:

The missing imports are the following:

  • Character$Subset

  • Character$UnicodeBlock

  • ProcessBuilder$Redirect

  • Character$UnicodeScript

  • ProcessBuilder$Redirect$Type

Perhaps it would be good to add those here as well. At least I was surprised not being able to use bare Character$UnicodeBlock.

Shogo Ohta
December 18, 2018, 10:46 AM

Added the patch, just in case

Alex Miller
August 8, 2018, 5:23 PM

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.

Ghadi Shayban
August 8, 2018, 4:18 PM

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).

Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Unassigned

Reporter

Shogo Ohta

Labels

Approval

Prescreened

Patch

Code

Priority

Major

Affects versions