Skip to content

Commit ceabf1d

Browse files
committed
Standardize documentation.
1 parent da3cee9 commit ceabf1d

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ public Response execute(String protocol, String... argument) {
10811081
* Custom {@link WinBase.SECURITY_ATTRIBUTES} is required here to "get" Medium Integrity Level.
10821082
* In order to allow Medium Integrity Level clients to open
10831083
* and use a NamedPipe created by an High Integrity Level process.
1084+
*
10841085
* @return A security attributes object that gives everyone read and write access.
10851086
*/
10861087
private WinBase.SECURITY_ATTRIBUTES createSecurityAttributesToAllowMediumIntegrity() {
@@ -2064,7 +2065,7 @@ public interface Dispatcher {
20642065
/**
20652066
* Changes the ownership of a file. Can be called only if this process is owned by root.
20662067
*
2067-
* @param file The path of the file to change ownership of.
2068+
* @param file The path of the file to change ownership of.
20682069
* @param userId The user that should own the file.
20692070
*/
20702071
void chownFileToUser(File file, long userId);
@@ -2079,6 +2080,9 @@ class ForJnaPosixEnvironment implements Dispatcher {
20792080
*/
20802081
private final PosixLibrary library;
20812082

2083+
/**
2084+
* The posix owner to use.
2085+
*/
20822086
private final PosixOwner posixOwner;
20832087

20842088
/**
@@ -2187,21 +2191,17 @@ private void notifySemaphore(File directory, String name, int count, short opera
21872191
PosixLibrary.SemaphoreOperation target = new PosixLibrary.SemaphoreOperation();
21882192
target.operation = operation;
21892193
target.flags = flags;
2190-
try {
2191-
while (count-- > 0) {
2192-
try {
2193-
library.semop(semaphore, target, 1);
2194-
} catch (LastErrorException exception) {
2195-
if (acceptUnavailable && (Native.getLastError() == PosixLibrary.EAGAIN
2196-
|| Native.getLastError() == PosixLibrary.EDEADLK)) {
2197-
break;
2198-
} else {
2199-
throw exception;
2200-
}
2194+
while (count-- > 0) {
2195+
try {
2196+
library.semop(semaphore, target, 1);
2197+
} catch (LastErrorException exception) {
2198+
if (acceptUnavailable && (Native.getLastError() == PosixLibrary.EAGAIN
2199+
|| Native.getLastError() == PosixLibrary.EDEADLK)) {
2200+
break;
2201+
} else {
2202+
throw exception;
22012203
}
22022204
}
2203-
} finally {
2204-
target = null;
22052205
}
22062206
}
22072207

@@ -2346,7 +2346,11 @@ protected List<String> getFieldOrder() {
23462346
}
23472347
}
23482348

2349+
/**
2350+
* Represents a system that supports posix.
2351+
*/
23492352
protected interface PosixOwner {
2353+
23502354
/**
23512355
* Returns the user id of the owner of the supplied file.
23522356
*
@@ -2355,6 +2359,9 @@ protected interface PosixOwner {
23552359
*/
23562360
int getOwnerIdOf(File file);
23572361

2362+
/**
2363+
* An implementation of a posix owner for Linux.
2364+
*/
23582365
class ForLinuxEnvironment implements PosixOwner {
23592366

23602367
/**
@@ -2386,12 +2393,8 @@ public ForLinuxEnvironment(int attempts, long pause, TimeUnit timeUnit) {
23862393
}
23872394

23882395
/**
2389-
* Returns the user id of the owner of the supplied file.
2390-
*
2391-
* @param file The file for which to locate the owner.
2392-
* @return The owner id of the supplied file.
2396+
* {@inheritDoc}
23932397
*/
2394-
@Override
23952398
public int getOwnerIdOf(File file) {
23962399
try {
23972400
// The binding for 'stat' is very platform dependant. To avoid the complexity of binding the correct method,
@@ -2430,8 +2433,16 @@ public int getOwnerIdOf(File file) {
24302433
}
24312434
}
24322435

2436+
/**
2437+
* An implementation for a posix owner that represents AIX.
2438+
*/
24332439
class ForAixEnvironment implements PosixOwner {
24342440

2441+
/**
2442+
* A pattern to represent the owner on the console output.
2443+
*/
2444+
private static final Pattern AIX_OWNER_PATTERN = Pattern.compile("Owner: (\\d+)\\(");
2445+
24352446
/**
24362447
* The maximum amount of attempts for checking the result of a foreign process.
24372448
*/
@@ -2460,15 +2471,9 @@ public ForAixEnvironment(int attempts, long pause, TimeUnit timeUnit) {
24602471
this.timeUnit = timeUnit;
24612472
}
24622473

2463-
private static final Pattern AIX_OWNER_PATTERN = Pattern.compile("Owner: (\\d+)\\(");
2464-
24652474
/**
2466-
* Returns the user id of the owner of the supplied file.
2467-
*
2468-
* @param file The file for which to locate the owner.
2469-
* @return The owner id of the supplied file.
2475+
* {@inheritDoc}
24702476
*/
2471-
@Override
24722477
public int getOwnerIdOf(File file) {
24732478
try {
24742479
Process process = Runtime.getRuntime().exec(new String[]{"istat", file.getAbsolutePath()});
@@ -2501,7 +2506,6 @@ public int getOwnerIdOf(File file) {
25012506
throw new IllegalStateException("Command for istat did not exit in time");
25022507
}
25032508
Matcher matcher = AIX_OWNER_PATTERN.matcher(output.toString());
2504-
// Find and print the Owner UID
25052509
if (matcher.find()) {
25062510
return Integer.parseInt(matcher.group(1));
25072511
} else {
@@ -2513,6 +2517,9 @@ public int getOwnerIdOf(File file) {
25132517
}
25142518
}
25152519

2520+
/**
2521+
* An implementation for a posix owner that represents MacOS.
2522+
*/
25162523
class ForMacEnvironment implements PosixOwner {
25172524

25182525
/**
@@ -2544,18 +2551,14 @@ public ForMacEnvironment(int attempts, long pause, TimeUnit timeUnit) {
25442551
}
25452552

25462553
/**
2547-
* Returns the user id of the owner of the supplied file.
2548-
*
2549-
* @param file The file for which to locate the owner.
2550-
* @return The owner id of the supplied file.
2554+
* {@inheritDoc}
25512555
*/
2552-
@Override
25532556
public int getOwnerIdOf(File file) {
25542557
try {
25552558
// The binding for 'stat' is very platform dependant. To avoid the complexity of binding the correct method,
25562559
// stat is called as a separate command. This is less efficient but more portable.
25572560
Process process = Runtime.getRuntime().exec(new String[]{"stat",
2558-
"-f",
2561+
"-f",
25592562
"%u",
25602563
file.getAbsolutePath()});
25612564
int attempts = this.attempts;

0 commit comments

Comments
 (0)