Top Description Fields Constructors Methods
jdk.internal.util

public final Class ClassFileDumper

extends Object
Class Inheritance
Imports
jdk.internal.misc.VM, sun.security.action.GetPropertyAction, java.io.IOException, java.nio.file.Files, .Path, java.security.AccessController, .PrivilegedAction, java.util.HexFormat, .Objects, .Set, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger

ClassFile dumper utility class to log normal and hidden classes.

Implementation Note

Because this class is called by MethodHandleStatics, LambdaForms generation and LambdaMetafactory, make use of lambda lead to recursive calls cause stack overflow.

Field Summary

Modifier and TypeField and Description
private static final Set<Character>
private final AtomicInteger
private final String
private static final ConcurrentHashMap<String, ClassFileDumper>
private final boolean
private static final HexFormat
private final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
dumpClass(String name, Class<?> c, byte[] bytes)

This method determines the path name from the given name and Class object.

public void
dumpFailedClass(String name, byte[] bytes)

This method dumps the given bytes at a path of the given name with a suffix ".failed-$COUNTER" where $COUNTER will be incremented for each time this method is called.

private static String
public static ClassFileDumper
getInstance(String key, String path)

Returns a ClassFileDumper instance for the given key with a given dump path.

public boolean
public String
key()

private Path
private static Path
private void
write(Path path, byte[] bytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BAD_CHARSback to summary
private static final Set<Character> BAD_CHARS
counterback to summary
private final AtomicInteger counter
dumpDirback to summary
private final String dumpDir
DUMPER_MAPback to summary
private static final ConcurrentHashMap<String, ClassFileDumper> DUMPER_MAP
enabledback to summary
private final boolean enabled
HEXback to summary
private static final HexFormat HEX
keyback to summary
private final String key

Constructor Detail

ClassFileDumperback to summary
private ClassFileDumper(String key, String path)

Method Detail

dumpClassback to summary
public void dumpClass(String name, Class<?> c, byte[] bytes)

This method determines the path name from the given name and Class object. If it is a hidden class, it will dump the given bytes at a path of the given name with a suffix "." concatenated with the suffix of the hidden class name.

dumpFailedClassback to summary
public void dumpFailedClass(String name, byte[] bytes)

This method dumps the given bytes at a path of the given name with a suffix ".failed-$COUNTER" where $COUNTER will be incremented for each time this method is called.

encodeForFilenameback to summary
private static String encodeForFilename(String className)
getInstanceback to summary
public static ClassFileDumper getInstance(String key, String path)

Returns a ClassFileDumper instance for the given key with a given dump path. To enable dumping of the generated classes -D or -D=true The system property is read only once when it is the first time the dumper instance for the given key is created.

isEnabledback to summary
public boolean isEnabled()
keyback to summary
public String key()
pathnameback to summary
private Path pathname(String name)
validateDumpDirback to summary
private static Path validateDumpDir(String dir)
Annotations
@SuppressWarnings:removal
writeback to summary
private void write(Path path, byte[] bytes)
Annotations
@SuppressWarnings:removal