Merge "PreloadCheck: Add some comments"

am: a1759a9bd8

Change-Id: I923ea92dc15dbfcc597d2d00f63707e32ec296af
This commit is contained in:
Andreas Gampe
2019-04-17 16:20:03 -07:00
committed by android-build-merger
4 changed files with 19 additions and 1 deletions

View File

@@ -16,6 +16,9 @@
package com.android.preload.check;
/**
* Test that the given boot classpath class is initialized.
*/
public class Initialized {
public static void main(String[] args) throws Exception {
Util.assertInitialized(args[0], null);

View File

@@ -16,13 +16,16 @@
package com.android.preload.check;
/**
* Test that a helper class is first seen as uninitialized, then initialized after forced.
*/
public class IntegrityCheck {
public static void main(String[] args) throws Exception {
ClassLoader loader = IntegrityCheck.class.getClassLoader();
Util.assertNotInitialized("com.android.preload.check.IntegrityCheck$StatusHelper", loader);
Class<?> klass = Class.forName("com.android.preload.check.IntegrityCheck$StatusHelper",
Class.forName("com.android.preload.check.IntegrityCheck$StatusHelper",
/* initialize */ true, loader);
Util.assertInitialized("com.android.preload.check.IntegrityCheck$StatusHelper", loader);
@@ -30,6 +33,7 @@ public class IntegrityCheck {
System.out.println("OK");
}
@SuppressWarnings("unused")
private static class StatusHelper {
private final static Object defer = new Object();
}

View File

@@ -16,6 +16,9 @@
package com.android.preload.check;
/**
* Test that the given boot classpath class is not initialized.
*/
public class NotInitialized {
public static void main(String[] args) throws Exception {
Util.assertNotInitialized(args[0], null);

View File

@@ -23,7 +23,15 @@ import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Test boot classpath classes that satisfy a given regular expression to be not initialized.
* Optionally check that at least one class was matched.
*/
public class NotInitializedRegex {
/**
* First arg (mandatory): regular exception. Second arg (optional): boolean to denote a
* required match.
*/
public static void main(String[] args) throws Exception {
Matcher m = Pattern.compile(args[0]).matcher("");
boolean requiresMatch = args.length > 1 ? Boolean.parseBoolean(args[1]) : false;