Skip to content

Class in default package causes StringIndexOutOfBoundsException #170

@bernhardf-ro

Description

@bernhardf-ro

A class in the default package causes a StringIndexOutOfBoundsException in the following code:

DirectoryScanner scanner = zf.getDirectoryScanner(project);
scanner.setIncludes(ObfuscatorTask.toNativePattern(ps.getIncludePatterns(project)));
scanner.setExcludes(ObfuscatorTask.toNativePattern(ps.getExcludePatterns(project)));
String[] matches = ZipScannerTool.getMatches(zf, scanner);
for (int i = 0; i < matches.length; i++) {
String match = matches[i];
int slashIndex = match.lastIndexOf('/');
if (match.endsWith(".class") || match.endsWith("/") && slashIndex > 0) {
match = match.substring(0, slashIndex);
packages.add(match);
}
}

match.substring(0, slashIndex) gets a slashIndex of -1 from match.lastIndexOf('/')

Obfuscating any JAR with a class in the default package should be enough to reproduce the issue.

Ideally such classes would be handled like other classes. But if they are considered unsupported a clear exception would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions