Skip to content

Commit

Permalink
ISPN-3974 Make it compile with JDK8
Browse files Browse the repository at this point in the history
* Module name calculation in javascript driven Server/AS/Wildfly
now works with both JDK7 and JDK8 by trying a split/join and if it
does not work, use a replace.
* spliterator() method name clashes with a new spliterator() method
introduced in java.util.Collection for JDK8, so name it differently
* Enable animal-sniffer maven plugin only when JDK7 is used since
it does not yet work with JDK8 (not even latest version 1.10).
  • Loading branch information
galderz authored and danberindei committed Feb 19, 2014
1 parent ba7c390 commit fbe7b16
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 66 deletions.
4 changes: 0 additions & 4 deletions as-modules/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
<maven-resource group="org.infinispan" artifact="infinispan-core" />
</module-def>

<module-def name="org.infinispan.cachestore.jdbc" slot="${infinispan.slot}" />

<module-def name="org.infinispan.cachestore.remote" slot="${infinispan.slot}" />

<module-def name="org.infinispan.persistence.jdbc" slot="${infinispan.slot}">
<maven-resource group="org.infinispan" artifact="infinispan-cachestore-jdbc" />
</module-def>
Expand Down
18 changes: 16 additions & 2 deletions as-modules/lib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@
<attribute name="slot"/>
<![CDATA[
name = attributes.get("name");
name = name.replace(".", "/");
name = name.split(".").join("/");
if (name) {
self.log("Use JDK8 method to build module names");
} else {
name = attributes.get("name");
name = name.replace(".", "/");
self.log("Use JDK7 method to build module names");
}
project.setProperty("source.module.path", name + "/main");
project.setProperty("current.module.path", name + "/" + attributes.get("slot"));
]]>
Expand All @@ -98,7 +105,14 @@
<attribute name="slot"/>
<![CDATA[
name = attributes.get("name");
name = name.replace(".", "/");
name = name.split(".").join("/");
if (name) {
self.log("Use JDK8 method to build module names");
} else {
name = attributes.get("name");
name = name.replace(".", "/");
self.log("Use JDK7 method to build module names");
}
project.setProperty("current.bundle.path", name + "/" + attributes.get("slot"));
]]>
</scriptdef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4552,7 +4552,7 @@ public boolean equals(Object o) {
(containsAll(c) && c.containsAll(this))));
}

public ConcurrentHashMapSpliterator<K> spliterator() {
public ConcurrentHashMapSpliterator<K> spliteratorV8() {
Node<K,V>[] t;
EquivalentConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down Expand Up @@ -4610,7 +4610,7 @@ public final boolean addAll(Collection<? extends V> c) {
throw new UnsupportedOperationException();
}

public ConcurrentHashMapSpliterator<V> spliterator() {
public ConcurrentHashMapSpliterator<V> spliteratorV8() {
Node<K,V>[] t;
EquivalentConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down Expand Up @@ -4699,7 +4699,7 @@ public final boolean equals(Object o) {
(containsAll(c) && c.containsAll(this))));
}

public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliterator() {
public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliteratorV8() {
Node<K,V>[] t;
EquivalentConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4515,7 +4515,7 @@ public boolean equals(Object o) {
(containsAll(c) && c.containsAll(this))));
}

public ConcurrentHashMapSpliterator<K> spliterator() {
public ConcurrentHashMapSpliterator<K> spliteratorV8() {
Node<K,V>[] t;
ConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down Expand Up @@ -4573,7 +4573,7 @@ public final boolean addAll(Collection<? extends V> c) {
throw new UnsupportedOperationException();
}

public ConcurrentHashMapSpliterator<V> spliterator() {
public ConcurrentHashMapSpliterator<V> spliteratorV8() {
Node<K,V>[] t;
ConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down Expand Up @@ -4661,7 +4661,7 @@ public final boolean equals(Object o) {
(containsAll(c) && c.containsAll(this))));
}

public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliterator() {
public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliteratorV8() {
Node<K,V>[] t;
ConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down
60 changes: 34 additions & 26 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<version.webdav.servlet>2.0.1</version.webdav.servlet>
<version.weld>1.1.13.Final</version.weld>
<version.wildfly>8.0.0.Beta1</version.wildfly>
<version.javassist>3.15.0-GA</version.javassist>
<version.javassist>3.18.0-GA</version.javassist>
<version.maven.animal.sniffer>1.9</version.maven.animal.sniffer>
<version.maven.buildhelper>1.8</version.maven.buildhelper>
<version.maven.bundle>2.4.0</version.maven.bundle>
Expand Down Expand Up @@ -1149,30 +1149,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>${version.maven.animal.sniffer}</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.0</version>
</signature>
<ignores>
<ignore>sun.misc.Unsafe</ignore>
<ignore>org.apache.lucene.store.IOContext</ignore>
</ignores>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.1</version>
Expand Down Expand Up @@ -1901,6 +1877,38 @@
</plugins>
</build>
</profile>

<profile>
<activation>
<jdk>1.7</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>${version.maven.animal.sniffer}</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.0</version>
</signature>
<ignores>
<ignore>sun.misc.Unsafe</ignore>
<ignore>org.apache.lucene.store.IOContext</ignore>
</ignores>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
18 changes: 16 additions & 2 deletions server/integration/build/lib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@
<attribute name="slot"/>
<![CDATA[
name = attributes.get("name");
name = name.replace(".", "/");
name = name.split(".").join("/");
if (name) {
self.log("Use JDK8 method to build module names");
} else {
name = attributes.get("name");
name = name.replace(".", "/");
self.log("Use JDK7 method to build module names");
}
project.setProperty("current.module.path", name + "/" + attributes.get("slot"));
]]>
</scriptdef>
Expand All @@ -121,7 +128,14 @@
<attribute name="slot"/>
<![CDATA[
name = attributes.get("name");
name = name.replace(".", "/");
name = name.split(".").join("/");
if (name) {
self.log("Use JDK8 method to build module names");
} else {
name = attributes.get("name");
name = name.replace(".", "/");
self.log("Use JDK7 method to build module names");
}
project.setProperty("current.bundle.path", name + "/" + attributes.get("slot"));
]]>
</scriptdef>
Expand Down
57 changes: 33 additions & 24 deletions server/integration/versions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -456,30 +456,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.0</version>
</signature>
<ignores>
<ignore>sun.misc.Unsafe</ignore>
<ignore>org.apache.lucene.store.IOContext</ignore>
</ignores>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
Expand All @@ -498,6 +474,39 @@
<maven.test.skip.exec>true</maven.test.skip.exec>
</properties>
</profile>
<profile>
<activation>
<jdk>1.7</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.0</version>
</signature>
<ignores>
<ignore>sun.misc.Unsafe</ignore>
<ignore>org.apache.lucene.store.IOContext</ignore>
</ignores>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
22 changes: 20 additions & 2 deletions tools/src/main/java/org/infinispan/tools/doclet/jmx/JmxDoclet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
Expand Down Expand Up @@ -64,7 +66,7 @@ private static String jmxTitle() {
}

public static int optionLength(String option) {
return (ConfigurationImpl.getInstance()).optionLength(option);
return (createConfigurationImpl()).optionLength(option);
}

public static boolean validOptions(String options[][], DocErrorReporter reporter) {
Expand All @@ -77,7 +79,23 @@ public static boolean validOptions(String options[][], DocErrorReporter reporter
else if (option[0].equals("-header")) header = option[1];
else if (option[0].equals("-doctitle")) title = option[1];
}
return (ConfigurationImpl.getInstance()).validOptions(options, reporter);
return (createConfigurationImpl()).validOptions(options, reporter);
}

private static ConfigurationImpl createConfigurationImpl() {
try {
// Deal with JDK7/JDK8 differences
Method getInstanceMethod = ConfigurationImpl.class.getMethod("getInstance");
return (ConfigurationImpl) getInstanceMethod.invoke(null);
} catch (NoSuchMethodException e) {
try {
return ConfigurationImpl.class.newInstance();
} catch (Exception e1) {
throw new RuntimeException(e1);
}
} catch (Exception e1) {
throw new RuntimeException(e1);
}
}

private static MBeanComponent toJmxComponent(ClassDoc cd) {
Expand Down

0 comments on commit fbe7b16

Please sign in to comment.