@ -29,6 +29,7 @@ import java.util.jar.JarFile;
import java.util.jar.Manifest ;
import org.springframework.boot.loader.tools.JarWriter.EntryTransformer ;
import org.springframework.lang.UsesJava8 ;
/ * *
* Utility class that can be used to repackage an archive so that it can be executed using
@ -339,19 +340,49 @@ public class Repackager {
}
renamedEntry . setCompressedSize ( entry . getCompressedSize ( ) ) ;
renamedEntry . setCrc ( entry . getCrc ( ) ) ;
if ( entry . getCreationTime ( ) ! = null ) {
renamedEntry . setCreationTime ( entry . getCreationTime ( ) ) ;
}
setCreationTimeIfPossible ( entry , renamedEntry ) ;
if ( entry . getExtra ( ) ! = null ) {
renamedEntry . setExtra ( entry . getExtra ( ) ) ;
}
if ( entry . getLastAccessTime ( ) ! = null ) {
renamedEntry . setLastAccessTime ( entry . getLastAccessTime ( ) ) ;
setLastAccessTimeIfPossible ( entry , renamedEntry ) ;
setLastModifiedTimeIfPossible ( entry , renamedEntry ) ;
return renamedEntry ;
}
@UsesJava8
private void setCreationTimeIfPossible ( JarEntry source , JarEntry target ) {
try {
if ( source . getCreationTime ( ) ! = null ) {
target . setCreationTime ( source . getCreationTime ( ) ) ;
}
}
if ( entry . getLastModifiedTime ( ) ! = null ) {
renamedEntry . setLastModifiedTime ( entry . getLastModifiedTime ( ) ) ;
catch ( NoSuchMethodError ex ) {
// Not running on Java 8. Continue.
}
}
@UsesJava8
private void setLastAccessTimeIfPossible ( JarEntry source , JarEntry target ) {
try {
if ( source . getLastAccessTime ( ) ! = null ) {
target . setLastAccessTime ( source . getLastAccessTime ( ) ) ;
}
}
catch ( NoSuchMethodError ex ) {
// Not running on Java 8. Continue.
}
}
@UsesJava8
private void setLastModifiedTimeIfPossible ( JarEntry source , JarEntry target ) {
try {
if ( source . getLastModifiedTime ( ) ! = null ) {
target . setLastModifiedTime ( source . getLastModifiedTime ( ) ) ;
}
}
catch ( NoSuchMethodError ex ) {
// Not running on Java 8. Continue.
}
return renamedEntry ;
}
}