Skip to content

Commit d1c2ebb

Browse files
authored
X.26 (#134)
* Initial branch of x.26 * Tidy up compiler setting and some warnings * tidy SuppressWarnings * Added fail on warning lint for Javadoc, and rawtypes fixes for Bytes (#132) * Fix newlines * parent poms -> x.26.0 * java-parent-pom -> 1.26.0
1 parent 9bfcf47 commit d1c2ebb

File tree

8 files changed

+37
-44
lines changed

8 files changed

+37
-44
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ String javaCode = "package mypackage;\n" +
4141
" System.out.println(\"Hello World\");\n" +
4242
" }\n" +
4343
"}\n";
44-
Class aClass = CompilerUtils.CACHED_COMPILER.loadFromJava(className, javaCode);
44+
Class<?> aClass = CompilerUtils.CACHED_COMPILER.loadFromJava(className, javaCode);
4545
Runnable runner = (Runnable) aClass.newInstance();
4646
runner.run();
4747
```

pom.xml

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
<parent>
2222
<groupId>net.openhft</groupId>
2323
<artifactId>java-parent-pom</artifactId>
24-
<version>1.25.4</version>
24+
<version>1.26.0</version>
2525
<relativePath />
2626
</parent>
2727

2828
<artifactId>compiler</artifactId>
29-
<version>2.25ea4-SNAPSHOT</version>
29+
<version>2.26ea0-SNAPSHOT</version>
3030
<packaging>bundle</packaging>
3131

3232
<name>OpenHFT/Java-Runtime-Compiler</name>
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>net.openhft</groupId>
4040
<artifactId>third-party-bom</artifactId>
41-
<version>3.24.0</version>
41+
<version>3.26.0</version>
4242
<type>pom</type>
4343
<scope>import</scope>
4444
</dependency>
@@ -90,27 +90,15 @@
9090
<groupId>org.apache.maven.plugins</groupId>
9191
<artifactId>maven-compiler-plugin</artifactId>
9292
<configuration>
93-
<source>8</source>
94-
<target>8</target>
93+
<failOnWarning>false</failOnWarning>
9594
</configuration>
9695
</plugin>
9796

9897
<plugin>
99-
<groupId>org.codehaus.mojo</groupId>
100-
<artifactId>exec-maven-plugin</artifactId>
101-
102-
<executions>
103-
<execution>
104-
<id>compiler-test</id>
105-
<phase>integration-test</phase>
106-
<goals>
107-
<goal>java</goal>
108-
</goals>
109-
</execution>
110-
</executions>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-javadoc-plugin</artifactId>
111100
<configuration>
112-
<classpathScope>test</classpathScope>
113-
<mainClass>net.openhft.compiler.CompilerTest</mainClass>
101+
<failOnWarnings>false</failOnWarnings>
114102
</configuration>
115103
</plugin>
116104

@@ -195,21 +183,28 @@
195183
</build>
196184
</profile>
197185
<profile>
198-
<id>java11</id>
186+
<id>prejava17</id>
199187
<activation>
200-
<jdk>[11,</jdk>
188+
<jdk>[8,17]</jdk>
201189
</activation>
202-
<properties>
203-
<maven.compiler.release>11</maven.compiler.release>
204-
</properties>
205190
<build>
206191
<plugins>
207192
<plugin>
208-
<groupId>org.apache.maven.plugins</groupId>
209-
<artifactId>maven-compiler-plugin</artifactId>
193+
<groupId>org.codehaus.mojo</groupId>
194+
<artifactId>exec-maven-plugin</artifactId>
195+
196+
<executions>
197+
<execution>
198+
<id>compiler-test</id>
199+
<phase>integration-test</phase>
200+
<goals>
201+
<goal>java</goal>
202+
</goals>
203+
</execution>
204+
</executions>
210205
<configuration>
211-
<source>11</source>
212-
<target>11</target>
206+
<classpathScope>test</classpathScope>
207+
<mainClass>net.openhft.compiler.CompilerTest</mainClass>
213208
</configuration>
214209
</plugin>
215210
</plugins>

src/main/java/net/openhft/compiler/CachedCompiler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ public void close() {
7777
}
7878
}
7979

80-
public Class loadFromJava(@NotNull String className, @NotNull String javaCode) throws ClassNotFoundException {
80+
public Class<?> loadFromJava(@NotNull String className, @NotNull String javaCode) throws ClassNotFoundException {
8181
return loadFromJava(getClass().getClassLoader(), className, javaCode, DEFAULT_WRITER);
8282
}
8383

84-
public Class loadFromJava(@NotNull ClassLoader classLoader,
84+
public Class<?> loadFromJava(@NotNull ClassLoader classLoader,
8585
@NotNull String className,
8686
@NotNull String javaCode) throws ClassNotFoundException {
8787
return loadFromJava(classLoader, className, javaCode, DEFAULT_WRITER);
@@ -134,7 +134,7 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
134134
}
135135
}
136136

137-
public Class loadFromJava(@NotNull ClassLoader classLoader,
137+
public Class<?> loadFromJava(@NotNull ClassLoader classLoader,
138138
@NotNull String className,
139139
@NotNull String javaCode,
140140
@Nullable PrintWriter writer) throws ClassNotFoundException {

src/main/java/net/openhft/compiler/CompilerUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static void reset() {
100100
* @throws IOException the resource could not be loaded.
101101
* @throws ClassNotFoundException the class name didn't match or failed to initialise.
102102
*/
103-
public static Class loadFromResource(@NotNull String className, @NotNull String resourceName) throws IOException, ClassNotFoundException {
103+
public static Class<?> loadFromResource(@NotNull String className, @NotNull String resourceName) throws IOException, ClassNotFoundException {
104104
return loadFromJava(className, readText(resourceName));
105105
}
106106

@@ -112,7 +112,7 @@ public static Class loadFromResource(@NotNull String className, @NotNull String
112112
* @return the outer class loaded.
113113
* @throws ClassNotFoundException the class name didn't match or failed to initialise.
114114
*/
115-
private static Class loadFromJava(@NotNull String className, @NotNull String javaCode) throws ClassNotFoundException {
115+
private static Class<?> loadFromJava(@NotNull String className, @NotNull String javaCode) throws ClassNotFoundException {
116116
return CACHED_COMPILER.loadFromJava(Thread.currentThread().getContextClassLoader(), className, javaCode);
117117
}
118118

@@ -158,7 +158,7 @@ public static void defineClass(@NotNull String className, @NotNull byte[] bytes)
158158
* @param className expected to load.
159159
* @param bytes of the byte code.
160160
*/
161-
public static Class defineClass(@Nullable ClassLoader classLoader, @NotNull String className, @NotNull byte[] bytes) {
161+
public static Class<?> defineClass(@Nullable ClassLoader classLoader, @NotNull String className, @NotNull byte[] bytes) {
162162
try {
163163
return (Class) DEFINE_CLASS_METHOD.invoke(classLoader, className, bytes, 0, bytes.length);
164164
} catch (IllegalAccessException e) {

src/main/java/net/openhft/compiler/MyJavaFileManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,4 @@ private <T> T invokeNamedMethodIfAvailable(final Location location, final String
222222
}
223223
throw new UnsupportedOperationException("Unable to find method " + name);
224224
}
225-
}
225+
}

src/test/java/eg/components/Foo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package eg.components;
2020

21-
@SuppressWarnings({"QuestionableName"})
21+
@SuppressWarnings("QuestionableName")
2222
public class Foo {
2323
public final Bar bar;
2424
public final Bar copy;

src/test/java/mytest/RuntimeCompileTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,3 @@ public void testMultiThread() throws Exception {
108108
assertEquals(nThreads, consumer.getAsInt());
109109
}
110110
}
111-

src/test/java/net/openhft/compiler/CompilerTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void test_compiler() throws Throwable {
6666

6767
String text = "generated test " + new Date();
6868
try {
69-
final Class aClass =
69+
final Class<?> aClass =
7070
cc.loadFromJava(EG_FOO_BAR_TEE + 3, "package eg;\n" +
7171
'\n' +
7272
"import eg.components.BarImpl;\n" +
@@ -112,7 +112,7 @@ public void test_compiler() throws Throwable {
112112
public void test_fromFile()
113113
throws ClassNotFoundException, IOException, IllegalAccessException, InstantiationException,
114114
NoSuchMethodException, InvocationTargetException, NoSuchFieldException {
115-
Class clazz = CompilerUtils.loadFromResource("eg.FooBarTee2", "eg/FooBarTee2.jcf");
115+
Class<?> clazz = CompilerUtils.loadFromResource("eg.FooBarTee2", "eg/FooBarTee2.jcf");
116116
// turn off System.out
117117
PrintStream out = System.out;
118118
try {
@@ -269,7 +269,7 @@ public void test_compilerErrorsDoNotBreakNextCompilations() throws Exception {
269269
}
270270

271271
// ensure next class can be compiled and used
272-
Class testClass = CompilerUtils.CACHED_COMPILER.loadFromJava(
272+
Class<?> testClass = CompilerUtils.CACHED_COMPILER.loadFromJava(
273273
getClass().getClassLoader(), "S", "class S {" +
274274
"public static final String s = \"ok\";}");
275275

@@ -292,11 +292,10 @@ public void testNewCompiler() throws Exception {
292292
ClassLoader classLoader = new ClassLoader() {
293293
};
294294
CachedCompiler cc = new CachedCompiler(null, null);
295-
Class a = cc.loadFromJava(classLoader, "A", "public class A { static int i = " + i + "; }");
296-
Class b = cc.loadFromJava(classLoader, "B", "public class B implements net.openhft.compiler.MyIntSupplier { public int get() { return A.i; } }");
295+
Class<?> a = cc.loadFromJava(classLoader, "A", "public class A { static int i = " + i + "; }");
296+
Class<?> b = cc.loadFromJava(classLoader, "B", "public class B implements net.openhft.compiler.MyIntSupplier { public int get() { return A.i; } }");
297297
MyIntSupplier bi = (MyIntSupplier) b.getDeclaredConstructor().newInstance();
298298
assertEquals(i, bi.get());
299299
}
300300
}
301301
}
302-

0 commit comments

Comments
 (0)