@Override public JvmType findTypeByName(String name) { try { // seems to be the only reliable way to locate nested types // since dollar signs are a quite good indicator but not necessarily the best BinaryClass clazz = classFinder.forName(name); return findTypeByClass(clazz); } catch (ClassNotFoundException e) { return tryFindTypeInIndex(name, true); } }
private JvmType doFindTypeByName(String name) { try { // seems to be the only reliable way to locate nested types // since dollar signs are a quite good indicator but not necessarily the best Class<?> clazz = findClassByName(name); return findTypeByClass(clazz); } catch (ClassNotFoundException e) { return tryFindTypeInIndex(name, false); } catch (NoClassDefFoundError e) { /* * Error will be thrown if the contents of the binary class file does not match the expectation (transitively). * See java.lang.ClassLoader.defineClass(String, byte[], int, int, ProtectionDomain) */ return tryFindTypeInIndex(name, false); } }
@Override public JvmType findTypeByName(String name) { try { // seems to be the only reliable way to locate nested types // since dollar signs are a quite good indicator but not necessarily the best Class<?> clazz = classFinder.forName(name); return findTypeByClass(clazz); } catch (ClassNotFoundException e) { return tryFindTypeInIndex(name, true); } catch (NoClassDefFoundError e) { /* * Error will be thrown if the contents of the binary class file does not match the expectation (transitively). * See java.lang.ClassLoader.defineClass(String, byte[], int, int, ProtectionDomain) */ return tryFindTypeInIndex(name, true); } }
private JvmType doFindTypeByName(String name) { try { // seems to be the only reliable way to locate nested types // since dollar signs are a quite good indicator but not necessarily the best BinaryClass clazz = findClassByName(name); return findTypeByClass(clazz); } catch (ClassNotFoundExceptionWithBaseName e) { String outerName = e.getBaseName(); JvmType outer = doFindTypeByName(outerName); if (outer instanceof JvmDeclaredType) { String nestedNames = name.substring(outerName.length() + 1); List<String> segments = Strings.split(nestedNames, "."); return findNestedType((JvmDeclaredType) outer, segments, 0); } return null; } catch (ClassNotFoundException e) { return tryFindTypeInIndex(name, false); } }
private JvmType findTypeByClass(Class<?> clazz) { IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess(); URI resourceURI = uriHelper.createResourceURI(clazz); if (indexedJvmTypeAccess != null) { URI proxyURI = resourceURI.appendFragment(uriHelper.getFragment(clazz)); EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; } TypeResource result = (TypeResource) getResourceSet().getResource(resourceURI, true); return findTypeByClass(clazz, result); }
private JvmType findTypeByClass(BinaryClass clazz) { try { IndexedJvmTypeAccess indexedJvmTypeAccess = getIndexedJvmTypeAccess(); URI resourceURI = clazz.getResourceURI(); if (indexedJvmTypeAccess != null) { URI proxyURI = resourceURI.appendFragment(clazz.getURIFragment()); EObject candidate = indexedJvmTypeAccess.getIndexedJvmType(proxyURI, getResourceSet()); if (candidate instanceof JvmType) return (JvmType) candidate; } TypeResource result = (TypeResource) getResourceSet().getResource(resourceURI, true); return findTypeByClass(clazz, result); } catch(UnknownNestedTypeException e) { return null; } }