private DotName toJandexName(Name typeName) { if (DotNameAdapter.class.isInstance(typeName)) { return ((DotNameAdapter) typeName).jandexName(); } else { return DotName.createSimple(typeName.fullName()); } }
protected JavaTypeDescriptor makeTypeDescriptor(Name typeName) { final String classNameToLoad = typeName.fullName(); if (isSafeClass(typeName)) { return makeTypeDescriptor(typeName, classLoaderService.classForName(classNameToLoad)); } else { if (jpaTempClassLoader == null) { log.debug( "Request to makeTypeDescriptor(%s) - but passed class is not known to be " + "safe (it might be, it might not be). However, there was no " + "temp ClassLoader provided; we will use the live ClassLoader"); try { // this reference is "safe" because it was loaded from the live ClassLoader return makeTypeDescriptor(typeName, classLoaderService.classForName(classNameToLoad)); } catch (ClassLoadingException e) { return new NoSuchClassTypeDescriptor(typeName); } } else { log.debug( "Request to makeTypeDescriptor(%s) - passed class is not known to be " + "safe (it might be, it might not be). There was a temp ClassLoader " + "provided, so we will use that"); // this is the Class reference that is unsafe to keep around... final Class unSafeReference; try { unSafeReference = jpaTempClassLoader.loadClass(classNameToLoad); } catch (ClassNotFoundException e) { return new NoSuchClassTypeDescriptor(typeName); } return makeTypeDescriptor(typeName, unSafeReference); } } }
private boolean isSafeClass(Name className) { final String classNameString = className.fullName(); // classes in any of these packages are safe to load through the "live" ClassLoader return classNameString.startsWith("java.") || classNameString.startsWith("javax.") || classNameString.startsWith("org.hibernate"); }
@Override public JavaTypeDescriptor getType(Name typeName) { if (typeName == null) { return null; } final String typeNameString = typeName.fullName(); if ("void".equals(typeNameString)) { return VoidDescriptor.INSTANCE; } JavaTypeDescriptor descriptor = typeDescriptorMap.get(typeName); if (descriptor == null) { descriptor = Primitives.resolveByName(typeName); } if (descriptor == null) { descriptor = makeTypeDescriptor(typeName); typeDescriptorMap.put(typeName, descriptor); } return descriptor; }
@Override public String toString() { return "InterfaceDescriptorImpl{" + name.toString() + '}'; }