Dear core libs developers,
I recently noted that the JDK lib implementation comes with a list of public
inner classes nested in package private classes. Either these classes are
explicitly flagged as public or they become implicitly public when they are
nested in interfaces (in accordance to JLS). Full list for JDK 11 see below.
These classes cannot be referenced in source files as the parent types cannot
be resolved. But access e.g. via reflection is possible:
Class<?> clazz = Class.forName("java.lang.WeakPairMap$Pair$Lookup");
System.out.println(Modifier.isPublic(clazz.getModifiers()));
Question: Are there any guidelines regarding visibility of such inner classes?
I think in many cases the visibility could be reduced. Is that something that
is worth a bug or patch?
Regards,
-marc
Public inner classes nested in non-public classes in JDK11:
java/awt/EventFilter$FilterAction
java/lang/FdLibm$Cbrt
java/lang/FdLibm$Hypot
java/lang/FdLibm$Pow
java/lang/LiveStackFrame$PrimitiveSlot
java/lang/WeakPairMap$Pair$Lookup
java/lang/WeakPairMap$Pair$Weak
java/lang/invoke/ClassSpecializer$Factory
java/lang/invoke/ClassSpecializer$SpeciesData
java/util/stream/Node$Builder
java/util/stream/Node$OfDouble
java/util/stream/Node$OfInt
java/util/stream/Node$OfLong
java/util/stream/Node$OfPrimitive
java/util/stream/Sink$ChainedDouble
java/util/stream/Sink$ChainedInt
java/util/stream/Sink$ChainedLong
java/util/stream/Sink$ChainedReference
java/util/stream/Sink$OfDouble
java/util/stream/Sink$OfInt
java/util/stream/Sink$OfLong
javax/swing/MultiUIDefaults$MultiUIDefaultsEnumerator$Type
javax/swing/plaf/basic/DragRecognitionSupport$BeforeDrag
javax/swing/plaf/metal/MetalSplitPaneDivider$MetalDividerLayout
javax/swing/plaf/nimbus/Effect$ArrayCache
javax/swing/text/html/AccessibleHTML$HTMLAccessibleContext
javax/swing/text/html/AccessibleHTML$IconElementInfo$IconAccessibleContext
javax/swing/text/html/AccessibleHTML$TableElementInfo$TableAccessibleContext
javax/swing/text/html/AccessibleHTML$TextElementInfo$TextAccessibleContext
javax/swing/text/html/TableView$RowView
javax/xml/catalog/GroupEntry$PreferType
javax/xml/catalog/GroupEntry$ResolveType