test/jdk/com/sun/jdi/ModulesTest.java
author amenkov
Fri, 12 Oct 2018 10:08:11 -0700
changeset 52110 65efb9c57fef
parent 47216 71c04702a3d5
permissions -rw-r--r--
8195703: BasicJDWPConnectionTest.java: 'App exited unexpectedly with 2' Reviewed-by: sspitsyn, jcbeyler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/**
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 42338
diff changeset
    25
 * @test
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 42338
diff changeset
    26
 * @bug 8049365
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 42338
diff changeset
    27
 * @summary Tests the JDI and JDWP update for modules
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 *
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 42338
diff changeset
    29
 * @run build TestScaffold VMConnection TargetListener TargetAdapter
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 42338
diff changeset
    30
 * @run compile -g ModulesTest.java
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 42338
diff changeset
    31
 * @run driver ModulesTest
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
import com.sun.jdi.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
import com.sun.jdi.event.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
import com.sun.jdi.request.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import java.util.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
    /********** target program **********/
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
class ModulesTarg {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
    public static void main(String[] args){
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
        System.out.println("Goodbye from ModulesTarg!");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
}
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
    /********** test program **********/
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
public class ModulesTest extends TestScaffold {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
    static final String FailPrefix = "ModulesTest: failed: ";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    private static ModuleReference bootUnnamedModule = null;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
    private static ModuleReference appUnnamedModule  = null;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    private static ModuleReference extUnnamedModule  = null;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
    private ReferenceType targetClass;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
    private List<ModuleReference> modules;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
    ModulesTest (String args[]) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
        super(args);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
    public static void main(String[] args) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        new ModulesTest(args).startTests();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
    /********** test core **********/
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
    private boolean reftypeSanityCheck(ModuleReference module, ReferenceType type) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
        ModuleReference other = type.module();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
        if (other == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
            println(FailPrefix + "a ModuleReference should never be null #1");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
            return false;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
        // Sanity checks: make sure there is no crash or exception
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
        String otherName = other.name();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        return true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
    private void checkLoaderDefinedClasses(ModuleReference module, ClassLoaderReference loader) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
        String moduleName = module.name();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
        List<ReferenceType> definedClasses = loader.definedClasses();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
        boolean origModuleWasObserved = false;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        for (ReferenceType type: definedClasses) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
            ClassLoaderReference otherLoader = type.classLoader();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
            if (!loader.equals(otherLoader)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    91
                testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    92
                println(FailPrefix + "all classes defined by a ClassLoader" +
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                        " should refer to the defining ClassLoader");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    94
                return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
            if (!reftypeSanityCheck(module, type)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    97
                return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    98
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    99
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   100
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   101
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   102
    private void checkLoaderVisibleClasses(ModuleReference module, ClassLoaderReference loader) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   103
        String moduleName = module.name();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   104
        List<ReferenceType> visibleClasses = loader.visibleClasses();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   105
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
        for (ReferenceType type: visibleClasses) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
            if (!type.isPrepared()) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
                continue; // Safety: skip unprepared classes
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   110
            if (!reftypeSanityCheck(module, type)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   111
                return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   112
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   113
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   114
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   115
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
    // Check any ClassLoader except the bootsrtap ClassLoader
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   117
    private void checkClassLoader(ModuleReference module, ClassLoaderReference loader) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   118
        checkLoaderDefinedClasses(module, loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   119
        checkLoaderVisibleClasses(module, loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   120
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   121
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   122
    // Sanity checks to make sure there are no crashes or exceptions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   123
    private void checkModule(ModuleReference module, ModuleReference other, int checkIdx) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
        if (module == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   125
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
            println(FailPrefix + "a ModuleReference should never be null #2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   127
            return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
        String name = module.name();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
        println("\n--- Check #" + checkIdx);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
        println("    module name: " + name);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   132
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   133
        ClassLoaderReference loader = module.classLoader();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   134
        println("    loader: " + loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   135
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   136
        if (loader != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   137
            checkClassLoader(module, loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   138
            String classloaderName = loader.toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   139
            if (classloaderName.contains("AppClassLoader") && name == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   140
                if (appUnnamedModule != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
                    testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
                    println(FailPrefix + "multiple unnamed modules in AppClassLoader");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
                }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
                appUnnamedModule = module;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
            if (classloaderName.contains("PlatformClassLoader") && name == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
                if (extUnnamedModule != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
                    testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
                    println(FailPrefix + "multiple unnamed modules in PlatformClassLoader");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
                }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                extUnnamedModule = module;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
        } else if (name == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
            if (bootUnnamedModule != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
                testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   156
                println(FailPrefix + "multiple unnamed modules in BootClassLoader");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   157
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   158
            bootUnnamedModule = module;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   160
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   161
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   162
    // Check that the java.lang.String class was loaded by the java.base module.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   163
    private void checkBaseModule() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   164
        List<ReferenceType> clist = vm().classesByName("java.lang.String");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   165
        if (clist.size() != 1) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   166
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   167
            println(FailPrefix + "just one java.lang.String class is expected" +
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
                    "but found multiple class instances: " + clist.size());
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   169
            return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   171
        ModuleReference module = clist.get(0).module();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   172
        if (module == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   173
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   174
            println(FailPrefix + "a ModuleReference should never be null #3");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   175
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   176
        if (module.name().compareTo("java.base") != 0) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   177
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   178
            println(FailPrefix + "java.lang.String must belong to java.base module");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   179
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   180
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   181
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   182
    // Check that the unnamed modules of the bootsrtap, application
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   183
    // and platform class loaders were observed.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   184
    private void checkUnnamedModules() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   185
        if (bootUnnamedModule == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   186
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   187
            println(FailPrefix + "unnamed module of BootClassLoader was not observed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   189
        if (appUnnamedModule == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   190
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   191
            println(FailPrefix + "unnamed module of AppClassLoader was not observed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   192
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   193
        if (extUnnamedModule == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   194
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   195
            println(FailPrefix + "unnamed module of PlatformClassLoader was not observed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   196
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   197
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   198
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   199
    protected void runTests() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   200
        /*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   201
         * Get to the top of main() to determine targetClass
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   202
         */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   203
        BreakpointEvent bpe = startToMain("ModulesTarg");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   204
        targetClass = bpe.location().declaringType();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   205
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   206
        if (!vm().canGetModuleInfo()) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   207
            testFailed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   208
            println(FailPrefix + "vm().canGetModuleInfo() returned false");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   209
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        ModuleReference other = targetClass.module();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   211
        modules = vm().allModules();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   212
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   213
        int checkIdx = 0;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   214
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   215
        for (ModuleReference module : modules) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   216
            checkModule(module, other, checkIdx++);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   217
            other = module;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   218
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   219
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   220
        checkBaseModule();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   221
        checkUnnamedModules();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   222
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   223
        /*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   224
         * resume the target until end
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   225
         */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   226
        listenUntilVMDisconnect();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   227
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   228
        /*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   229
         * deal with results of test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   230
         * if anything has called failure("foo") testFailed will be true
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   231
         */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   232
        if (!testFailed) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   233
            println("ModulesTest: passed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   234
        } else {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   235
            throw new Exception("ModulesTest: some checks failed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   236
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   237
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   238
}