From 0be7bcd96f62d53aa9f7acd08d4ca4b8a2d572ef Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Thu, 5 Dec 2019 16:21:28 +0100 Subject: [PATCH 01/17] Remove outdated user error description --- USER_ERRORS | 5 ----- 1 file changed, 5 deletions(-) diff --git a/USER_ERRORS b/USER_ERRORS index 2cee4901..555aa166 100644 --- a/USER_ERRORS +++ b/USER_ERRORS @@ -9,8 +9,3 @@ Java process ends with SEGFAULT - HOW TO FIX: Fix the instrumentation or exclude the class causing the problem in the exclusion list (-Ddisl.exclusionList=exclusion.lst command line option of DiSL server). - -Build failure: java.lang.UnsupportedClassVersionError: ch/usi/dag/disl/utilinstr/tlvinserter/ExtendThread : Unsupported major.minor version 51.0 - - CAUSE: A version 1.7.x JRE is used; this version is not yet supported - - HOW TO FIX: Use a version 1.6.x JRE instead. - -- GitLab From 37f9f59901fec1be734dc1706f46304730bc5ef2 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Thu, 5 Dec 2019 16:25:50 +0100 Subject: [PATCH 02/17] Update jni and jvmti headers to Java 9 --- src-jdk-include/jni.h | 14 ++++- src-jdk-include/jvmti.h | 127 ++++++++++++++++++++++++++++++---------- 2 files changed, 110 insertions(+), 31 deletions(-) diff --git a/src-jdk-include/jni.h b/src-jdk-include/jni.h index 2e83cb7e..e29bf04b 100644 --- a/src-jdk-include/jni.h +++ b/src-jdk-include/jni.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -765,6 +765,11 @@ struct JNINativeInterface_ { jobjectRefType (JNICALL *GetObjectRefType) (JNIEnv* env, jobject obj); + + /* Module Features */ + + jobject (JNICALL *GetModule) + (JNIEnv* env, jclass clazz); }; /* @@ -1857,6 +1862,12 @@ struct JNIEnv_ { return functions->GetObjectRefType(this, obj); } + /* Module Features */ + + jobject GetModule(jclass clazz) { + return functions->GetModule(this, clazz); + } + #endif /* __cplusplus */ }; @@ -1952,6 +1963,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved); #define JNI_VERSION_1_4 0x00010004 #define JNI_VERSION_1_6 0x00010006 #define JNI_VERSION_1_8 0x00010008 +#define JNI_VERSION_9 0x00090000 #ifdef __cplusplus } /* extern "C" */ diff --git a/src-jdk-include/jvmti.h b/src-jdk-include/jvmti.h index ee708cb1..eb0ec927 100644 --- a/src-jdk-include/jvmti.h +++ b/src-jdk-include/jvmti.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,7 @@ * questions. */ - /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */ - + /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */ /* Include file for the Java(tm) Virtual Machine Tool Interface */ @@ -42,8 +41,9 @@ enum { JVMTI_VERSION_1_0 = 0x30010000, JVMTI_VERSION_1_1 = 0x30010100, JVMTI_VERSION_1_2 = 0x30010200, + JVMTI_VERSION_9 = 0x30090000, - JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (2 * 0x100) + 1 /* version: 1.2.1 */ + JVMTI_VERSION = 0x30000000 + (9 * 0x10000) + (0 * 0x100) + 0 /* version: 9.0.0 */ }; JNIEXPORT jint JNICALL @@ -348,6 +348,7 @@ typedef enum { JVMTI_ERROR_INVALID_METHODID = 23, JVMTI_ERROR_INVALID_LOCATION = 24, JVMTI_ERROR_INVALID_FIELDID = 25, + JVMTI_ERROR_INVALID_MODULE = 26, JVMTI_ERROR_NO_MORE_FRAMES = 31, JVMTI_ERROR_OPAQUE_FRAME = 32, JVMTI_ERROR_TYPE_MISMATCH = 34, @@ -370,6 +371,7 @@ typedef enum { JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71, JVMTI_ERROR_UNMODIFIABLE_CLASS = 79, + JVMTI_ERROR_UNMODIFIABLE_MODULE = 80, JVMTI_ERROR_NOT_AVAILABLE = 98, JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99, JVMTI_ERROR_NULL_POINTER = 100, @@ -703,7 +705,9 @@ typedef struct { unsigned int can_retransform_any_class : 1; unsigned int can_generate_resource_exhaustion_heap_events : 1; unsigned int can_generate_resource_exhaustion_threads_events : 1; - unsigned int : 7; + unsigned int can_generate_early_vmstart : 1; + unsigned int can_generate_early_class_hook_events : 1; + unsigned int : 5; unsigned int : 16; unsigned int : 16; unsigned int : 16; @@ -1011,8 +1015,10 @@ typedef struct jvmtiInterface_1_ { jthread event_thread, ...); - /* 3 : RESERVED */ - void *reserved3; + /* 3 : Get All Modules */ + jvmtiError (JNICALL *GetAllModules) (jvmtiEnv* env, + jint* module_count_ptr, + jobject** modules_ptr); /* 4 : Get All Threads */ jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv* env, @@ -1213,8 +1219,11 @@ typedef struct jvmtiInterface_1_ { jmethodID method, jlocation location); - /* 40 : RESERVED */ - void *reserved40; + /* 40 : Get Named Module */ + jvmtiError (JNICALL *GetNamedModule) (jvmtiEnv* env, + jobject class_loader, + const char* package_name, + jobject* module_ptr); /* 41 : Set Field Access Watch */ jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env, @@ -1492,23 +1501,38 @@ typedef struct jvmtiInterface_1_ { const jthread* request_list, jvmtiError* results); - /* 94 : RESERVED */ - void *reserved94; - - /* 95 : RESERVED */ - void *reserved95; - - /* 96 : RESERVED */ - void *reserved96; - - /* 97 : RESERVED */ - void *reserved97; - - /* 98 : RESERVED */ - void *reserved98; - - /* 99 : RESERVED */ - void *reserved99; + /* 94 : Add Module Reads */ + jvmtiError (JNICALL *AddModuleReads) (jvmtiEnv* env, + jobject module, + jobject to_module); + + /* 95 : Add Module Exports */ + jvmtiError (JNICALL *AddModuleExports) (jvmtiEnv* env, + jobject module, + const char* pkg_name, + jobject to_module); + + /* 96 : Add Module Opens */ + jvmtiError (JNICALL *AddModuleOpens) (jvmtiEnv* env, + jobject module, + const char* pkg_name, + jobject to_module); + + /* 97 : Add Module Uses */ + jvmtiError (JNICALL *AddModuleUses) (jvmtiEnv* env, + jobject module, + jclass service); + + /* 98 : Add Module Provides */ + jvmtiError (JNICALL *AddModuleProvides) (jvmtiEnv* env, + jobject module, + jclass service, + jclass impl_class); + + /* 99 : Is Modifiable Module */ + jvmtiError (JNICALL *IsModifiableModule) (jvmtiEnv* env, + jobject module, + jboolean* is_modifiable_module_ptr); /* 100 : Get All Stack Traces */ jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv* env, @@ -1675,7 +1699,7 @@ typedef struct jvmtiInterface_1_ { /* 132 : Set System Property */ jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv* env, const char* property, - const char* value); + const char* value_ptr); /* 133 : Get Phase */ jvmtiError (JNICALL *GetPhase) (jvmtiEnv* env, @@ -2137,6 +2161,50 @@ struct _jvmtiEnv { return functions->ClearFieldModificationWatch(this, klass, field); } + jvmtiError GetAllModules(jint* module_count_ptr, + jobject** modules_ptr) { + return functions->GetAllModules(this, module_count_ptr, modules_ptr); + } + + jvmtiError GetNamedModule(jobject class_loader, + const char* package_name, + jobject* module_ptr) { + return functions->GetNamedModule(this, class_loader, package_name, module_ptr); + } + + jvmtiError AddModuleReads(jobject module, + jobject to_module) { + return functions->AddModuleReads(this, module, to_module); + } + + jvmtiError AddModuleExports(jobject module, + const char* pkg_name, + jobject to_module) { + return functions->AddModuleExports(this, module, pkg_name, to_module); + } + + jvmtiError AddModuleOpens(jobject module, + const char* pkg_name, + jobject to_module) { + return functions->AddModuleOpens(this, module, pkg_name, to_module); + } + + jvmtiError AddModuleUses(jobject module, + jclass service) { + return functions->AddModuleUses(this, module, service); + } + + jvmtiError AddModuleProvides(jobject module, + jclass service, + jclass impl_class) { + return functions->AddModuleProvides(this, module, service, impl_class); + } + + jvmtiError IsModifiableModule(jobject module, + jboolean* is_modifiable_module_ptr) { + return functions->IsModifiableModule(this, module, is_modifiable_module_ptr); + } + jvmtiError GetLoadedClasses(jint* class_count_ptr, jclass** classes_ptr) { return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr); @@ -2484,8 +2552,8 @@ struct _jvmtiEnv { } jvmtiError SetSystemProperty(const char* property, - const char* value) { - return functions->SetSystemProperty(this, property, value); + const char* value_ptr) { + return functions->SetSystemProperty(this, property, value_ptr); } jvmtiError GetPhase(jvmtiPhase* phase_ptr) { @@ -2531,4 +2599,3 @@ struct _jvmtiEnv { #endif /* __cplusplus */ #endif /* !_JAVA_JVMTI_H_ */ - -- GitLab From e4dc612e41daad95e65f357ecdbebb6cdf0eb318 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Tue, 10 Dec 2019 02:00:25 +0100 Subject: [PATCH 03/17] dynamically patch module based on java version --- bin/disl.py | 11 +++++++ build.xml | 6 +++- .../utils/ClientServerEvaluationRunner.java | 9 ++++++ .../disl/test/utils/ClientServerRunner.java | 9 ++++++ .../ch/usi/dag/disl/test/utils/Runner.java | 32 +++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/bin/disl.py b/bin/disl.py index 6e694749..995b1e03 100755 --- a/bin/disl.py +++ b/bin/disl.py @@ -5,6 +5,7 @@ import itertools import os import platform import time +import re from subprocess import * @@ -494,6 +495,16 @@ def run_client(args, parser): else: c_cmd+= ["-Xbootclasspath/a:"+bypass+":"+args.instrumentation] + # provide options needed only for Java 9+ + java_version = subprocess.check_output(["java", '-version'], stderr=subprocess.STDOUT) + version_match = re.search('"(\d+)\.(\d+)', java_version, re.IGNORECASE) + if version_match: + version = version_match.group(1) + if version == "1": + version = version_match.group(2) + if int(version) >= 9: + c_cmd+= ["--patch-module", "java.base="+args.disl_home+"/lib/java.base"] + c_cmd+= args.c_app #print c_cmd diff --git a/build.xml b/build.xml index 966bf09d..3b67fc8c 100644 --- a/build.xml +++ b/build.xml @@ -14,6 +14,9 @@ + + + @@ -416,7 +419,7 @@ - + @@ -862,6 +865,7 @@ + diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java index 9d60b9bb..b5c77681 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java @@ -128,6 +128,15 @@ public class ClientServerEvaluationRunner extends Runner { )) )); + int javaVersion = _getJavaVersion(__CLIENT_JAVA_COMMAND__); + if (javaVersion >= 9) { + command.addAll (Arrays.asList ( + "--patch-module", String.format ( + "java.base=%s", _DISL_THREAD_DIR_ + ) + )); + } + command.addAll (propertiesStartingWith ("disl.")); command.addAll (Arrays.asList ( "-jar", appJar.toString () diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java index 9b53b342..c44d1586 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java @@ -92,6 +92,15 @@ public class ClientServerRunner extends Runner { )) )); + int javaVersion = _getJavaVersion(__CLIENT_JAVA_COMMAND__); + if (javaVersion >= 9) { + command.addAll (Arrays.asList ( + "--patch-module", String.format ( + "java.base=%s", _DISL_THREAD_DIR_ + ) + )); + } + command.addAll (propertiesStartingWith ("disl.")); command.addAll (Arrays.asList ( "-jar", testAppJar.toString () diff --git a/src-test/ch/usi/dag/disl/test/utils/Runner.java b/src-test/ch/usi/dag/disl/test/utils/Runner.java index 5ef1e1e8..9a1ca7b1 100644 --- a/src-test/ch/usi/dag/disl/test/utils/Runner.java +++ b/src-test/ch/usi/dag/disl/test/utils/Runner.java @@ -3,11 +3,16 @@ package ch.usi.dag.disl.test.utils; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import ch.usi.dag.dislreserver.DiSLREServer; import ch.usi.dag.dislserver.DiSLServer; @@ -24,6 +29,7 @@ public abstract class Runner { protected static final String _ENV_JAVA_HOME_ = "JAVA_HOME"; protected static final File _DISL_LIB_DIR_ = new File (System.getProperty ("runner.disl.lib.dir", "lib")); + protected static final File _DISL_THREAD_DIR_ = new File (System.getProperty ("runner.disl.thread.dir", "disl-thread")); protected static final File _DISL_AGENT_LIB_ = __libPath ("runner.disl.agent.lib", "libdislagent.so"); protected static final File _DISL_BYPASS_JAR_ = __libPath ("runner.disl.bypass.jar", "disl-bypass.jar"); @@ -69,6 +75,32 @@ public abstract class Runner { } } + protected static int _getJavaVersion (final String javaCommand) throws IOException { + final ProcessBuilder builder = new ProcessBuilder(javaCommand, "-version"); + builder.redirectErrorStream(true); + final Process process = builder.start(); + final InputStream is = process.getInputStream(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + + String line = null; + final StringBuilder output = new StringBuilder(); + while ((line = reader.readLine()) != null) { + output.append(line); + } + + final Pattern pattern = Pattern.compile("\\\"(\\d+)\\.(\\d+)"); + final Matcher matcher = pattern.matcher(output); + if (!matcher.find()) { + throw new RunnerException ("failed to get java version"); + } + + String version = matcher.group(1); + if (version.equals("1")) { + version = matcher.group(2); + } + + return Integer.parseInt(version); + } private static String __extractTestName (final Class testClass) { final String [] packages = testClass.getPackage ().getName ().split ("\\."); -- GitLab From 4e2e6329a8b7e66d2d9e2ea1207f51c537d40244 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Tue, 10 Dec 2019 02:30:13 +0100 Subject: [PATCH 04/17] add capability to enable class load hook in primordial phase --- build.properties | 3 ++- src-disl-agent/dislagent.c | 1 + src-shvm-agent/dislreagent.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build.properties b/build.properties index d5e8539b..eee7109c 100644 --- a/build.properties +++ b/build.properties @@ -86,5 +86,6 @@ release.src.tar=${release}/disl-${disl.version}-src.tar.bz2 target.disl.bypass=1.6 target.shvm.dispatch=1.6 -# Default Java target +# Default Java source and target +ant.build.javac.source=1.8 ant.build.javac.target=1.8 diff --git a/src-disl-agent/dislagent.c b/src-disl-agent/dislagent.c index 27e80152..4cc4c543 100644 --- a/src-disl-agent/dislagent.c +++ b/src-disl-agent/dislagent.c @@ -744,6 +744,7 @@ Agent_OnLoad (JavaVM * jvm, char * options, void * reserved) { jvmtiCapabilities caps = { .can_redefine_classes = 1, .can_generate_all_class_hook_events = 1, + .can_generate_early_class_hook_events = 1, }; jvmtiError error = (*jvmti)->AddCapabilities (jvmti, &caps); diff --git a/src-shvm-agent/dislreagent.c b/src-shvm-agent/dislreagent.c index a370d905..c54ac553 100644 --- a/src-shvm-agent/dislreagent.c +++ b/src-shvm-agent/dislreagent.c @@ -1799,12 +1799,14 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { // - all class events // - object tagging // - object free notification + // - class events in primordial phase // jvmtiCapabilities cap; memset(&cap, 0, sizeof(cap)); cap.can_generate_all_class_hook_events = TRUE; cap.can_tag_objects = TRUE; cap.can_generate_object_free_events = TRUE; + cap.can_generate_early_class_hook_events = TRUE; jvmtiError error; error = (*jvmti_env)->AddCapabilities(jvmti_env, &cap); -- GitLab From 3e2ba5e45fa41bd8902630870b1534d225c60a48 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Tue, 10 Dec 2019 16:19:04 +0100 Subject: [PATCH 05/17] fix java 8 --- src-disl-agent/dislagent.c | 17 +++++++++++++++-- src-shvm-agent/dislreagent.c | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src-disl-agent/dislagent.c b/src-disl-agent/dislagent.c index 4cc4c543..d1dfa4b3 100644 --- a/src-disl-agent/dislagent.c +++ b/src-disl-agent/dislagent.c @@ -744,10 +744,23 @@ Agent_OnLoad (JavaVM * jvm, char * options, void * reserved) { jvmtiCapabilities caps = { .can_redefine_classes = 1, .can_generate_all_class_hook_events = 1, - .can_generate_early_class_hook_events = 1, }; - jvmtiError error = (*jvmti)->AddCapabilities (jvmti, &caps); + // + // Add class events in primordial phase only if available + // i.e. in Java9+ + // + jvmtiError error; + jvmtiCapabilities potentialCapabilities; + error = (*jvmti)->GetPotentialCapabilities(jvmti, &potentialCapabilities); + check_jvmti_error(jvmti, error, + "Unable to get potential JVMTI capabilities."); + + if(potentialCapabilities.can_generate_early_class_hook_events) { + caps.can_generate_early_class_hook_events = 1; + } + + error = (*jvmti)->AddCapabilities (jvmti, &caps); check_jvmti_error (jvmti, error, "failed to add capabilities"); diff --git a/src-shvm-agent/dislreagent.c b/src-shvm-agent/dislreagent.c index c54ac553..e7776f8c 100644 --- a/src-shvm-agent/dislreagent.c +++ b/src-shvm-agent/dislreagent.c @@ -1799,16 +1799,27 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { // - all class events // - object tagging // - object free notification - // - class events in primordial phase // jvmtiCapabilities cap; memset(&cap, 0, sizeof(cap)); cap.can_generate_all_class_hook_events = TRUE; cap.can_tag_objects = TRUE; cap.can_generate_object_free_events = TRUE; - cap.can_generate_early_class_hook_events = TRUE; + // + // Add class events in primordial phase only if available + // i.e. in Java9+ + // jvmtiError error; + jvmtiCapabilities potentialCapabilities; + error = (*jvmti_env)->GetPotentialCapabilities(jvmti_env, &potentialCapabilities); + check_jvmti_error(jvmti_env, error, + "Unable to get potential JVMTI capabilities."); + + if(potentialCapabilities.can_generate_early_class_hook_events) { + cap.can_generate_early_class_hook_events = TRUE; + } + error = (*jvmti_env)->AddCapabilities(jvmti_env, &cap); check_jvmti_error(jvmti_env, error, "Unable to get necessary JVMTI capabilities."); -- GitLab From 198d39bcc78a6f7a81e91735d28aa54538c27ac5 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Tue, 7 Jan 2020 18:49:47 +0100 Subject: [PATCH 06/17] Change default Java source and target to the ones of the host machine --- build.properties | 8 -------- build.xml | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/build.properties b/build.properties index eee7109c..5c4571e2 100644 --- a/build.properties +++ b/build.properties @@ -81,11 +81,3 @@ release.bin.zip=${release}/disl-${disl.version}-bin.zip release.bin.tar=${release}/disl-${disl.version}-bin.tar.bz2 release.src.zip=${release}/disl-${disl.version}-src.zip release.src.tar=${release}/disl-${disl.version}-src.tar.bz2 - -# Java versions for specific components -target.disl.bypass=1.6 -target.shvm.dispatch=1.6 - -# Default Java source and target -ant.build.javac.source=1.8 -ant.build.javac.target=1.8 diff --git a/build.xml b/build.xml index 3b67fc8c..b9bbc8d8 100644 --- a/build.xml +++ b/build.xml @@ -418,7 +418,7 @@ - + @@ -653,7 +653,7 @@ - + -- GitLab From dc9bb1436abc94e4b83a7f25b3082f4090ad3a82 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Tue, 7 Jan 2020 19:59:49 +0100 Subject: [PATCH 07/17] Add Java 9 to CI --- .gitlab-ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3517df8c..b750c6b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,24 @@ -image: gitlab.ow2.org:4567/disl/disl/disl-ci +image: &image-java-8 gitlab.ow2.org:4567/disl/disl/disl-ci +image: &image-java-9 mbasso/disl-ci # Setup cache to prevent downloading deps and compiling sources in each stage cache: &cache - # Cache is branch-local - key: "${CI_COMMIT_REF_SLUG}" # Cache deps and compiled classes paths: - 'output/' - 'lib/' - 'src-disl-agent/linux-x86_64' # Specific architecture of used container +# Caches for different Java versions +cache: &cache-8 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-8" + +cache: &cache-9 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-9" + + # Adjust modification date to prevent recompiling sources in different stages. before_script: - find . -exec touch -t 200001010000 {} \; @@ -22,20 +31,43 @@ stages: # The YAML Anchors are used because of Gitlab Issue#2838 # Check whether the build task succeeded -build: +.build: stage: build + script: + - ant build + +build-8: + image: *image-java-8 + extends: .build cache: - <<: *cache + <<: *cache-8 + policy: + push + +build-9: + image: *image-java-9 + extends: .build + cache: + <<: *cache-9 policy: push - script: - - ant build # Run tests -test: +.test: stage: test - cache: - <<: *cache - policy: pull script: - ant test + +test-8: + image: *image-java-8 + extends: .test + cache: + <<: *cache-8 + policy: pull + +test-9: + image: *image-java-9 + extends: .test + cache: + <<: *cache-9 + policy: pull -- GitLab From b735f933b2f2a8227fcf6a810630564f56edc41d Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Tue, 7 Jan 2020 22:00:15 +0100 Subject: [PATCH 08/17] fix ant build.xml --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index b9bbc8d8..79cbf4e9 100644 --- a/build.xml +++ b/build.xml @@ -419,7 +419,7 @@ - + -- GitLab From a600f867901cc82c7a1b5b742f5d6f99043016d0 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Wed, 8 Jan 2020 00:11:41 +0100 Subject: [PATCH 09/17] change protobuf-javalite to protobuf-java --- .classpath | 2 +- dependencies.properties | 2 +- lib/artifacts.lst | 2 +- src-disl/ch/usi/dag/dislserver/Protocol.java | 1419 +++++++++++++----- 4 files changed, 1024 insertions(+), 401 deletions(-) diff --git a/.classpath b/.classpath index 3a4499b6..bb6aceea 100644 --- a/.classpath +++ b/.classpath @@ -15,6 +15,6 @@ - + diff --git a/dependencies.properties b/dependencies.properties index bbff0284..807b3679 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -14,4 +14,4 @@ log4j.org=log4j protobuf.rev=3.11.0 protobuf.org=com.google.protobuf -protobuf.lib=protobuf-javalite +protobuf.lib=protobuf-java diff --git a/lib/artifacts.lst b/lib/artifacts.lst index 3b577097..e5c8918e 100644 --- a/lib/artifacts.lst +++ b/lib/artifacts.lst @@ -6,6 +6,6 @@ lib/disl/asm-tree.jar lib/disl/asm-util.jar lib/disl/asm.jar lib/disl/log4j.jar -lib/disl/protobuf-javalite.jar +lib/disl/protobuf-java.jar lib/test/hamcrest-core.jar lib/test/junit.jar diff --git a/src-disl/ch/usi/dag/dislserver/Protocol.java b/src-disl/ch/usi/dag/dislserver/Protocol.java index 04decac7..02ef7c22 100644 --- a/src-disl/ch/usi/dag/dislserver/Protocol.java +++ b/src-disl/ch/usi/dag/dislserver/Protocol.java @@ -8,11 +8,17 @@ public final class Protocol { public static void registerAllExtensions( com.google.protobuf.ExtensionRegistryLite registry) { } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } /** * Protobuf enum {@code InstrumentClassResult} */ public enum InstrumentClassResult - implements com.google.protobuf.Internal.EnumLite { + implements com.google.protobuf.ProtocolMessageEnum { /** * CLASS_UNMODIFIED = 0; */ @@ -42,7 +48,6 @@ public final class Protocol { public static final int ERROR_VALUE = 3; - @java.lang.Override public final int getNumber() { if (this == UNRECOGNIZED) { throw new java.lang.IllegalArgumentException( @@ -52,8 +57,8 @@ public final class Protocol { } /** - * @param value The number of the enum to look for. - * @return The enum associated with the given number. + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. * @deprecated Use {@link #forNumber(int)} instead. */ @java.lang.Deprecated @@ -61,6 +66,10 @@ public final class Protocol { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static InstrumentClassResult forNumber(int value) { switch (value) { case 0: return CLASS_UNMODIFIED; @@ -77,25 +86,37 @@ public final class Protocol { private static final com.google.protobuf.Internal.EnumLiteMap< InstrumentClassResult> internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { - @java.lang.Override public InstrumentClassResult findValueByNumber(int number) { return InstrumentClassResult.forNumber(number); } }; - public static com.google.protobuf.Internal.EnumVerifier - internalGetVerifier() { - return InstrumentClassResultVerifier.INSTANCE; + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return ch.usi.dag.dislserver.Protocol.getDescriptor().getEnumTypes().get(0); } - private static final class InstrumentClassResultVerifier implements - com.google.protobuf.Internal.EnumVerifier { - static final com.google.protobuf.Internal.EnumVerifier INSTANCE = new InstrumentClassResultVerifier(); - @java.lang.Override - public boolean isInRange(int number) { - return InstrumentClassResult.forNumber(number) != null; - } - }; + private static final InstrumentClassResult[] VALUES = values(); + + public static InstrumentClassResult valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } private final int value; @@ -108,7 +129,7 @@ public final class Protocol { public interface InstrumentClassRequestOrBuilder extends // @@protoc_insertion_point(interface_extends:InstrumentClassRequest) - com.google.protobuf.MessageLiteOrBuilder { + com.google.protobuf.MessageOrBuilder { /** * int32 flags = 1; @@ -138,90 +159,141 @@ public final class Protocol { * Protobuf type {@code InstrumentClassRequest} */ public static final class InstrumentClassRequest extends - com.google.protobuf.GeneratedMessageLite< - InstrumentClassRequest, InstrumentClassRequest.Builder> implements + com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:InstrumentClassRequest) InstrumentClassRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use InstrumentClassRequest.newBuilder() to construct. + private InstrumentClassRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } private InstrumentClassRequest() { className_ = ""; classBytes_ = com.google.protobuf.ByteString.EMPTY; } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new InstrumentClassRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private InstrumentClassRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + flags_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + className_ = s; + break; + } + case 26: { + + classBytes_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.class, ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.Builder.class); + } + public static final int FLAGS_FIELD_NUMBER = 1; private int flags_; /** * int32 flags = 1; * @return The flags. */ - @java.lang.Override public int getFlags() { return flags_; } - /** - * int32 flags = 1; - * @param value The flags to set. - */ - private void setFlags(int value) { - - flags_ = value; - } - /** - * int32 flags = 1; - */ - private void clearFlags() { - - flags_ = 0; - } public static final int CLASSNAME_FIELD_NUMBER = 2; - private java.lang.String className_; + private volatile java.lang.Object className_; /** * string className = 2; * @return The className. */ - @java.lang.Override public java.lang.String getClassName() { - return className_; + java.lang.Object ref = className_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + className_ = s; + return s; + } } /** * string className = 2; * @return The bytes for className. */ - @java.lang.Override public com.google.protobuf.ByteString getClassNameBytes() { - return com.google.protobuf.ByteString.copyFromUtf8(className_); - } - /** - * string className = 2; - * @param value The className to set. - */ - private void setClassName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - className_ = value; - } - /** - * string className = 2; - */ - private void clearClassName() { - - className_ = getDefaultInstance().getClassName(); - } - /** - * string className = 2; - * @param value The bytes for className to set. - */ - private void setClassNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - className_ = value.toStringUtf8(); + java.lang.Object ref = className_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + className_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } public static final int CLASSBYTES_FIELD_NUMBER = 3; @@ -230,131 +302,353 @@ public final class Protocol { * bytes classBytes = 3; * @return The classBytes. */ - @java.lang.Override public com.google.protobuf.ByteString getClassBytes() { return classBytes_; } - /** - * bytes classBytes = 3; - * @param value The classBytes to set. - */ - private void setClassBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - classBytes_ = value; + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; } - /** - * bytes classBytes = 3; - */ - private void clearClassBytes() { - - classBytes_ = getDefaultInstance().getClassBytes(); + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (flags_ != 0) { + output.writeInt32(1, flags_); + } + if (!getClassNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, className_); + } + if (!classBytes_.isEmpty()) { + output.writeBytes(3, classBytes_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (flags_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, flags_); + } + if (!getClassNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, className_); + } + if (!classBytes_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, classBytes_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ch.usi.dag.dislserver.Protocol.InstrumentClassRequest)) { + return super.equals(obj); + } + ch.usi.dag.dislserver.Protocol.InstrumentClassRequest other = (ch.usi.dag.dislserver.Protocol.InstrumentClassRequest) obj; + + if (getFlags() + != other.getFlags()) return false; + if (!getClassName() + .equals(other.getClassName())) return false; + if (!getClassBytes() + .equals(other.getClassBytes())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FLAGS_FIELD_NUMBER; + hash = (53 * hash) + getFlags(); + hash = (37 * hash) + CLASSNAME_FIELD_NUMBER; + hash = (53 * hash) + getClassName().hashCode(); + hash = (37 * hash) + CLASSBYTES_FIELD_NUMBER; + hash = (53 * hash) + getClassBytes().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); + return PARSER.parseFrom(data); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); + return PARSER.parseFrom(data, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); + return PARSER.parseFrom(data); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); + return PARSER.parseFrom(data, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); + return PARSER.parseFrom(data); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); + return PARSER.parseFrom(data, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input, extensionRegistry); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return parseDelimitedFrom(DEFAULT_INSTANCE, input); + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input, extensionRegistry); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); } + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { - return (Builder) DEFAULT_INSTANCE.createBuilder(); + return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(ch.usi.dag.dislserver.Protocol.InstrumentClassRequest prototype) { - return (Builder) DEFAULT_INSTANCE.createBuilder(prototype); + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); } + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code InstrumentClassRequest} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - ch.usi.dag.dislserver.Protocol.InstrumentClassRequest, Builder> implements + com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:InstrumentClassRequest) ch.usi.dag.dislserver.Protocol.InstrumentClassRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.class, ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.Builder.class); + } + // Construct using ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.newBuilder() private Builder() { - super(DEFAULT_INSTANCE); + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + flags_ = 0; + + className_ = ""; + + classBytes_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassRequest_descriptor; } + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassRequest getDefaultInstanceForType() { + return ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.getDefaultInstance(); + } + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassRequest build() { + ch.usi.dag.dislserver.Protocol.InstrumentClassRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassRequest buildPartial() { + ch.usi.dag.dislserver.Protocol.InstrumentClassRequest result = new ch.usi.dag.dislserver.Protocol.InstrumentClassRequest(this); + result.flags_ = flags_; + result.className_ = className_; + result.classBytes_ = classBytes_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof ch.usi.dag.dislserver.Protocol.InstrumentClassRequest) { + return mergeFrom((ch.usi.dag.dislserver.Protocol.InstrumentClassRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ch.usi.dag.dislserver.Protocol.InstrumentClassRequest other) { + if (other == ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.getDefaultInstance()) return this; + if (other.getFlags() != 0) { + setFlags(other.getFlags()); + } + if (!other.getClassName().isEmpty()) { + className_ = other.className_; + onChanged(); + } + if (other.getClassBytes() != com.google.protobuf.ByteString.EMPTY) { + setClassBytes(other.getClassBytes()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ch.usi.dag.dislserver.Protocol.InstrumentClassRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (ch.usi.dag.dislserver.Protocol.InstrumentClassRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int flags_ ; /** * int32 flags = 1; * @return The flags. */ - @java.lang.Override public int getFlags() { - return instance.getFlags(); + return flags_; } /** * int32 flags = 1; @@ -362,8 +656,9 @@ public final class Protocol { * @return This builder for chaining. */ public Builder setFlags(int value) { - copyOnWrite(); - instance.setFlags(value); + + flags_ = value; + onChanged(); return this; } /** @@ -371,27 +666,45 @@ public final class Protocol { * @return This builder for chaining. */ public Builder clearFlags() { - copyOnWrite(); - instance.clearFlags(); + + flags_ = 0; + onChanged(); return this; } + private java.lang.Object className_ = ""; /** * string className = 2; * @return The className. */ - @java.lang.Override public java.lang.String getClassName() { - return instance.getClassName(); + java.lang.Object ref = className_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + className_ = s; + return s; + } else { + return (java.lang.String) ref; + } } /** * string className = 2; * @return The bytes for className. */ - @java.lang.Override public com.google.protobuf.ByteString getClassNameBytes() { - return instance.getClassNameBytes(); + java.lang.Object ref = className_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + className_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } /** * string className = 2; @@ -400,8 +713,12 @@ public final class Protocol { */ public Builder setClassName( java.lang.String value) { - copyOnWrite(); - instance.setClassName(value); + if (value == null) { + throw new NullPointerException(); + } + + className_ = value; + onChanged(); return this; } /** @@ -409,8 +726,9 @@ public final class Protocol { * @return This builder for chaining. */ public Builder clearClassName() { - copyOnWrite(); - instance.clearClassName(); + + className_ = getDefaultInstance().getClassName(); + onChanged(); return this; } /** @@ -420,18 +738,23 @@ public final class Protocol { */ public Builder setClassNameBytes( com.google.protobuf.ByteString value) { - copyOnWrite(); - instance.setClassNameBytes(value); + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + className_ = value; + onChanged(); return this; } + private com.google.protobuf.ByteString classBytes_ = com.google.protobuf.ByteString.EMPTY; /** * bytes classBytes = 3; * @return The classBytes. */ - @java.lang.Override public com.google.protobuf.ByteString getClassBytes() { - return instance.getClassBytes(); + return classBytes_; } /** * bytes classBytes = 3; @@ -439,8 +762,12 @@ public final class Protocol { * @return This builder for chaining. */ public Builder setClassBytes(com.google.protobuf.ByteString value) { - copyOnWrite(); - instance.setClassBytes(value); + if (value == null) { + throw new NullPointerException(); + } + + classBytes_ = value; + onChanged(); return this; } /** @@ -448,91 +775,67 @@ public final class Protocol { * @return This builder for chaining. */ public Builder clearClassBytes() { - copyOnWrite(); - instance.clearClassBytes(); + + classBytes_ = getDefaultInstance().getClassBytes(); + onChanged(); return this; } - - // @@protoc_insertion_point(builder_scope:InstrumentClassRequest) - } - @java.lang.Override - @java.lang.SuppressWarnings({"unchecked", "fallthrough"}) - protected final java.lang.Object dynamicMethod( - com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, - java.lang.Object arg0, java.lang.Object arg1) { - switch (method) { - case NEW_MUTABLE_INSTANCE: { - return new ch.usi.dag.dislserver.Protocol.InstrumentClassRequest(); - } - case NEW_BUILDER: { - return new Builder(); - } - case BUILD_MESSAGE_INFO: { - java.lang.Object[] objects = new java.lang.Object[] { - "flags_", - "className_", - "classBytes_", - }; - java.lang.String info = - "\u0000\u0003\u0000\u0000\u0001\u0003\u0003\u0000\u0000\u0000\u0001\u0004\u0002\u0208" + - "\u0003\n"; - return newMessageInfo(DEFAULT_INSTANCE, info, objects); - } - // fall through - case GET_DEFAULT_INSTANCE: { - return DEFAULT_INSTANCE; - } - case GET_PARSER: { - com.google.protobuf.Parser parser = PARSER; - if (parser == null) { - synchronized (ch.usi.dag.dislserver.Protocol.InstrumentClassRequest.class) { - parser = PARSER; - if (parser == null) { - parser = - new DefaultInstanceBasedParser( - DEFAULT_INSTANCE); - PARSER = parser; - } - } - } - return parser; - } - case GET_MEMOIZED_IS_INITIALIZED: { - return (byte) 1; - } - case SET_MEMOIZED_IS_INITIALIZED: { - return null; + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - throw new UnsupportedOperationException(); - } + // @@protoc_insertion_point(builder_scope:InstrumentClassRequest) + } + // @@protoc_insertion_point(class_scope:InstrumentClassRequest) private static final ch.usi.dag.dislserver.Protocol.InstrumentClassRequest DEFAULT_INSTANCE; static { - InstrumentClassRequest defaultInstance = new InstrumentClassRequest(); - // New instances are implicitly immutable so no need to make - // immutable. - DEFAULT_INSTANCE = defaultInstance; - com.google.protobuf.GeneratedMessageLite.registerDefaultInstance( - InstrumentClassRequest.class, defaultInstance); + DEFAULT_INSTANCE = new ch.usi.dag.dislserver.Protocol.InstrumentClassRequest(); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassRequest getDefaultInstance() { return DEFAULT_INSTANCE; } - private static volatile com.google.protobuf.Parser PARSER; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public InstrumentClassRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new InstrumentClassRequest(input, extensionRegistry); + } + }; public static com.google.protobuf.Parser parser() { - return DEFAULT_INSTANCE.getParserForType(); + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; } + + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } public interface InstrumentClassResponseOrBuilder extends // @@protoc_insertion_point(interface_extends:InstrumentClassResponse) - com.google.protobuf.MessageLiteOrBuilder { + com.google.protobuf.MessageOrBuilder { /** * .InstrumentClassResult result = 1; @@ -567,21 +870,105 @@ public final class Protocol { * Protobuf type {@code InstrumentClassResponse} */ public static final class InstrumentClassResponse extends - com.google.protobuf.GeneratedMessageLite< - InstrumentClassResponse, InstrumentClassResponse.Builder> implements + com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:InstrumentClassResponse) InstrumentClassResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use InstrumentClassResponse.newBuilder() to construct. + private InstrumentClassResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } private InstrumentClassResponse() { + result_ = 0; errorMessage_ = ""; classBytes_ = com.google.protobuf.ByteString.EMPTY; } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new InstrumentClassResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private InstrumentClassResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + int rawValue = input.readEnum(); + + result_ = rawValue; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + errorMessage_ = s; + break; + } + case 26: { + + classBytes_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.class, ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.Builder.class); + } + public static final int RESULT_FIELD_NUMBER = 1; private int result_; /** * .InstrumentClassResult result = 1; * @return The enum numeric value on the wire for result. */ - @java.lang.Override public int getResultValue() { return result_; } @@ -589,87 +976,46 @@ public final class Protocol { * .InstrumentClassResult result = 1; * @return The result. */ - @java.lang.Override public ch.usi.dag.dislserver.Protocol.InstrumentClassResult getResult() { - ch.usi.dag.dislserver.Protocol.InstrumentClassResult result = ch.usi.dag.dislserver.Protocol.InstrumentClassResult.forNumber(result_); + @SuppressWarnings("deprecation") + ch.usi.dag.dislserver.Protocol.InstrumentClassResult result = ch.usi.dag.dislserver.Protocol.InstrumentClassResult.valueOf(result_); return result == null ? ch.usi.dag.dislserver.Protocol.InstrumentClassResult.UNRECOGNIZED : result; } - /** - * .InstrumentClassResult result = 1; - * @param value The enum numeric value on the wire for result to set. - */ - private void setResultValue(int value) { - result_ = value; - } - /** - * .InstrumentClassResult result = 1; - * @param value The result to set. - */ - private void setResult(ch.usi.dag.dislserver.Protocol.InstrumentClassResult value) { - if (value == null) { - throw new NullPointerException(); - } - - result_ = value.getNumber(); - } - /** - * .InstrumentClassResult result = 1; - */ - private void clearResult() { - - result_ = 0; - } public static final int ERRORMESSAGE_FIELD_NUMBER = 2; - private java.lang.String errorMessage_; + private volatile java.lang.Object errorMessage_; /** * string errorMessage = 2; * @return The errorMessage. */ - @java.lang.Override public java.lang.String getErrorMessage() { - return errorMessage_; + java.lang.Object ref = errorMessage_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + errorMessage_ = s; + return s; + } } /** * string errorMessage = 2; * @return The bytes for errorMessage. */ - @java.lang.Override public com.google.protobuf.ByteString getErrorMessageBytes() { - return com.google.protobuf.ByteString.copyFromUtf8(errorMessage_); - } - /** - * string errorMessage = 2; - * @param value The errorMessage to set. - */ - private void setErrorMessage( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - errorMessage_ = value; - } - /** - * string errorMessage = 2; - */ - private void clearErrorMessage() { - - errorMessage_ = getDefaultInstance().getErrorMessage(); - } - /** - * string errorMessage = 2; - * @param value The bytes for errorMessage to set. - */ - private void setErrorMessageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - errorMessage_ = value.toStringUtf8(); + java.lang.Object ref = errorMessage_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + errorMessage_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } public static final int CLASSBYTES_FIELD_NUMBER = 3; @@ -678,158 +1024,384 @@ public final class Protocol { * bytes classBytes = 3; * @return The classBytes. */ - @java.lang.Override public com.google.protobuf.ByteString getClassBytes() { return classBytes_; } - /** - * bytes classBytes = 3; - * @param value The classBytes to set. - */ - private void setClassBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - classBytes_ = value; + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; } - /** - * bytes classBytes = 3; - */ - private void clearClassBytes() { - - classBytes_ = getDefaultInstance().getClassBytes(); + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (result_ != ch.usi.dag.dislserver.Protocol.InstrumentClassResult.CLASS_UNMODIFIED.getNumber()) { + output.writeEnum(1, result_); + } + if (!getErrorMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, errorMessage_); + } + if (!classBytes_.isEmpty()) { + output.writeBytes(3, classBytes_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (result_ != ch.usi.dag.dislserver.Protocol.InstrumentClassResult.CLASS_UNMODIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, result_); + } + if (!getErrorMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, errorMessage_); + } + if (!classBytes_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, classBytes_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ch.usi.dag.dislserver.Protocol.InstrumentClassResponse)) { + return super.equals(obj); + } + ch.usi.dag.dislserver.Protocol.InstrumentClassResponse other = (ch.usi.dag.dislserver.Protocol.InstrumentClassResponse) obj; + + if (result_ != other.result_) return false; + if (!getErrorMessage() + .equals(other.getErrorMessage())) return false; + if (!getClassBytes() + .equals(other.getClassBytes())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + result_; + hash = (37 * hash) + ERRORMESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getErrorMessage().hashCode(); + hash = (37 * hash) + CLASSBYTES_FIELD_NUMBER; + hash = (53 * hash) + getClassBytes().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); + return PARSER.parseFrom(data); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); + return PARSER.parseFrom(data, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); + return PARSER.parseFrom(data); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); + return PARSER.parseFrom(data, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); + return PARSER.parseFrom(data); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); + return PARSER.parseFrom(data, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input, extensionRegistry); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return parseDelimitedFrom(DEFAULT_INSTANCE, input); + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input, extensionRegistry); + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); } + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { - return (Builder) DEFAULT_INSTANCE.createBuilder(); + return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(ch.usi.dag.dislserver.Protocol.InstrumentClassResponse prototype) { - return (Builder) DEFAULT_INSTANCE.createBuilder(prototype); + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); } + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } /** * Protobuf type {@code InstrumentClassResponse} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - ch.usi.dag.dislserver.Protocol.InstrumentClassResponse, Builder> implements + com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:InstrumentClassResponse) ch.usi.dag.dislserver.Protocol.InstrumentClassResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.class, ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.Builder.class); + } + // Construct using ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.newBuilder() private Builder() { - super(DEFAULT_INSTANCE); + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + result_ = 0; + + errorMessage_ = ""; + + classBytes_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return ch.usi.dag.dislserver.Protocol.internal_static_InstrumentClassResponse_descriptor; + } + + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassResponse getDefaultInstanceForType() { + return ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.getDefaultInstance(); + } + + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassResponse build() { + ch.usi.dag.dislserver.Protocol.InstrumentClassResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; } + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassResponse buildPartial() { + ch.usi.dag.dislserver.Protocol.InstrumentClassResponse result = new ch.usi.dag.dislserver.Protocol.InstrumentClassResponse(this); + result.result_ = result_; + result.errorMessage_ = errorMessage_; + result.classBytes_ = classBytes_; + onBuilt(); + return result; + } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof ch.usi.dag.dislserver.Protocol.InstrumentClassResponse) { + return mergeFrom((ch.usi.dag.dislserver.Protocol.InstrumentClassResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ch.usi.dag.dislserver.Protocol.InstrumentClassResponse other) { + if (other == ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.getDefaultInstance()) return this; + if (other.result_ != 0) { + setResultValue(other.getResultValue()); + } + if (!other.getErrorMessage().isEmpty()) { + errorMessage_ = other.errorMessage_; + onChanged(); + } + if (other.getClassBytes() != com.google.protobuf.ByteString.EMPTY) { + setClassBytes(other.getClassBytes()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ch.usi.dag.dislserver.Protocol.InstrumentClassResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (ch.usi.dag.dislserver.Protocol.InstrumentClassResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int result_ = 0; /** * .InstrumentClassResult result = 1; * @return The enum numeric value on the wire for result. */ - @java.lang.Override public int getResultValue() { - return instance.getResultValue(); + return result_; } /** * .InstrumentClassResult result = 1; - * @param value The result to set. + * @param value The enum numeric value on the wire for result to set. * @return This builder for chaining. */ public Builder setResultValue(int value) { - copyOnWrite(); - instance.setResultValue(value); + result_ = value; + onChanged(); return this; } /** * .InstrumentClassResult result = 1; * @return The result. */ - @java.lang.Override public ch.usi.dag.dislserver.Protocol.InstrumentClassResult getResult() { - return instance.getResult(); + @SuppressWarnings("deprecation") + ch.usi.dag.dislserver.Protocol.InstrumentClassResult result = ch.usi.dag.dislserver.Protocol.InstrumentClassResult.valueOf(result_); + return result == null ? ch.usi.dag.dislserver.Protocol.InstrumentClassResult.UNRECOGNIZED : result; } /** * .InstrumentClassResult result = 1; - * @param value The enum numeric value on the wire for result to set. + * @param value The result to set. * @return This builder for chaining. */ public Builder setResult(ch.usi.dag.dislserver.Protocol.InstrumentClassResult value) { - copyOnWrite(); - instance.setResult(value); + if (value == null) { + throw new NullPointerException(); + } + + result_ = value.getNumber(); + onChanged(); return this; } /** @@ -837,27 +1409,45 @@ public final class Protocol { * @return This builder for chaining. */ public Builder clearResult() { - copyOnWrite(); - instance.clearResult(); + + result_ = 0; + onChanged(); return this; } + private java.lang.Object errorMessage_ = ""; /** * string errorMessage = 2; * @return The errorMessage. */ - @java.lang.Override public java.lang.String getErrorMessage() { - return instance.getErrorMessage(); + java.lang.Object ref = errorMessage_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + errorMessage_ = s; + return s; + } else { + return (java.lang.String) ref; + } } /** * string errorMessage = 2; * @return The bytes for errorMessage. */ - @java.lang.Override public com.google.protobuf.ByteString getErrorMessageBytes() { - return instance.getErrorMessageBytes(); + java.lang.Object ref = errorMessage_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + errorMessage_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } /** * string errorMessage = 2; @@ -866,8 +1456,12 @@ public final class Protocol { */ public Builder setErrorMessage( java.lang.String value) { - copyOnWrite(); - instance.setErrorMessage(value); + if (value == null) { + throw new NullPointerException(); + } + + errorMessage_ = value; + onChanged(); return this; } /** @@ -875,8 +1469,9 @@ public final class Protocol { * @return This builder for chaining. */ public Builder clearErrorMessage() { - copyOnWrite(); - instance.clearErrorMessage(); + + errorMessage_ = getDefaultInstance().getErrorMessage(); + onChanged(); return this; } /** @@ -886,18 +1481,23 @@ public final class Protocol { */ public Builder setErrorMessageBytes( com.google.protobuf.ByteString value) { - copyOnWrite(); - instance.setErrorMessageBytes(value); + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + errorMessage_ = value; + onChanged(); return this; } + private com.google.protobuf.ByteString classBytes_ = com.google.protobuf.ByteString.EMPTY; /** * bytes classBytes = 3; * @return The classBytes. */ - @java.lang.Override public com.google.protobuf.ByteString getClassBytes() { - return instance.getClassBytes(); + return classBytes_; } /** * bytes classBytes = 3; @@ -905,8 +1505,12 @@ public final class Protocol { * @return This builder for chaining. */ public Builder setClassBytes(com.google.protobuf.ByteString value) { - copyOnWrite(); - instance.setClassBytes(value); + if (value == null) { + throw new NullPointerException(); + } + + classBytes_ = value; + onChanged(); return this; } /** @@ -914,90 +1518,109 @@ public final class Protocol { * @return This builder for chaining. */ public Builder clearClassBytes() { - copyOnWrite(); - instance.clearClassBytes(); + + classBytes_ = getDefaultInstance().getClassBytes(); + onChanged(); return this; } - - // @@protoc_insertion_point(builder_scope:InstrumentClassResponse) - } - @java.lang.Override - @java.lang.SuppressWarnings({"unchecked", "fallthrough"}) - protected final java.lang.Object dynamicMethod( - com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, - java.lang.Object arg0, java.lang.Object arg1) { - switch (method) { - case NEW_MUTABLE_INSTANCE: { - return new ch.usi.dag.dislserver.Protocol.InstrumentClassResponse(); - } - case NEW_BUILDER: { - return new Builder(); - } - case BUILD_MESSAGE_INFO: { - java.lang.Object[] objects = new java.lang.Object[] { - "result_", - "errorMessage_", - "classBytes_", - }; - java.lang.String info = - "\u0000\u0003\u0000\u0000\u0001\u0003\u0003\u0000\u0000\u0000\u0001\f\u0002\u0208" + - "\u0003\n"; - return newMessageInfo(DEFAULT_INSTANCE, info, objects); - } - // fall through - case GET_DEFAULT_INSTANCE: { - return DEFAULT_INSTANCE; - } - case GET_PARSER: { - com.google.protobuf.Parser parser = PARSER; - if (parser == null) { - synchronized (ch.usi.dag.dislserver.Protocol.InstrumentClassResponse.class) { - parser = PARSER; - if (parser == null) { - parser = - new DefaultInstanceBasedParser( - DEFAULT_INSTANCE); - PARSER = parser; - } - } - } - return parser; - } - case GET_MEMOIZED_IS_INITIALIZED: { - return (byte) 1; - } - case SET_MEMOIZED_IS_INITIALIZED: { - return null; + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - throw new UnsupportedOperationException(); - } + // @@protoc_insertion_point(builder_scope:InstrumentClassResponse) + } + // @@protoc_insertion_point(class_scope:InstrumentClassResponse) private static final ch.usi.dag.dislserver.Protocol.InstrumentClassResponse DEFAULT_INSTANCE; static { - InstrumentClassResponse defaultInstance = new InstrumentClassResponse(); - // New instances are implicitly immutable so no need to make - // immutable. - DEFAULT_INSTANCE = defaultInstance; - com.google.protobuf.GeneratedMessageLite.registerDefaultInstance( - InstrumentClassResponse.class, defaultInstance); + DEFAULT_INSTANCE = new ch.usi.dag.dislserver.Protocol.InstrumentClassResponse(); } public static ch.usi.dag.dislserver.Protocol.InstrumentClassResponse getDefaultInstance() { return DEFAULT_INSTANCE; } - private static volatile com.google.protobuf.Parser PARSER; + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public InstrumentClassResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new InstrumentClassResponse(input, extensionRegistry); + } + }; public static com.google.protobuf.Parser parser() { - return DEFAULT_INSTANCE.getParserForType(); + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; } + + @java.lang.Override + public ch.usi.dag.dislserver.Protocol.InstrumentClassResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_InstrumentClassRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_InstrumentClassRequest_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_InstrumentClassResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_InstrumentClassResponse_fieldAccessorTable; + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; static { + java.lang.String[] descriptorData = { + "\n\020dislserver.proto\"N\n\026InstrumentClassReq" + + "uest\022\r\n\005flags\030\001 \001(\005\022\021\n\tclassName\030\002 \001(\t\022\022" + + "\n\nclassBytes\030\003 \001(\014\"k\n\027InstrumentClassRes" + + "ponse\022&\n\006result\030\001 \001(\0162\026.InstrumentClassR" + + "esult\022\024\n\014errorMessage\030\002 \001(\t\022\022\n\nclassByte" + + "s\030\003 \001(\014*L\n\025InstrumentClassResult\022\024\n\020CLAS" + + "S_UNMODIFIED\020\000\022\022\n\016CLASS_MODIFIED\020\001\022\t\n\005ER" + + "ROR\020\003B#\n\025ch.usi.dag.dislserverB\010Protocol" + + "H\003b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_InstrumentClassRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_InstrumentClassRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_InstrumentClassRequest_descriptor, + new java.lang.String[] { "Flags", "ClassName", "ClassBytes", }); + internal_static_InstrumentClassResponse_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_InstrumentClassResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_InstrumentClassResponse_descriptor, + new java.lang.String[] { "Result", "ErrorMessage", "ClassBytes", }); } // @@protoc_insertion_point(outer_class_scope) -- GitLab From 0fb6c4b40c4913961e2316713b5ec5932a5e062e Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Wed, 8 Jan 2020 01:20:17 +0100 Subject: [PATCH 10/17] fix bypass visibility issues --- bin/disl.py | 3 +- src-disl-agent/dislagent.c | 42 +++++++++++++++++++ .../app/TargetClass.java | 15 +++++++ .../instr/DiSLClass.java | 19 +++++++++ .../instr/Profiler.java | 13 ++++++ .../junit/BypassModuleVisibilityTest.java | 12 ++++++ .../junit/client.out.resource | 2 + .../utils/ClientServerEvaluationRunner.java | 5 ++- .../disl/test/utils/ClientServerRunner.java | 5 ++- 9 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/app/TargetClass.java create mode 100644 src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/DiSLClass.java create mode 100644 src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/Profiler.java create mode 100644 src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/BypassModuleVisibilityTest.java create mode 100644 src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/client.out.resource diff --git a/bin/disl.py b/bin/disl.py index 995b1e03..bbfbfe4c 100755 --- a/bin/disl.py +++ b/bin/disl.py @@ -503,7 +503,8 @@ def run_client(args, parser): if version == "1": version = version_match.group(2) if int(version) >= 9: - c_cmd+= ["--patch-module", "java.base="+args.disl_home+"/lib/java.base"] + c_cmd+= ["--patch-module", "java.base="+args.disl_home+"/lib/java.base:"+bypass] + c_cmd+= ["--add-exports", "java.base/ch.usi.dag.disl.dynamicbypass=ALL-UNNAMED"] c_cmd+= args.c_app diff --git a/src-disl-agent/dislagent.c b/src-disl-agent/dislagent.c index d1dfa4b3..07084a2e 100644 --- a/src-disl-agent/dislagent.c +++ b/src-disl-agent/dislagent.c @@ -126,6 +126,13 @@ static volatile bool jvm_is_started; static volatile bool jvm_is_initialized; +/** + * Flag indicating that the VM is using Java 9 or above, + * which allows calling JNI module system functions. + */ +static volatile bool java_is_9_or_above; + + /** * Runtime debuging output macros. */ @@ -518,6 +525,31 @@ jvmti_callback_class_file_load ( ); if (class_changed) { + // + // Enable module to read bypass check class. + // + if (java_is_9_or_above && jvm_is_started && strstr(class_name, "/") != NULL) { + char* class_wt_package = strrchr (class_name, '/'); + int package_name_length = strlen(class_name) - strlen(class_wt_package); + char package_name[package_name_length + 1]; + strncpy (package_name, class_name, package_name_length); + package_name[package_name_length] = '\0'; + + jvmtiError error; + jobject bypass_module = NULL; + error = (*jvmti)->GetNamedModule (jvmti, NULL, "ch/usi/dag/disl/dynamicbypass", &bypass_module); + check_jvmti_error (jvmti, error, "failed to get bypass module"); + + jobject class_module = NULL; + error = (*jvmti)->GetNamedModule (jvmti, loader, package_name, &class_module); + check_jvmti_error (jvmti, error, "failed to get logger module"); + + if (class_module != NULL) { + error = (*jvmti)->AddModuleExports (jvmti, bypass_module, "ch.usi.dag.disl.dynamicbypass", class_module); + check_jvmti_error (jvmti, error, "failed to export bypass package to module"); + } + } + unsigned char * jvm_class_bytes = jvmti_alloc_copy ( jvmti, class_def.class_bytes, class_def.class_byte_count ); @@ -768,6 +800,16 @@ Agent_OnLoad (JavaVM * jvm, char * options, void * reserved) { __configure_from_options (options, &agent_config); __configure_from_properties (jvmti, &agent_config); + char * java_version; + error = (*jvmti)->GetSystemProperty (jvmti, "java.vm.specification.version", &java_version); + check_jvmti_error (jvmti, error, "failed to get java version"); + + // Java specification version contains a dot until version 9 + // eg. Java 8 = 1.8 + // Java 9 = 9 + java_is_9_or_above = strstr(java_version, ".") == NULL; + (* jvmti)->Deallocate (jvmti, (unsigned char *) java_version); + jvm_is_started = false; jvm_is_initialized = false; agent_code_flags = __calc_code_flags (&agent_config, true); diff --git a/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/app/TargetClass.java b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/app/TargetClass.java new file mode 100644 index 00000000..4d2fce6b --- /dev/null +++ b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/app/TargetClass.java @@ -0,0 +1,15 @@ +package ch.usi.dag.disl.test.suite.bypassmodulevisibility.app; + +import java.util.logging.Logger; + +public class TargetClass { + + public static void main(String[] args) { + // + // try to instrument a class in another module + // BypassCheck should be visible to it + // + final Logger LOGGER = Logger.getGlobal(); + } + +} diff --git a/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/DiSLClass.java b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/DiSLClass.java new file mode 100644 index 00000000..b21d1fc2 --- /dev/null +++ b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/DiSLClass.java @@ -0,0 +1,19 @@ +package ch.usi.dag.disl.test.suite.bypassmodulevisibility.instr; + +import ch.usi.dag.disl.annotation.Before; +import ch.usi.dag.disl.annotation.After; +import ch.usi.dag.disl.marker.BodyMarker; + +public class DiSLClass { + + @Before(marker = BodyMarker.class, order = 1, scope = "java.util.logging.Logger.getGlobal(..)") + public static void beforeEvent() { + Profiler.before(); + } + + @After(marker = BodyMarker.class, order = 1, scope = "java.util.logging.Logger.getGlobal(..)") + public static void afterEvent() { + Profiler.after(); + } + +} diff --git a/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/Profiler.java b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/Profiler.java new file mode 100644 index 00000000..e689c041 --- /dev/null +++ b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/instr/Profiler.java @@ -0,0 +1,13 @@ +package ch.usi.dag.disl.test.suite.bypassmodulevisibility.instr; + +public class Profiler { + + public static void before() { + System.out.println("disl: before"); + } + + public static void after() { + System.out.println("disl: after"); + } + +} diff --git a/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/BypassModuleVisibilityTest.java b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/BypassModuleVisibilityTest.java new file mode 100644 index 00000000..da5cdf09 --- /dev/null +++ b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/BypassModuleVisibilityTest.java @@ -0,0 +1,12 @@ +package ch.usi.dag.disl.test.suite.bypassmodulevisibility.junit; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import ch.usi.dag.disl.test.suite.DislOnlyTest; + + +@RunWith (JUnit4.class) +public class BypassModuleVisibilityTest extends DislOnlyTest { + +} diff --git a/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/client.out.resource b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/client.out.resource new file mode 100644 index 00000000..d8e210d3 --- /dev/null +++ b/src-test/ch/usi/dag/disl/test/suite/bypassmodulevisibility/junit/client.out.resource @@ -0,0 +1,2 @@ +disl: before +disl: after diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java index b5c77681..0930d742 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java @@ -132,9 +132,12 @@ public class ClientServerEvaluationRunner extends Runner { if (javaVersion >= 9) { command.addAll (Arrays.asList ( "--patch-module", String.format ( - "java.base=%s", _DISL_THREAD_DIR_ + "java.base=%s:%s", _DISL_THREAD_DIR_, _DISL_BYPASS_JAR_ ) )); + command.addAll (Arrays.asList ( + "--add-exports", "java.base/ch.usi.dag.disl.dynamicbypass=ALL-UNNAMED" + )); } command.addAll (propertiesStartingWith ("disl.")); diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java index c44d1586..dca8a1f3 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java @@ -96,9 +96,12 @@ public class ClientServerRunner extends Runner { if (javaVersion >= 9) { command.addAll (Arrays.asList ( "--patch-module", String.format ( - "java.base=%s", _DISL_THREAD_DIR_ + "java.base=%s:%s", _DISL_THREAD_DIR_, _DISL_BYPASS_JAR_ ) )); + command.addAll (Arrays.asList ( + "--add-exports", "java.base/ch.usi.dag.disl.dynamicbypass=ALL-UNNAMED" + )); } command.addAll (propertiesStartingWith ("disl.")); -- GitLab From ce4f474ab47aeb62cff5a1007ff9a10eacfe3df5 Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Wed, 8 Jan 2020 17:08:59 +0100 Subject: [PATCH 11/17] add Java 10, 11 and 12 to CI --- .gitlab-ci.yml | 68 +++++++++++++++++++-- docker/openjdk-10.Dockerfile | 29 +++++++++ docker/openjdk-11.Dockerfile | 29 +++++++++ docker/openjdk-12.Dockerfile | 31 ++++++++++ docker/openjdk-9.Dockerfile | 29 +++++++++ Dockerfile => docker/oraclejdk-8.Dockerfile | 0 6 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 docker/openjdk-10.Dockerfile create mode 100644 docker/openjdk-11.Dockerfile create mode 100644 docker/openjdk-12.Dockerfile create mode 100644 docker/openjdk-9.Dockerfile rename Dockerfile => docker/oraclejdk-8.Dockerfile (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b750c6b6..5d1d8ce9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ image: &image-java-8 gitlab.ow2.org:4567/disl/disl/disl-ci -image: &image-java-9 mbasso/disl-ci +image: &image-java-9 mbasso/disl-ci:openjdk-9 +image: &image-java-10 mbasso/disl-ci:openjdk-10 +image: &image-java-11 mbasso/disl-ci:openjdk-11 +image: &image-java-12 mbasso/disl-ci:openjdk-12 # Setup cache to prevent downloading deps and compiling sources in each stage cache: &cache @@ -12,11 +15,23 @@ cache: &cache # Caches for different Java versions cache: &cache-8 <<: *cache - key: "${CI_COMMIT_REF_SLUG}-8" + key: "${CI_COMMIT_REF_SLUG}-oraclejdk-8" cache: &cache-9 - <<: *cache - key: "${CI_COMMIT_REF_SLUG}-9" + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-9" + +cache: &cache-10 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-10" + +cache: &cache-11 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-11" + +cache: &cache-12 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-12" # Adjust modification date to prevent recompiling sources in different stages. @@ -52,6 +67,30 @@ build-9: policy: push +build-10: + image: *image-java-10 + extends: .build + cache: + <<: *cache-10 + policy: + push + +build-11: + image: *image-java-11 + extends: .build + cache: + <<: *cache-11 + policy: + push + +build-12: + image: *image-java-12 + extends: .build + cache: + <<: *cache-12 + policy: + push + # Run tests .test: stage: test @@ -71,3 +110,24 @@ test-9: cache: <<: *cache-9 policy: pull + +test-10: + image: *image-java-10 + extends: .test + cache: + <<: *cache-10 + policy: pull + +test-11: + image: *image-java-11 + extends: .test + cache: + <<: *cache-11 + policy: pull + +test-12: + image: *image-java-12 + extends: .test + cache: + <<: *cache-12 + policy: pull diff --git a/docker/openjdk-10.Dockerfile b/docker/openjdk-10.Dockerfile new file mode 100644 index 00000000..ff669a8f --- /dev/null +++ b/docker/openjdk-10.Dockerfile @@ -0,0 +1,29 @@ +FROM openjdk:10 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN apt-get update && \ + DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/openjdk-11.Dockerfile b/docker/openjdk-11.Dockerfile new file mode 100644 index 00000000..ca29e107 --- /dev/null +++ b/docker/openjdk-11.Dockerfile @@ -0,0 +1,29 @@ +FROM openjdk:11 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN apt-get update && \ + DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/openjdk-12.Dockerfile b/docker/openjdk-12.Dockerfile new file mode 100644 index 00000000..b6b89198 --- /dev/null +++ b/docker/openjdk-12.Dockerfile @@ -0,0 +1,31 @@ +FROM adoptopenjdk/openjdk12:x86_64-debian-jdk-12.0.2_10 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +RUN apt-get update && \ + apt-get install wget + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/openjdk-9.Dockerfile b/docker/openjdk-9.Dockerfile new file mode 100644 index 00000000..b776a158d --- /dev/null +++ b/docker/openjdk-9.Dockerfile @@ -0,0 +1,29 @@ +FROM openjdk:9 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN apt-get update && \ + DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile b/docker/oraclejdk-8.Dockerfile similarity index 100% rename from Dockerfile rename to docker/oraclejdk-8.Dockerfile -- GitLab From 34126df59437563d276f05964175e1d8256a1bdb Mon Sep 17 00:00:00 2001 From: Matteo Basso Date: Wed, 8 Jan 2020 20:39:17 +0100 Subject: [PATCH 12/17] fix java version --- bin/disl.py | 4 ++-- src-test/ch/usi/dag/disl/test/utils/Runner.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/disl.py b/bin/disl.py index bbfbfe4c..5afbf0b5 100755 --- a/bin/disl.py +++ b/bin/disl.py @@ -496,8 +496,8 @@ def run_client(args, parser): c_cmd+= ["-Xbootclasspath/a:"+bypass+":"+args.instrumentation] # provide options needed only for Java 9+ - java_version = subprocess.check_output(["java", '-version'], stderr=subprocess.STDOUT) - version_match = re.search('"(\d+)\.(\d+)', java_version, re.IGNORECASE) + java_version = check_output(["java", '-version'], stderr=STDOUT).decode('utf-8') + version_match = re.search('"(\d+)(?:\.(\d+))?', java_version, re.IGNORECASE) if version_match: version = version_match.group(1) if version == "1": diff --git a/src-test/ch/usi/dag/disl/test/utils/Runner.java b/src-test/ch/usi/dag/disl/test/utils/Runner.java index 9a1ca7b1..ca8296a8 100644 --- a/src-test/ch/usi/dag/disl/test/utils/Runner.java +++ b/src-test/ch/usi/dag/disl/test/utils/Runner.java @@ -88,7 +88,7 @@ public abstract class Runner { output.append(line); } - final Pattern pattern = Pattern.compile("\\\"(\\d+)\\.(\\d+)"); + final Pattern pattern = Pattern.compile("\\\"(\\d+)(?:\\.(\\d+))?"); final Matcher matcher = pattern.matcher(output); if (!matcher.find()) { throw new RunnerException ("failed to get java version"); -- GitLab From f418426ad46dad3b9c28e9143c77afc917285bf9 Mon Sep 17 00:00:00 2001 From: mbasso Date: Wed, 30 Sep 2020 00:01:38 +0200 Subject: [PATCH 13/17] add Java 13, 14 and 15 to CI --- .gitlab-ci.yml | 59 ++++++++++++++++++++++++++++++++++++ docker/openjdk-13.Dockerfile | 33 ++++++++++++++++++++ docker/openjdk-14.Dockerfile | 33 ++++++++++++++++++++ docker/openjdk-15.Dockerfile | 33 ++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 docker/openjdk-13.Dockerfile create mode 100644 docker/openjdk-14.Dockerfile create mode 100644 docker/openjdk-15.Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5d1d8ce9..190f8f3c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,9 @@ image: &image-java-9 mbasso/disl-ci:openjdk-9 image: &image-java-10 mbasso/disl-ci:openjdk-10 image: &image-java-11 mbasso/disl-ci:openjdk-11 image: &image-java-12 mbasso/disl-ci:openjdk-12 +image: &image-java-13 mbasso/disl-ci:openjdk-13 +image: &image-java-14 mbasso/disl-ci:openjdk-14 +image: &image-java-15 mbasso/disl-ci:openjdk-15 # Setup cache to prevent downloading deps and compiling sources in each stage cache: &cache @@ -33,6 +36,17 @@ cache: &cache-12 <<: *cache key: "${CI_COMMIT_REF_SLUG}-openjdk-12" +cache: &cache-13 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-13" + +cache: &cache-14 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-14" + +cache: &cache-15 + <<: *cache + key: "${CI_COMMIT_REF_SLUG}-openjdk-15" # Adjust modification date to prevent recompiling sources in different stages. before_script: @@ -91,6 +105,30 @@ build-12: policy: push +build-13: + image: *image-java-13 + extends: .build + cache: + <<: *cache-13 + policy: + push + +build-14: + image: *image-java-14 + extends: .build + cache: + <<: *cache-14 + policy: + push + +build-15: + image: *image-java-15 + extends: .build + cache: + <<: *cache-15 + policy: + push + # Run tests .test: stage: test @@ -131,3 +169,24 @@ test-12: cache: <<: *cache-12 policy: pull + +test-13: + image: *image-java-13 + extends: .test + cache: + <<: *cache-13 + policy: pull + +test-14: + image: *image-java-14 + extends: .test + cache: + <<: *cache-14 + policy: pull + +test-15: + image: *image-java-15 + extends: .test + cache: + <<: *cache-15 + policy: pull diff --git a/docker/openjdk-13.Dockerfile b/docker/openjdk-13.Dockerfile new file mode 100644 index 00000000..a7f1ef62 --- /dev/null +++ b/docker/openjdk-13.Dockerfile @@ -0,0 +1,33 @@ +FROM adoptopenjdk/openjdk13:x86_64-debian-jdk-13.0.2_8 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +RUN chmod o+r /etc/resolv.conf + +RUN apt-get -yq update && \ + apt-get -yq install wget + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/openjdk-14.Dockerfile b/docker/openjdk-14.Dockerfile new file mode 100644 index 00000000..4d613039 --- /dev/null +++ b/docker/openjdk-14.Dockerfile @@ -0,0 +1,33 @@ +FROM adoptopenjdk/openjdk14:x86_64-debian-jdk-14.0.2_12 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +RUN chmod o+r /etc/resolv.conf + +RUN apt-get -yq update && \ + apt-get -yq install wget + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/openjdk-15.Dockerfile b/docker/openjdk-15.Dockerfile new file mode 100644 index 00000000..9e3957ee --- /dev/null +++ b/docker/openjdk-15.Dockerfile @@ -0,0 +1,33 @@ +FROM adoptopenjdk/openjdk15:x86_64-debian-jdk-15_36 + +ENV ANT_VERSION=1.10.7 +ENV ANT_HOME=/opt/ant + +WORKDIR /tmp + +RUN chmod o+r /etc/resolv.conf + +RUN apt-get -yq update && \ + apt-get -yq install wget + +# https://github.com/frekele/docker-ant/blob/master/Dockerfile +# MIT License +# Copyright (c) 2016-2018 @frekele + +# Download, extract apache ant to opt folder and add executables to path +RUN wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + wget --no-check-certificate --no-cookies http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + echo "$(cat apache-ant-${ANT_VERSION}-bin.tar.gz.sha512) apache-ant-${ANT_VERSION}-bin.tar.gz" | sha512sum -c && \ + tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && \ + ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.sha512 && \ + update-alternatives --install "/usr/bin/ant" "ant" "/opt/ant/bin/ant" 1 && \ + update-alternatives --set "ant" "/opt/ant/bin/ant" + +WORKDIR /root + +# Install make and gcc (cc respectively) +RUN DEBIAN_FRONTEND='noninteractive' apt-get install -yq make gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* -- GitLab From 2b93c2d8f4785d4911976061be42a7618dd4d368 Mon Sep 17 00:00:00 2001 From: mbasso Date: Wed, 30 Sep 2020 00:15:05 +0200 Subject: [PATCH 14/17] fix ivy url --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 5c4571e2..9d6a5350 100644 --- a/build.properties +++ b/build.properties @@ -38,7 +38,7 @@ build.doc.intro=${build.dir}/intro build.disl.native=${build.dir}/native # Build system libraries -build.ivy.url = http://central.maven.org/maven2/org/apache/ivy/ivy/${ivy.rev}/ivy-${ivy.rev}.jar +build.ivy.url = https://repo.maven.apache.org/maven2/org/apache/ivy/ivy/${ivy.rev}/ivy-${ivy.rev}.jar build.ivy.path = ${lib.ant.dir}/ivy.jar build.ivy.file = dependencies.xml -- GitLab From e8a72ab999f35f3c8b83a14f8cffdaa1c0430ee5 Mon Sep 17 00:00:00 2001 From: mbasso Date: Wed, 30 Sep 2020 00:37:43 +0200 Subject: [PATCH 15/17] update asm to 9.0, add -XX:-PrintWarnings flag --- dependencies.properties | 2 +- examples/build-example.xml | 1 + src-disl/ch/usi/dag/disl/DiSL.java | 2 +- src-disl/ch/usi/dag/disl/TLVInserter.java | 4 ++-- .../ch/usi/dag/disl/classparser/AnnotationMapper.java | 4 ++-- src-disl/ch/usi/dag/disl/marker/AfterInitBodyMarker.java | 2 +- src-disl/ch/usi/dag/disl/util/AsmHelper.java | 2 +- src-disl/ch/usi/dag/disl/weaver/pe/ConstInterpreter.java | 2 +- .../usi/dag/disl/test/utils/ClientEvaluationRunner.java | 2 +- .../dag/disl/test/utils/ClientServerEvaluationRunner.java | 2 +- .../ch/usi/dag/disl/test/utils/ClientServerRunner.java | 2 +- src-tools/ch/usi/dag/disl/tools/ExtendThread.java | 4 ++-- src-util/ch/usi/dag/util/asm/ClassNodeHelper.java | 8 ++++---- 13 files changed, 19 insertions(+), 18 deletions(-) diff --git a/dependencies.properties b/dependencies.properties index 807b3679..3d84f949 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -6,7 +6,7 @@ ant-contrib.org=ant-contrib junit.rev=4.12 junit.org=junit -asm.rev=7.2 +asm.rev=9.0 asm.org=org.ow2.asm log4j.rev=1.2.17 diff --git a/examples/build-example.xml b/examples/build-example.xml index c0d82a35..077a5226 100644 --- a/examples/build-example.xml +++ b/examples/build-example.xml @@ -50,6 +50,7 @@ + diff --git a/src-disl/ch/usi/dag/disl/DiSL.java b/src-disl/ch/usi/dag/disl/DiSL.java index 7db0de81..f6cb6679 100644 --- a/src-disl/ch/usi/dag/disl/DiSL.java +++ b/src-disl/ch/usi/dag/disl/DiSL.java @@ -430,7 +430,7 @@ public final class DiSL { if (!tlvs.isEmpty ()) { // instrument fields - final ClassNode cnWithFields = new ClassNode (Opcodes.ASM7); + final ClassNode cnWithFields = new ClassNode (Opcodes.ASM9); classNode.accept (new TLVInserter (cnWithFields, tlvs)); // replace original code with instrumented one diff --git a/src-disl/ch/usi/dag/disl/TLVInserter.java b/src-disl/ch/usi/dag/disl/TLVInserter.java index b37ebe7f..b0add069 100644 --- a/src-disl/ch/usi/dag/disl/TLVInserter.java +++ b/src-disl/ch/usi/dag/disl/TLVInserter.java @@ -30,7 +30,7 @@ final class TLVInserter extends ClassVisitor { // public TLVInserter (final ClassVisitor cv, final Set tlvs) { - super (Opcodes.ASM7, cv); + super (Opcodes.ASM9, cv); __threadLocals = tlvs; } @@ -97,7 +97,7 @@ final class TLVInserter extends ClassVisitor { final MethodVisitor mv, final int access, final String name, final String desc ) { - super (Opcodes.ASM7, mv, access, name, desc); + super (Opcodes.ASM9, mv, access, name, desc); assert JavaNames.isConstructorName (name); } diff --git a/src-disl/ch/usi/dag/disl/classparser/AnnotationMapper.java b/src-disl/ch/usi/dag/disl/classparser/AnnotationMapper.java index 2aedfa8a..2c275166 100644 --- a/src-disl/ch/usi/dag/disl/classparser/AnnotationMapper.java +++ b/src-disl/ch/usi/dag/disl/classparser/AnnotationMapper.java @@ -110,7 +110,7 @@ final class AnnotationMapper { Predicate , BiConsumer > consumers = __findConsumers (ac); - an.accept (new AnnotationVisitor (Opcodes.ASM7) { + an.accept (new AnnotationVisitor (Opcodes.ASM9) { @Override public void visit (final String name, final Object value) { __getConsumer (consumers, name).accept (name, value); @@ -149,7 +149,7 @@ final class AnnotationMapper { final BiConsumer __consumer; ListCollector (final String name, final BiConsumer consumer) { - super (Opcodes.ASM7); + super (Opcodes.ASM9); __name = name; __consumer = consumer; diff --git a/src-disl/ch/usi/dag/disl/marker/AfterInitBodyMarker.java b/src-disl/ch/usi/dag/disl/marker/AfterInitBodyMarker.java index 0a455415..1ba41dfd 100644 --- a/src-disl/ch/usi/dag/disl/marker/AfterInitBodyMarker.java +++ b/src-disl/ch/usi/dag/disl/marker/AfterInitBodyMarker.java @@ -76,7 +76,7 @@ public class AfterInitBodyMarker extends AbstractMarker { // final AtomicBoolean superInitialized = new AtomicBoolean (false); final AdviceAdapter adapter = new AdviceAdapter ( - Opcodes.ASM7, new MethodVisitor (Opcodes.ASM7) { /* empty */ }, + Opcodes.ASM9, new MethodVisitor (Opcodes.ASM9) { /* empty */ }, method.access, method.name, method.desc ) { @Override diff --git a/src-disl/ch/usi/dag/disl/util/AsmHelper.java b/src-disl/ch/usi/dag/disl/util/AsmHelper.java index 4a234530..58c504f4 100644 --- a/src-disl/ch/usi/dag/disl/util/AsmHelper.java +++ b/src-disl/ch/usi/dag/disl/util/AsmHelper.java @@ -470,7 +470,7 @@ public abstract class AsmHelper { */ public static MethodNode cloneMethod (final MethodNode method) { final MethodNode result = new MethodNode ( - Opcodes.ASM7, method.access, method.name, method.desc, + Opcodes.ASM9, method.access, method.name, method.desc, method.signature, method.exceptions.toArray ( new String [method.exceptions.size ()] ) diff --git a/src-disl/ch/usi/dag/disl/weaver/pe/ConstInterpreter.java b/src-disl/ch/usi/dag/disl/weaver/pe/ConstInterpreter.java index 28bbdd75..e7e5d8a4 100644 --- a/src-disl/ch/usi/dag/disl/weaver/pe/ConstInterpreter.java +++ b/src-disl/ch/usi/dag/disl/weaver/pe/ConstInterpreter.java @@ -17,7 +17,7 @@ import org.objectweb.asm.tree.analysis.Interpreter; public class ConstInterpreter extends Interpreter { protected ConstInterpreter() { - super(Opcodes.ASM7); + super(Opcodes.ASM9); } @Override diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientEvaluationRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientEvaluationRunner.java index a3fb262a..35ad8f14 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientEvaluationRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientEvaluationRunner.java @@ -83,7 +83,7 @@ public class ClientEvaluationRunner extends Runner { final File instJar, final File appJar ) throws IOException { final List command = new LinkedList <> (Arrays.asList ( - __CLIENT_JAVA_COMMAND__, "-noverify", + __CLIENT_JAVA_COMMAND__, "-XX:-PrintWarnings", "-noverify", String.format ("-agentpath:%s", _SHVM_AGENT_LIB_), String.format ("-Xbootclasspath/a:%s", Runner.classPath ( _SHVM_DISPATCH_JAR_, instJar diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java index 0930d742..5ea421d3 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientServerEvaluationRunner.java @@ -120,7 +120,7 @@ public class ClientServerEvaluationRunner extends Runner { final File instJar, final File appJar ) throws IOException { final List command = new LinkedList <> (Arrays.asList ( - __CLIENT_JAVA_COMMAND__, "-noverify", + __CLIENT_JAVA_COMMAND__, "-XX:-PrintWarnings", "-noverify", String.format ("-agentpath:%s", _DISL_AGENT_LIB_), String.format ("-agentpath:%s", _SHVM_AGENT_LIB_), String.format ("-Xbootclasspath/a:%s", Runner.classPath ( diff --git a/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java b/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java index dca8a1f3..7c3a1c69 100644 --- a/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java +++ b/src-test/ch/usi/dag/disl/test/utils/ClientServerRunner.java @@ -85,7 +85,7 @@ public class ClientServerRunner extends Runner { final File testInstJar, final File testAppJar ) throws IOException { final List command = new LinkedList <> (Arrays.asList ( - __CLIENT_JAVA_COMMAND__, "-noverify", + __CLIENT_JAVA_COMMAND__, "-XX:-PrintWarnings", "-noverify", String.format ("-agentpath:%s", _DISL_AGENT_LIB_), String.format ("-Xbootclasspath/a:%s", Runner.classPath ( _DISL_BYPASS_JAR_, testInstJar diff --git a/src-tools/ch/usi/dag/disl/tools/ExtendThread.java b/src-tools/ch/usi/dag/disl/tools/ExtendThread.java index 0209304f..856b3975 100644 --- a/src-tools/ch/usi/dag/disl/tools/ExtendThread.java +++ b/src-tools/ch/usi/dag/disl/tools/ExtendThread.java @@ -60,7 +60,7 @@ public final class ExtendThread { private Type __owner; public FieldExtender (final FieldDefinition fd, final ClassWriter cw) { - super (Opcodes.ASM7, cw); + super (Opcodes.ASM9, cw); __fd = fd; } @@ -86,7 +86,7 @@ public final class ExtendThread { if ("".equals (name)) { // Initialize the field. - return new AdviceAdapter (Opcodes.ASM7, mv, access, name, desc) { + return new AdviceAdapter (Opcodes.ASM9, mv, access, name, desc) { @Override protected void onMethodEnter () { __fd.initialize (__owner, this); diff --git a/src-util/ch/usi/dag/util/asm/ClassNodeHelper.java b/src-util/ch/usi/dag/util/asm/ClassNodeHelper.java index bc35173b..18f08ba1 100644 --- a/src-util/ch/usi/dag/util/asm/ClassNodeHelper.java +++ b/src-util/ch/usi/dag/util/asm/ClassNodeHelper.java @@ -52,7 +52,7 @@ public enum ClassNodeHelper { * from the given array. */ public ClassNode unmarshal (final byte [] bytes) { - final ClassNode result = new ClassNode (Opcodes.ASM7); + final ClassNode result = new ClassNode (Opcodes.ASM9); new ClassReader (bytes).accept (result, __flags); return result; } @@ -63,7 +63,7 @@ public enum ClassNodeHelper { * from the given input stream. */ public ClassNode unmarshal (final InputStream is) throws IOException { - final ClassNode result = new ClassNode (Opcodes.ASM7); + final ClassNode result = new ClassNode (Opcodes.ASM9); new ClassReader (is).accept (result, __flags); return result; } @@ -74,7 +74,7 @@ public enum ClassNodeHelper { * as a resource using the system class loader. */ public ClassNode load (final String className) throws IOException { - final ClassNode result = new ClassNode (Opcodes.ASM7); + final ClassNode result = new ClassNode (Opcodes.ASM9); new ClassReader (className).accept (result, __flags); return result; } @@ -89,7 +89,7 @@ public enum ClassNodeHelper { * @return a new {@link ClassNode} instance */ public static ClassNode duplicate (final ClassNode source) { - final ClassNode result = new ClassNode (Opcodes.ASM7); + final ClassNode result = new ClassNode (Opcodes.ASM9); source.accept (result); return result; } -- GitLab From a69258ccecabe71604a77ef1b5cf4d99563e5f36 Mon Sep 17 00:00:00 2001 From: mbasso Date: Wed, 30 Sep 2020 14:59:36 +0200 Subject: [PATCH 16/17] fix lambda canonical name --- .../shadow/LambdaShadowClass.java | 9 ++++++ .../ch/usi/dag/dislreserver/util/Env.java | 29 +++++++++++++++++++ .../suite/dispatchlambda/instr/Analysis.java | 11 ++++++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src-shvm/ch/usi/dag/dislreserver/util/Env.java diff --git a/src-shvm/ch/usi/dag/dislreserver/shadow/LambdaShadowClass.java b/src-shvm/ch/usi/dag/dislreserver/shadow/LambdaShadowClass.java index b2df7124..201941fe 100644 --- a/src-shvm/ch/usi/dag/dislreserver/shadow/LambdaShadowClass.java +++ b/src-shvm/ch/usi/dag/dislreserver/shadow/LambdaShadowClass.java @@ -5,6 +5,8 @@ import java.util.stream.Stream; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; +import ch.usi.dag.dislreserver.util.Env; + final class LambdaShadowClass extends ShadowClass { @@ -37,6 +39,13 @@ final class LambdaShadowClass extends ShadowClass { @Override public String getCanonicalName () { + // + // From Java 15, lambdas are treated as Hidden Classes + // + if (Env.getJavaVersion() > 14) { + return null; + } + return __canonicalName (); } diff --git a/src-shvm/ch/usi/dag/dislreserver/util/Env.java b/src-shvm/ch/usi/dag/dislreserver/util/Env.java new file mode 100644 index 00000000..1c1edd6c --- /dev/null +++ b/src-shvm/ch/usi/dag/dislreserver/util/Env.java @@ -0,0 +1,29 @@ +package ch.usi.dag.dislreserver.util; + + +public final class Env { + + /** + * Java version of the running JVM. + */ + private static final int javaVersion; + + static { + String version = System.getProperty("java.version"); + if(version.startsWith("1.")) { + version = version.substring(2, 3); + } else { + final int dot = version.indexOf("."); + if(dot != -1) { + version = version.substring(0, dot); + } + } + + javaVersion = Integer.parseInt(version); + } + + public static int getJavaVersion() { + return javaVersion; + } + +} diff --git a/src-test/ch/usi/dag/disl/test/suite/dispatchlambda/instr/Analysis.java b/src-test/ch/usi/dag/disl/test/suite/dispatchlambda/instr/Analysis.java index 864bee89..f6d0e6d4 100644 --- a/src-test/ch/usi/dag/disl/test/suite/dispatchlambda/instr/Analysis.java +++ b/src-test/ch/usi/dag/disl/test/suite/dispatchlambda/instr/Analysis.java @@ -14,7 +14,16 @@ public class Analysis extends RemoteAnalysis { public void lambdaEvent (final int index, final ShadowObject object) { final String name = object.getShadowClass ().getName (); - System.out.println (index +": "+ name.substring (0, name.lastIndexOf ("/"))); + + // + // In Java 1, slash has been replaced by dot + // + int lastIndex = name.lastIndexOf ("/"); + if (lastIndex == -1) { + lastIndex = name.lastIndexOf ("."); + } + + System.out.println (index +": "+ name.substring (0, lastIndex)); __lambdaEventsTotal.incrementAndGet (); } -- GitLab From 45406aaf92873e0845b88326dea7c6265c8067a7 Mon Sep 17 00:00:00 2001 From: mbasso Date: Wed, 30 Sep 2020 15:10:09 +0200 Subject: [PATCH 17/17] fix agent --- src-disl-agent/dislagent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-disl-agent/dislagent.c b/src-disl-agent/dislagent.c index 07084a2e..2ffc6d68 100644 --- a/src-disl-agent/dislagent.c +++ b/src-disl-agent/dislagent.c @@ -528,7 +528,7 @@ jvmti_callback_class_file_load ( // // Enable module to read bypass check class. // - if (java_is_9_or_above && jvm_is_started && strstr(class_name, "/") != NULL) { + if (java_is_9_or_above && jvm_is_initialized && strstr(class_name, "/") != NULL) { char* class_wt_package = strrchr (class_name, '/'); int package_name_length = strlen(class_name) - strlen(class_wt_package); char package_name[package_name_length + 1]; -- GitLab