Example #1
0
def java_base_unittest(args):
    """tests whether graal compiler runs on JDK9 with limited set of modules"""
    jlink = mx.exe_suffix(join(jdk.home, 'bin', 'jlink'))
    if not exists(jlink):
        raise mx.JDKConfigException('jlink tool does not exist: ' + jlink)
    basejdk_dir = join(_suite.get_output_root(), 'jdkbase')
    basemodules = 'java.base,jdk.internal.vm.ci,jdk.unsupported'
    if exists(basejdk_dir):
        shutil.rmtree(basejdk_dir)
    mx.run([jlink, '--output', basejdk_dir, '--add-modules', basemodules, '--module-path', join(jdk.home, 'jmods')])
    jdwp = mx.add_lib_suffix(mx.add_lib_prefix('jdwp'))
    shutil.copy(join(jdk.home, 'lib', jdwp), join(basejdk_dir, 'lib', jdwp))
    dt_socket = mx.add_lib_suffix(mx.add_lib_prefix('dt_socket'))
    shutil.copy(join(jdk.home, 'lib', dt_socket), join(basejdk_dir, 'lib', dt_socket))

    if not args:
        args = []

    fakeJavac = join(basejdk_dir, 'bin', 'javac')
    open(fakeJavac, 'a').close()

    basejdk = mx.JDKConfig(basejdk_dir)
    savedJava = jdk.java
    try:
        jdk.java = basejdk.java
        if mx_gate.Task.verbose:
            extra_args = ['--verbose', '--enable-timing']
        else:
            extra_args = []
        mx_unittest.unittest(['--suite', 'compiler', '--fail-fast'] + extra_args + args)
    finally:
        jdk.java = savedJava
Example #2
0
def run_jaotc(args, classpath=None, cwd=None):
    """run AOT compiler with classes in this repo instead of those in the JDK"""
    _check_jaotc_support()
    vm_args = [a for a in args if a.startswith('-J')]
    args = [a for a in args if not a.startswith('-J')]

    verbose = ['--verbose'] if mx._opts.very_verbose else []
    cp = ['-J--class-path=' + classpath] if classpath else []

    graaljdk_dir, _ = mx_compiler._update_graaljdk(mx_compiler.jdk)
    graaljdk = mx.JDKConfig(graaljdk_dir)
    jaotc_exe = graaljdk.exe_path('jaotc', 'bin')
    mx.run([jaotc_exe] + vm_args + cp + verbose + args, cwd=cwd)
Example #3
0
def run_jaotc(args, classpath=None, cwd=None):
    """run AOT compiler with classes in this repo instead of those in the JDK"""
    if jdk.javaCompliance < '11':
        mx.abort(
            'jaotc command is only available if JAVA_HOME is JDK 11 or later')

    vm_args = [a for a in args if a.startswith('-J')]
    args = [a for a in args if not a.startswith('-J')]

    verbose = ['--verbose'] if mx._opts.very_verbose else []
    cp = ['-J--class-path=' + classpath] if classpath else []

    graaljdk_dir, _ = mx_compiler._update_graaljdk(mx_compiler.jdk)
    graaljdk = mx.JDKConfig(graaljdk_dir)
    jaotc_exe = graaljdk.exe_path('jaotc', 'bin')
    mx.run([jaotc_exe] + vm_args + cp + verbose + args, cwd=cwd)