Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e8c3995 authored by Andreas Gampe's avatar Andreas Gampe
Browse files

PreloadCheck: Add some comments

Test: m
Change-Id: I61039d4fc64f0958bc3f81a49f3a78620c86e34c
parent c771bfeb
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package com.android.preload.check;
package com.android.preload.check;


/**
 * Test that the given boot classpath class is initialized.
 */
public class Initialized {
public class Initialized {
    public static void main(String[] args) throws Exception {
    public static void main(String[] args) throws Exception {
        Util.assertInitialized(args[0], null);
        Util.assertInitialized(args[0], null);
+5 −1
Original line number Original line Diff line number Diff line
@@ -16,13 +16,16 @@


package com.android.preload.check;
package com.android.preload.check;


/**
 * Test that a helper class is first seen as uninitialized, then initialized after forced.
 */
public class IntegrityCheck {
public class IntegrityCheck {
    public static void main(String[] args) throws Exception {
    public static void main(String[] args) throws Exception {
        ClassLoader loader = IntegrityCheck.class.getClassLoader();
        ClassLoader loader = IntegrityCheck.class.getClassLoader();


        Util.assertNotInitialized("com.android.preload.check.IntegrityCheck$StatusHelper", loader);
        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);
                /* initialize */ true, loader);


        Util.assertInitialized("com.android.preload.check.IntegrityCheck$StatusHelper", loader);
        Util.assertInitialized("com.android.preload.check.IntegrityCheck$StatusHelper", loader);
@@ -30,6 +33,7 @@ public class IntegrityCheck {
        System.out.println("OK");
        System.out.println("OK");
    }
    }


    @SuppressWarnings("unused")
    private static class StatusHelper {
    private static class StatusHelper {
        private final static Object defer = new Object();
        private final static Object defer = new Object();
    }
    }
+3 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package com.android.preload.check;
package com.android.preload.check;


/**
 * Test that the given boot classpath class is not initialized.
 */
public class NotInitialized {
public class NotInitialized {
    public static void main(String[] args) throws Exception {
    public static void main(String[] args) throws Exception {
        Util.assertNotInitialized(args[0], null);
        Util.assertNotInitialized(args[0], null);
+8 −0
Original line number Original line Diff line number Diff line
@@ -23,7 +23,15 @@ import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
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 {
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 {
    public static void main(String[] args) throws Exception {
        Matcher m = Pattern.compile(args[0]).matcher("");
        Matcher m = Pattern.compile(args[0]).matcher("");
        boolean requiresMatch = args.length > 1 ? Boolean.parseBoolean(args[1]) : false;
        boolean requiresMatch = args.length > 1 ? Boolean.parseBoolean(args[1]) : false;