Skip to content

Commit 61dfeb2

Browse files
committed
Merge pull request #12 from ctomc/jdk9
Make it work also on JDK9 with new versioning scheme
2 parents 6d4d4b1 + c0357c5 commit 61dfeb2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.codehaus.plexus.util.FileUtils;
3535
import org.codehaus.plexus.util.IOUtil;
3636

37-
import javax.annotation.WillClose;
3837
import java.io.ByteArrayInputStream;
3938
import java.io.File;
4039
import java.io.FileOutputStream;
@@ -119,8 +118,7 @@ public abstract class AbstractZipArchiver
119118
* Java versions from 8 and up round timestamp up.
120119
* s
121120
*/
122-
private static final boolean isJava7OrLower =
123-
Integer.parseInt( System.getProperty( "java.version" ).split( "\\." )[1] ) <= 7;
121+
private static final boolean isJava7OrLower = getJavaVersion()<= 7;
124122

125123
// Renamed version of original file, if it exists
126124
private File renamedFile = null;
@@ -133,6 +131,16 @@ public abstract class AbstractZipArchiver
133131

134132
protected ZipArchiveOutputStream zipArchiveOutputStream;
135133

134+
private static int getJavaVersion(){
135+
String javaSpecVersion = System.getProperty( "java.specification.version" );
136+
if (javaSpecVersion.contains(".")) {//before jdk 9
137+
return Integer.parseInt(javaSpecVersion.split("\\.")[1]);
138+
}else {
139+
return Integer.parseInt(javaSpecVersion);
140+
}
141+
}
142+
143+
136144
public String getComment()
137145
{
138146
return comment;

0 commit comments

Comments
 (0)