We can already accomplish that with type.describeConstable().orElseThrow(); and we can replace all map(ProxyGenerator::toClassDesc) calls with map(Class::describeConstable).map(Optional::orElseThrow) instead.
On Thu, Mar 9, 2023 at 1:45 PM Brian Goetz <brian.go...@oracle.com> wrote: > > > > src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 390: > > > >> 388: uniqueList.add(ex); > >> 389: } > >> 390: return uniqueList.stream().map(ex -> > >> ClassDesc.ofDescriptor(ex.descriptorString())).toList(); > > It would be useful to add a helper method to convert Class to ClassDesc: > > > > private static ClassDesc toClassDesc(Class<?> type) { > > return ClassDesc.ofDescriptor(type.descriptorString()); > > } > > I would love it if we could have this as a factory on ClassDesc itself. > We'd have to filter VMAC/hidden classes (and any other classes that > can't be resolved symbolically), probably by returning > Optional<ClassDesc> instead of ClassDesc. > >