public static BinaryModuleDescriptor createDescriptor(ModularClassFile modularClassFile) { return createDescriptor(modularClassFile.getPackageFragmentRoot(), modularClassFile); }
public static BinaryModuleDescriptor createDescriptor(ModularClassFile modularClassFile) { return createDescriptor(modularClassFile.getPackageFragmentRoot(), modularClassFile); }
private IBinaryModule getJarBinaryModuleInfo() throws CoreException, IOException, ClassFormatException { BinaryModuleDescriptor descriptor = BinaryModuleFactory.createDescriptor(this); if (descriptor == null) { return null; } IBinaryModule result = null; IPackageFragmentRoot root = getPackageFragmentRoot(); if (getPackageFragmentRoot() instanceof JarPackageFragmentRoot) { if (root instanceof JrtPackageFragmentRoot || this.name.equals(IModule.MODULE_INFO)) { PackageFragment pkg = (PackageFragment) getParent(); JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) getPackageFragmentRoot(); String entryName = jarRoot.getClassFilePath(Util.concatWith(pkg.names, getElementName(), '/')); byte[] contents = getClassFileContent(jarRoot, entryName); if (contents != null) { String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName; ClassFileReader classFileReader = new ClassFileReader(contents, fileName.toCharArray(), false); return classFileReader.getModuleDeclaration(); } } else { result = BinaryModuleFactory.readModule(descriptor, null); } } else { result = BinaryModuleFactory.readModule(descriptor, null); } return result; }
IPackageFragmentRoot root = getPackageFragmentRoot(); if (getPackageFragmentRoot() instanceof JarPackageFragmentRoot) { if (root instanceof JrtPackageFragmentRoot || this.name.equals(IModule.MODULE_INFO)) { PackageFragment pkg = (PackageFragment) getParent(); JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) getPackageFragmentRoot(); String entryName = jarRoot.getClassFilePath(Util.concatWith(pkg.names, getElementName(), '/')); byte[] contents = getClassFileContent(jarRoot, entryName);
/** * Creates the single child element for this class file adding the resulting * new handle (of type {@link IBinaryModule}) and info object to the newElements table. * Returns true if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ @Override protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryModule moduleInfo = getBinaryModuleInfo(); if (moduleInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(JavaElement.NO_ELEMENTS); return false; } // Create & link a handle: BinaryModule module = new BinaryModule(this, moduleInfo); newElements.put(module, moduleInfo); info.setChildren(new IJavaElement[] {module}); this.binaryModule = module; if (info instanceof ClassFileInfo) { ((ClassFileInfo) info).setModule(module); } ((PackageFragmentRootInfo) getPackageFragmentRoot().getElementInfo()).setModule(module); return true; }
/** * Creates the single child element for this class file adding the resulting * new handle (of type {@link IBinaryModule}) and info object to the newElements table. * Returns true if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ @Override protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryModule moduleInfo = getBinaryModuleInfo(); if (moduleInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(JavaElement.NO_ELEMENTS); return false; } // Read the module BinaryModule module = ((ClassFileInfo) info).readBinaryModule(this, (HashMap<?,?>) newElements, moduleInfo); if (module != null) { this.binaryModule = module; info.setChildren(new IJavaElement[] {module}); ((PackageFragmentRootInfo) getPackageFragmentRoot().getElementInfo()).setModule(module); } return true; }