Skip to content

Commit cc291bc

Browse files
committed
FEATURE: migrate to java 11
1 parent 31f2260 commit cc291bc

File tree

38 files changed

+448
-251
lines changed

38 files changed

+448
-251
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module executor.client {
2+
exports com.credits.client.executor.thrift.generated.apiexec;
3+
exports com.credits.client.executor.thrift.generated;
4+
requires jsr250.api;
5+
requires libthrift;
6+
requires node.client;
7+
requires slf4j.api;
8+
requires general;
9+
}

api-client/general/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,16 @@
2828
<artifactId>type-parser</artifactId>
2929
<version>0.6.0</version>
3030
</dependency>
31+
<dependency>
32+
<groupId>org.jetbrains</groupId>
33+
<artifactId>annotations</artifactId>
34+
<version>RELEASE</version>
35+
<scope>compile</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>javax.annotation</groupId>
39+
<artifactId>jsr250-api</artifactId>
40+
<version>1.0</version>
41+
</dependency>
3142
</dependencies>
3243
</project>

api-client/general/src/main/java/com/credits/general/util/compiler/InMemoryClassManager.java

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.tools.JavaFileManager;
99
import javax.tools.JavaFileObject;
1010
import javax.tools.JavaFileObject.Kind;
11+
import java.io.IOException;
1112
import java.util.ArrayList;
1213
import java.util.List;
1314

@@ -16,51 +17,63 @@
1617
* JavaFileObject to read/write bytecode into class files. This class extends
1718
* the standard JavaFileManager to read/write bytecode into memory using a
1819
* custom implementation of the JavaFileObject.
19-
*
20+
*
2021
* @see JavaMemoryObject
2122
*/
2223
public class InMemoryClassManager extends ForwardingJavaFileManager<JavaFileManager> {
2324

24-
private List<CompilationUnit> memory = new ArrayList();
25+
private List<CompilationUnit> memory = new ArrayList();
2526

26-
public InMemoryClassManager(JavaFileManager fileManager) {
27-
super(fileManager);
28-
}
29-
30-
@Override
31-
public FileObject getFileForInput(Location location, String packageName, String relativeName) {
32-
throw new UnsupportedOperationException();
33-
}
27+
public InMemoryClassManager(JavaFileManager fileManager) {
28+
super(fileManager);
29+
}
3430

35-
@Override
36-
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) {
37-
throw new UnsupportedOperationException();
38-
}
31+
@Override
32+
public FileObject getFileForInput(Location location, String packageName, String relativeName) {
3933

40-
@Override
41-
public JavaFileObject getJavaFileForOutput(Location location,
42-
String name, Kind kind, FileObject sibling) {
43-
JavaMemoryObject co = new JavaMemoryObject(name, kind);
44-
CompilationUnit cf = new CompilationUnit(name, co);
45-
memory.add(cf);
46-
return co;
47-
}
34+
try {
35+
return super.getFileForInput(location, packageName, relativeName);
36+
} catch (IOException e) {
37+
System.out.println(e);
38+
return null;
39+
}
40+
}
4841

49-
@Override
50-
public boolean isSameFile(FileObject a, FileObject b) {
51-
return false;
52-
}
42+
@Override
43+
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) {
44+
try {
45+
return super.getJavaFileForInput(location, className, kind);
46+
} catch (IOException e) {
47+
System.out.println(e);
48+
return null;
49+
}
50+
}
5351

54-
/**
55-
* Gets the bytecode as a list of compiled classes. If the source code
56-
* generates inner classes, these classes will be placed in front of the
57-
* returned list and the class associated to the source file will be the
58-
* last element in the list.
59-
*
60-
* @return List of compiled classes
61-
*/
62-
public List<CompilationUnit> getAllClasses() {
63-
return memory;
64-
}
52+
@Override
53+
public JavaFileObject getJavaFileForOutput(
54+
Location location,
55+
String name, Kind kind, FileObject sibling) {
56+
JavaMemoryObject co = new JavaMemoryObject(name, kind);
57+
CompilationUnit cf = new CompilationUnit(name, co);
58+
memory.add(cf);
59+
return co;
60+
}
61+
62+
@Override
63+
public boolean isSameFile(FileObject a, FileObject b) {
64+
return false;
65+
}
66+
67+
/**
68+
* Gets the bytecode as a list of compiled classes. If the source code
69+
* generates inner classes, these classes will be placed in front of the
70+
* returned list and the class associated to the source file will be the
71+
* last element in the list.
72+
*
73+
* @return List of compiled classes
74+
*/
75+
public List<CompilationUnit> getAllClasses() {
76+
return memory;
77+
}
6578
}
6679

api-client/general/src/main/java/com/credits/general/util/variant/VariantConverter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.credits.general.thrift.generated.Variant;
44
import com.credits.general.thrift.generated.object;
55

6-
import javax.annotation.Nonnull;
7-
import javax.annotation.Nullable;
86
import java.nio.ByteBuffer;
97
import java.util.ArrayList;
108
import java.util.Arrays;
@@ -48,11 +46,11 @@ public class VariantConverter {
4846
public static final Byte NULL_TYPE_VALUE = 0;
4947
public static final Byte VOID_TYPE_VALUE = 0;
5048

51-
public static Variant toVariant(@Nonnull String classType, @Nullable Object object) {
49+
public static Variant toVariant(String classType, Object object) {
5250
return new ObjectToVariantConverter().apply(requireNonNull(classType, "classType can't be null"), object);
5351
}
5452

55-
public static Object toObject(@Nonnull Variant variant, ClassLoader... classLoader) {
53+
public static Object toObject(Variant variant, ClassLoader... classLoader) {
5654
return new VariantToObjectConverter().apply(requireNonNull(variant, "variant can't be null"), classLoader);
5755
}
5856

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module general {
2+
requires libthrift;
3+
requires org.apache.commons.lang3;
4+
requires java.compiler;
5+
requires slf4j.api;
6+
requires commons.pool;
7+
requires org.eclipse.jdt.core;
8+
requires com.google.common;
9+
requires jsr250.api;
10+
requires type.parser;
11+
requires commons.beanutils.core;
12+
requires bcprov.jdk15on;
13+
exports com.credits.general.classload;
14+
exports com.credits.general.pojo;
15+
exports com.credits.general.thrift.generated;
16+
exports com.credits.general.util;
17+
exports com.credits.general.util.variant;
18+
exports com.credits.general.exception;
19+
exports com.credits.general.crypto;
20+
exports com.credits.general.util.compiler;
21+
exports com.credits.general.util.exception;
22+
exports com.credits.general.util.compiler.model;
23+
exports com.credits.general.serialize;
24+
exports com.credits.general.thrift;
25+
exports com.credits.general.crypto.exception;
26+
exports com.credits.general.util.sourceCode;
27+
}

api-client/general/src/test/java/com/credits/general/util/GeneralConverterTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.Test;
66

77
import java.math.BigDecimal;
8+
import java.math.RoundingMode;
89
import java.util.BitSet;
910

1011
import static com.credits.general.util.Constants.DECIMAL_SEPARATOR;
@@ -80,7 +81,7 @@ public void toBigDecimalTest() {
8081
String doubleString = "1" + DECIMAL_SEPARATOR + "1111111111111111";
8182
long longValue = GeneralConverter.toBigDecimal(longString).longValue();
8283
int integerValue = GeneralConverter.toBigDecimal(intString).intValue();
83-
double doubleValue = GeneralConverter.toBigDecimal(doubleString).setScale(13, BigDecimal.ROUND_DOWN).doubleValue();
84+
double doubleValue = GeneralConverter.toBigDecimal(doubleString).setScale(13, RoundingMode.DOWN).doubleValue();
8485
Assert.assertEquals(111111111111111111L, (Object) longValue);
8586
Assert.assertEquals(1111111111, (Object) integerValue);
8687
Assert.assertEquals(1.1111111111111, (Object) doubleValue);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module node.client {
2+
requires libthrift;
3+
requires jsr250.api;
4+
requires general;
5+
requires commons.codec;
6+
requires eddsa;
7+
requires slf4j.api;
8+
requires org.apache.commons.lang3;
9+
exports com.credits.client.node.exception;
10+
exports com.credits.client.node.pojo;
11+
exports com.credits.client.node.service;
12+
exports com.credits.client.node.thrift.generated;
13+
exports com.credits.client.node.util;
14+
exports com.credits.client.node.crypto;
15+
}

contract-executor/pom.xml

Lines changed: 81 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,77 @@
2727
<defaultGoal>package</defaultGoal>
2828
<plugins>
2929
<plugin>
30-
<artifactId>maven-resources-plugin</artifactId>
31-
<version>3.1.0</version>
32-
<executions>
33-
<execution>
34-
<id>copy-resources</id>
35-
<phase>package</phase>
36-
<goals>
37-
<goal>copy-resources</goal>
38-
</goals>
39-
<configuration>
40-
<outputDirectory>${basedir}/target</outputDirectory>
41-
<resources>
42-
<resource>
43-
<directory>src/main/resources</directory>
44-
<filtering>true</filtering>
45-
</resource>
46-
<resource>
47-
<filtering>false</filtering>
48-
<directory>..</directory>
49-
<includes>
50-
<include>**/*.properties</include>
51-
</includes>
52-
</resource>
53-
</resources>
54-
</configuration>
55-
</execution>
56-
</executions>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-compiler-plugin</artifactId>
32+
<version>3.8.0</version>
33+
<configuration>
34+
<source>${javaVersion}</source>
35+
<target>${javaVersion}</target>
36+
<compilerArgs>
37+
<arg>-parameters</arg>
38+
</compilerArgs>
39+
<annotationProcessorPaths>
40+
<path>
41+
<groupId>com.google.dagger</groupId>
42+
<artifactId>dagger-compiler</artifactId>
43+
<version>2.22.1</version>
44+
</path>
45+
</annotationProcessorPaths>
46+
<encoding>UTF-8</encoding>
47+
</configuration>
48+
<dependencies>
49+
<dependency>
50+
<groupId>org.ow2.asm</groupId>
51+
<artifactId>asm</artifactId>
52+
<version>6.2</version>
53+
</dependency>
54+
</dependencies>
5755
</plugin>
56+
57+
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-surefire-plugin</artifactId>
61+
<version>2.20</version>
62+
<configuration>
63+
<skipTests>${skipTests}</skipTests>
64+
<testFailureIgnore>false</testFailureIgnore>
65+
<excludes>
66+
<exclude>**/*IT.java</exclude>
67+
<exclude>**/*IntegrationTest.java</exclude>
68+
</excludes>
69+
</configuration>
70+
</plugin>
71+
72+
<!-- <plugin>-->
73+
<!-- <artifactId>maven-resources-plugin</artifactId>-->
74+
<!-- <version>3.1.0</version>-->
75+
<!-- <executions>-->
76+
<!-- <execution>-->
77+
<!-- <id>copy-resources</id>-->
78+
<!-- <phase>package</phase>-->
79+
<!-- <goals>-->
80+
<!-- <goal>copy-resources</goal>-->
81+
<!-- </goals>-->
82+
<!-- <configuration>-->
83+
<!-- <outputDirectory>${basedir}/target</outputDirectory>-->
84+
<!-- <resources>-->
85+
<!-- <resource>-->
86+
<!-- <directory>src/main/resources</directory>-->
87+
<!-- <filtering>true</filtering>-->
88+
<!-- </resource>-->
89+
<!-- <resource>-->
90+
<!-- <filtering>false</filtering>-->
91+
<!-- <directory>..</directory>-->
92+
<!-- <includes>-->
93+
<!-- <include>**/*.properties</include>-->
94+
<!-- </includes>-->
95+
<!-- </resource>-->
96+
<!-- </resources>-->
97+
<!-- </configuration>-->
98+
<!-- </execution>-->
99+
<!-- </executions>-->
100+
<!-- </plugin>-->
58101
<plugin>
59102
<groupId>org.apache.maven.plugins</groupId>
60103
<artifactId>maven-assembly-plugin</artifactId>
@@ -63,9 +106,10 @@
63106
<descriptorRef>jar-with-dependencies</descriptorRef>
64107
</descriptorRefs>
65108
<archive>
66-
<manifest>
67-
<mainClass>com.credits.ExecutorApp</mainClass>
68-
</manifest>
109+
<manifestEntries>
110+
<Main-Class>com.credits.ExecutorApp</Main-Class>
111+
<Multi-Release>true</Multi-Release>
112+
</manifestEntries>
69113
</archive>
70114
</configuration>
71115
<executions>
@@ -111,6 +155,13 @@
111155
<version>1.0</version>
112156
<scope>compile</scope>
113157
</dependency>
158+
159+
<!-- dagger -->
160+
<dependency>
161+
<groupId>com.google.dagger</groupId>
162+
<artifactId>dagger</artifactId>
163+
<version>2.22.1</version>
164+
</dependency>
114165
</dependencies>
115166

116167
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module contract.executor {
2+
requires general;
3+
requires org.apache.commons.lang3;
4+
requires general.structures;
5+
requires node.client;
6+
requires javax.inject;
7+
requires slf4j.api;
8+
requires sc.api;
9+
requires dagger;
10+
requires executor.client;
11+
requires libthrift;
12+
requires java.compiler;
13+
requires error.prone.annotations;
14+
}

contract-executor/src/test/java/com/credits/TestUtils.java renamed to contract-executor/src/test/java/tests/credits/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.credits;
1+
package tests.credits;
22

33
import com.credits.general.exception.CreditsException;
44

0 commit comments

Comments
 (0)