Example usage for org.eclipse.jdt.internal.compiler.env IModule MODULE_INFO_CLASS

List of usage examples for org.eclipse.jdt.internal.compiler.env IModule MODULE_INFO_CLASS

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env IModule MODULE_INFO_CLASS.

Prototype

String MODULE_INFO_CLASS

To view the source code for org.eclipse.jdt.internal.compiler.env IModule MODULE_INFO_CLASS.

Click Source Link

Usage

From source file:org.eclipse.m2e.jdt.internal.InternalModuleSupport.java

License:Open Source License

private static String getModuleNameFromJar(File file) {
    if (!file.isFile()) {
        return null;
    }//from w ww.j a v a 2s .  c o m
    char[] moduleName = null;
    try (ZipFile zipFile = new ZipFile(file)) {
        IModule module = null;
        ClassFileReader reader = ClassFileReader.read(zipFile, IModule.MODULE_INFO_CLASS);
        if (reader != null) {
            module = reader.getModuleDeclaration();
            if (module != null) {
                moduleName = module.name();
            }
        }
    } catch (ClassFormatException | IOException ex) {
        log.error(ex.getMessage(), ex);
    }
    if (moduleName == null) {
        moduleName = AutomaticModuleNaming.determineAutomaticModuleName(file.getAbsolutePath());
    }
    return new String(moduleName);
}