static ClasspathJrt forJrtSystem(String jrtPath, AccessRuleSet accessRuleSet, IPath annotationsPath, String release) { return new ClasspathJrt(jrtPath, accessRuleSet, annotationsPath, release); }
private void addRequired(String mod, Set<String> allModules) { IModule iMod = getModule(mod.toCharArray()); for (IModuleReference requiredRef : iMod.requires()) { IModule reqMod = getModule(requiredRef.name()); if (reqMod != null) { String reqModName = String.valueOf(reqMod.name()); if (allModules.add(reqModName)) addRequired(reqModName, allModules); } } } @Override
@Override public NameEnvironmentAnswer findClass(String typeName, String qualifiedPackageName, String moduleName, String qualifiedBinaryFileName) { // return findClass(typeName, qualifiedPackageName, moduleName, qualifiedBinaryFileName, false, null); } /** TEST ONLY */
@Override public Collection<String> getModuleNames(Collection<String> limitModules) { HashMap<String, SimpleSet> cache = findPackagesInModules(this); if (cache != null) return selectModules(cache.keySet(), limitModules); return Collections.emptyList(); }
public ClasspathJrt(String zipFilename, AccessRuleSet accessRuleSet, IPath externalAnnotationPath, String release) { this.zipFilename = zipFilename; this.accessRuleSet = accessRuleSet; if (externalAnnotationPath != null) this.externalAnnotationPath = externalAnnotationPath.toString(); if (release != null && release.length() == 0) { this.release = null; } else { this.release = release; } initialize(); loadModules(this); } /**
@Override public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String moduleName, String qualifiedBinaryFileName, boolean asBinaryOnly) { if (!isPackage(qualifiedPackageName, moduleName)) return null; // most common case try { IBinaryType reader = ClassFileReader.readFromModule(new File(this.zipFilename), moduleName, qualifiedBinaryFileName); if (reader != null) { if (this.externalAnnotationPath != null) { String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length); try { if (this.annotationZipFile == null) { this.annotationZipFile = ExternalAnnotationDecorator.getAnnotationZipFile(this.externalAnnotationPath, null); } reader = ExternalAnnotationDecorator.create(reader, this.externalAnnotationPath, fileNameWithoutExtension, this.annotationZipFile); } catch (IOException e) { // don't let error on annotations fail class reading } } return new NameEnvironmentAnswer(reader, null, reader.getModule()); } } catch (IOException e) { // treat as if class file is missing } catch (ClassFormatException e) { // treat as if class file is missing } return null; }
public ClasspathJrt(String zipFilename, IPath externalAnnotationPath) { this.zipFilename = zipFilename; if (externalAnnotationPath != null) this.externalAnnotationPath = externalAnnotationPath.toString(); loadModules(this); } /**
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ClasspathJrt)) return false; ClasspathJrt jar = (ClasspathJrt) o; if (!Util.equalOrNull(this.release, jar.release)) { return false; } if (this.accessRuleSet != jar.accessRuleSet) if (this.accessRuleSet == null || !this.accessRuleSet.equals(jar.accessRuleSet)) return false; return this.zipFilename.endsWith(jar.zipFilename) && areAllModuleOptionsEqual(jar); }
return; this.release = getReleaseOptionFromCompliance(this.release); this.releaseInHex = Integer.toHexString(Integer.parseInt(this.release)).toUpperCase(); Path lib = Paths.get(this.zipFilename).getParent();
@Override public Collection<String> getModuleNames(Collection<String> limitModules) { HashMap<String, SimpleSet> cache = findPackagesInModules(this); if (cache != null) return selectModules(cache.keySet(), limitModules); return Collections.emptyList(); }
@Override public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String moduleName, String qualifiedBinaryFileName, boolean asBinaryOnly, Predicate<String> moduleNameFilter) { if (!isPackage(qualifiedPackageName, moduleName)) return null; // most common case
private void addRequired(String mod, Set<String> allModules) { IModule iMod = getModule(mod.toCharArray()); for (IModuleReference requiredRef : iMod.requires()) { IModule reqMod = getModule(requiredRef.name()); if (reqMod != null) { String reqModName = String.valueOf(reqMod.name()); if (allModules.add(reqModName)) addRequired(reqModName, allModules); } } } @Override
@Override public NameEnvironmentAnswer findClass(String typeName, String qualifiedPackageName, String moduleName, String qualifiedBinaryFileName) { // return findClass(typeName, qualifiedPackageName, moduleName, qualifiedBinaryFileName, false); } /** TEST ONLY */
static ClasspathLocation forLibrary(String libraryPathname, long lastModified, AccessRuleSet accessRuleSet, IPath annotationsPath, boolean autoModule) { return Util.isJrt(libraryPathname) ? new ClasspathJrt(libraryPathname, annotationsPath) : Util.archiveFormat(libraryPathname) == Util.JMOD_FILE ? new ClasspathJMod(libraryPathname, lastModified, accessRuleSet, annotationsPath) : new ClasspathJar(libraryPathname, lastModified, accessRuleSet, annotationsPath, autoModule); }
private Collection<String> selectModules(Set<String> keySet, Collection<String> limitModules) { Collection<String> rootModules; if (limitModules == NO_LIMIT_MODULES) { rootModules = new HashSet<>(keySet); } else if (limitModules != null) { Set<String> result = new HashSet<>(keySet); result.retainAll(limitModules); rootModules = result; } else { rootModules = JavaProject.internalDefaultRootModules(keySet, s -> s, m -> getModule(m.toCharArray())); } Set<String> allModules = new HashSet<>(rootModules); for (String mod : rootModules) addRequired(mod, allModules); return allModules; }
@Override public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String moduleName, String qualifiedBinaryFileName, boolean asBinaryOnly, Predicate<String> moduleNameFilter) { String fileName = new String(typeName); return findClass(fileName, qualifiedPackageName, moduleName, qualifiedBinaryFileName, asBinaryOnly, moduleNameFilter); } @Override
ClasspathEntry rawClasspathEntry = (ClasspathEntry) root.getRawClasspathEntry(); cp = JavaModelManager.isJrt(path) ? new ClasspathJrt(path.toOSString(), ClasspathEntry.getExternalAnnotationPath(rawClasspathEntry, ((IJavaProject)root.getParent()).getProject(), true)) : new ClasspathJar(manager.getZipFile(path), rawClasspathEntry.getAccessRuleSet(),
private Collection<String> selectModules(Set<String> keySet, Collection<String> limitModules) { Collection<String> rootModules; if (limitModules == NO_LIMIT_MODULES) { rootModules = new HashSet<>(keySet); } else if (limitModules != null) { Set<String> result = new HashSet<>(keySet); result.retainAll(limitModules); rootModules = result; } else { rootModules = JavaProject.internalDefaultRootModules(keySet, s -> s, m -> getModule(m.toCharArray())); } Set<String> allModules = new HashSet<>(rootModules); for (String mod : rootModules) addRequired(mod, allModules); return allModules; }
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String moduleName, String qualifiedBinaryFileName, boolean asBinaryOnly) { String fileName = new String(typeName); return findClass(fileName, qualifiedPackageName, moduleName, qualifiedBinaryFileName, asBinaryOnly); } @Override
String compliance = project.getOption(JavaCore.COMPILER_COMPLIANCE, true); cp = (root instanceof JrtPackageFragmentRoot) ? new ClasspathJrt(path.toOSString(), rawClasspathEntry.getAccessRuleSet(), ClasspathEntry.getExternalAnnotationPath(rawClasspathEntry, project.getProject(), true), compliance) : ClasspathLocation.forLibrary(manager.getZipFile(path), rawClasspathEntry.getAccessRuleSet(),