Skip to content

Commit

Permalink
Remove explicit array creation when using var args
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Apr 14, 2017
1 parent c6fb914 commit 0072848
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,14 @@ private void chmod755(File file) {
Class<?> posixFilePermissionsClass = classLoader.loadClass("java.nio.file.attribute.PosixFilePermissions");
// Set <PosixFilePermission> permissionSet = PosixFilePermissions.fromString("rwxr-xr-x")
Method fromStringMethod = posixFilePermissionsClass.getMethod("fromString", String.class);
Object permissionSet = fromStringMethod.invoke(null, new Object[] {"rwxr-xr-x"});
Object permissionSet = fromStringMethod.invoke(null, "rwxr-xr-x");
// Path path = file.toPath()
Object path = file.getClass().getMethod("toPath").invoke(file);
// Files.setPosixFilePermissions(path, permissionSet)
Class<?> pathClass = classLoader.loadClass("java.nio.file.Path");
Class<?> filesClass = classLoader.loadClass("java.nio.file.Files");
Method setPosixFilePermissionsMethod = filesClass.getMethod("setPosixFilePermissions", pathClass, Set.class);
setPosixFilePermissionsMethod.invoke(null, new Object[] {path, permissionSet});
setPosixFilePermissionsMethod.invoke(null, path, permissionSet);
} catch (Throwable ignored) {
// Fallback to starting a new process
try {
Expand Down

0 comments on commit 0072848

Please sign in to comment.