You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2020/08/21 21:58:27 UTC

[royale-compiler] branch develop updated (9c4338a -> fbe3ab8)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git.


    from 9c4338a  compiler: allow classes with private constructors to be used for function-style casts
     new 872574b  COMPJSC: always use / in the file entry path when including .js.map files into SWCs
     new 3b7040f  COMPJSC: reduce duplicate code for writing zip file entries to SWCs
     new fbe3ab8  COMPJSC: fix issue where .js files from one .swc file on the library-path were not copied to the new .swc file

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/royale/compiler/clients/COMPJSC.java    | 163 +++++++++++++-------
 .../royale/compiler/clients/COMPJSCNative.java     | 131 ++++++++++++++--
 .../royale/compiler/clients/COMPJSCRoyale.java     | 165 ++++++++++++++-------
 3 files changed, 336 insertions(+), 123 deletions(-)


[royale-compiler] 03/03: COMPJSC: fix issue where .js files from one .swc file on the library-path were not copied to the new .swc file

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit fbe3ab86c444ba640ba78cec7d7a32040a7a925e
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Fri Aug 21 14:48:55 2020 -0700

    COMPJSC: fix issue where .js files from one .swc file on the library-path were not copied to the new .swc file
    
    The bytecode was being included, but not the corresponding .js file. Both are required, and this broke the app compiler, which couldn't figure out where to find the .js file. To exclude both the bytecode and .js file, then the .swc file should be added to the external-library-path instead of the library-path.
---
 .../apache/royale/compiler/clients/COMPJSC.java    | 60 ++++++++++++++++++++++
 .../royale/compiler/clients/COMPJSCNative.java     | 60 ++++++++++++++++++++++
 .../royale/compiler/clients/COMPJSCRoyale.java     | 60 ++++++++++++++++++++++
 3 files changed, 180 insertions(+)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
index 5c058b9..c61356a 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
@@ -50,6 +50,7 @@ import org.apache.royale.compiler.exceptions.ConfigurationException.MustSpecifyT
 import org.apache.royale.compiler.internal.driver.js.goog.JSGoogCompcConfiguration;
 import org.apache.royale.compiler.internal.projects.CompilerProject;
 import org.apache.royale.compiler.internal.targets.RoyaleSWCTarget;
+import org.apache.royale.compiler.internal.units.SWCCompilationUnit;
 import org.apache.royale.compiler.internal.targets.JSTarget;
 import org.apache.royale.compiler.problems.ICompilerProblem;
 import org.apache.royale.compiler.problems.InternalCompilerProblem;
@@ -59,6 +60,7 @@ import org.apache.royale.compiler.problems.UnexpectedExceptionProblem;
 import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
+import org.apache.royale.swc.ISWCFileEntry;
 import org.apache.royale.swc.io.SWCReader;
 import org.apache.royale.utils.ArgumentUtil;
 
@@ -517,6 +519,64 @@ public class COMPJSC extends MXMLJSC
                             writer.close();
                         }
                     }
+                    else if (cuType == ICompilationUnit.UnitType.SWC_UNIT)
+                    {
+                    	String symbol = cu.getQualifiedNames().get(0);
+                    	if (externs.contains(symbol)) continue;
+                    	if (project.isExternalLinkage(cu)) continue;
+                    	if (!packingSWC)
+                    	{
+                            // we probably shouldn't skip this -JT
+                            continue;
+                        }
+
+                        // if another .swc file is on our library-path, we must
+                        // include the .js (and .js.map) files because the
+                        // bytecode will also be included. if we have the
+                        // bytecode, but not the .js files, the compiler won't
+                        // know where to find the .js files. that's really bad.
+
+                        // if the bytecode and .js files should not be included,
+                        // then the developer is expected to use
+                        // external-library-path instead of library-path.
+
+                        SWCCompilationUnit swcCU = (SWCCompilationUnit) cu;
+                        String outputClassFile = getOutputClassFile(
+                                cu.getQualifiedNames().get(0),
+                                jsOut,
+                                false).getPath();
+                        outputClassFile = outputClassFile.replace('\\', '/');
+                        ISWCFileEntry fileEntry = swcCU.getSWC().getFile(outputClassFile);
+                        if (fileEntry == null)
+                        {
+                            continue;
+                        }
+                        if (config.isVerbose())
+                        {
+                            System.out.println("Writing file: " + outputClassFile + " from SWC: " + swcCU.getAbsoluteFilename());
+                        }
+                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        InputStream fileStream = fileEntry.createInputStream();
+                        IOUtils.copy(fileStream, baos);
+                        fileStream.close();
+                        writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
+
+                        String outputMapFile = outputClassFile + ".map";
+                        fileEntry = swcCU.getSWC().getFile(outputMapFile);
+                        if (fileEntry == null)
+                        {
+                            continue;
+                        }
+                        if (config.isVerbose())
+                        {
+                            System.out.println("Writing file: " + outputMapFile + " from SWC: " + swcCU.getAbsoluteFilename());
+                        }
+                        baos = new ByteArrayOutputStream();
+                        fileStream = fileEntry.createInputStream();
+                        IOUtils.copy(fileStream, baos);
+                        fileStream.close();
+                        writeFileToZip(zipOutputStream, outputMapFile, baos, fileList);
+                    }
                 }
                 if (packingSWC)
                 {
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
index e2b3d11..125e93d 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
@@ -59,6 +59,7 @@ import org.apache.royale.compiler.internal.parsing.as.RoyaleASDocDelegate;
 import org.apache.royale.compiler.internal.projects.CompilerProject;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
 import org.apache.royale.compiler.internal.targets.RoyaleSWCTarget;
+import org.apache.royale.compiler.internal.units.SWCCompilationUnit;
 import org.apache.royale.compiler.internal.targets.JSTarget;
 import org.apache.royale.compiler.internal.workspaces.Workspace;
 import org.apache.royale.compiler.problems.ICompilerProblem;
@@ -68,6 +69,7 @@ import org.apache.royale.compiler.problems.UnableToBuildSWFProblem;
 import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
+import org.apache.royale.swc.ISWCFileEntry;
 import org.apache.royale.swc.io.SWCReader;
 
 /**
@@ -382,6 +384,64 @@ public class COMPJSCNative extends MXMLJSCNative
                             writer.close();
                         }
                     }
+                    else if (cuType == ICompilationUnit.UnitType.SWC_UNIT)
+                    {
+                    	String symbol = cu.getQualifiedNames().get(0);
+                    	if (externs.contains(symbol)) continue;
+                    	if (project.isExternalLinkage(cu)) continue;
+                    	if (!packingSWC)
+                    	{
+                            // we probably shouldn't skip this -JT
+                            continue;
+                        }
+
+                        // if another .swc file is on our library-path, we must
+                        // include the .js (and .js.map) files because the
+                        // bytecode will also be included. if we have the
+                        // bytecode, but not the .js files, the compiler won't
+                        // know where to find the .js files. that's really bad.
+
+                        // if the bytecode and .js files should not be included,
+                        // then the developer is expected to use
+                        // external-library-path instead of library-path.
+
+                        SWCCompilationUnit swcCU = (SWCCompilationUnit) cu;
+                        String outputClassFile = getOutputClassFile(
+                                cu.getQualifiedNames().get(0),
+                                jsOut,
+                                false).getPath();
+                        outputClassFile = outputClassFile.replace('\\', '/');
+                        ISWCFileEntry fileEntry = swcCU.getSWC().getFile(outputClassFile);
+                        if (fileEntry == null)
+                        {
+                            continue;
+                        }
+                        if (config.isVerbose())
+                        {
+                            System.out.println("Writing file: " + outputClassFile + " from SWC: " + swcCU.getAbsoluteFilename());
+                        }
+                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        InputStream fileStream = fileEntry.createInputStream();
+                        IOUtils.copy(fileStream, baos);
+                        fileStream.close();
+                        writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
+
+                        String outputMapFile = outputClassFile + ".map";
+                        fileEntry = swcCU.getSWC().getFile(outputMapFile);
+                        if (fileEntry == null)
+                        {
+                            continue;
+                        }
+                        if (config.isVerbose())
+                        {
+                            System.out.println("Writing file: " + outputMapFile + " from SWC: " + swcCU.getAbsoluteFilename());
+                        }
+                        baos = new ByteArrayOutputStream();
+                        fileStream = fileEntry.createInputStream();
+                        IOUtils.copy(fileStream, baos);
+                        fileStream.close();
+                        writeFileToZip(zipOutputStream, outputMapFile, baos, fileList);
+                    }
                 }
                 if (packingSWC)
                 {
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
index 4ed9d8c..366de7e 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
@@ -51,6 +51,7 @@ import org.apache.royale.compiler.internal.parsing.as.RoyaleASDocDelegate;
 import org.apache.royale.compiler.internal.projects.CompilerProject;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
 import org.apache.royale.compiler.internal.targets.RoyaleSWCTarget;
+import org.apache.royale.compiler.internal.units.SWCCompilationUnit;
 import org.apache.royale.compiler.internal.targets.JSTarget;
 import org.apache.royale.compiler.internal.workspaces.Workspace;
 import org.apache.royale.compiler.problems.ICompilerProblem;
@@ -61,6 +62,7 @@ import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
 import org.apache.royale.compiler.units.ICompilationUnit.UnitType;
+import org.apache.royale.swc.ISWCFileEntry;
 import org.apache.royale.swc.io.SWCReader;
 
 /**
@@ -404,6 +406,64 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                        writer.close();
                     	}
                     }
+                    else if (cuType == ICompilationUnit.UnitType.SWC_UNIT)
+                    {
+                    	String symbol = cu.getQualifiedNames().get(0);
+                    	if (externs.contains(symbol)) continue;
+                    	if (project.isExternalLinkage(cu)) continue;
+                    	if (!packingSWC)
+                    	{
+                            // we probably shouldn't skip this -JT
+                            continue;
+                        }
+
+                        // if another .swc file is on our library-path, we must
+                        // include the .js (and .js.map) files because the
+                        // bytecode will also be included. if we have the
+                        // bytecode, but not the .js files, the compiler won't
+                        // know where to find the .js files. that's really bad.
+
+                        // if the bytecode and .js files should not be included,
+                        // then the developer is expected to use
+                        // external-library-path instead of library-path.
+
+                        SWCCompilationUnit swcCU = (SWCCompilationUnit) cu;
+                        String outputClassFile = getOutputClassFile(
+                                cu.getQualifiedNames().get(0),
+                                jsOut,
+                                false).getPath();
+                        outputClassFile = outputClassFile.replace('\\', '/');
+                        ISWCFileEntry fileEntry = swcCU.getSWC().getFile(outputClassFile);
+                        if (fileEntry == null)
+                        {
+                            continue;
+                        }
+                        if (config.isVerbose())
+                        {
+                            System.out.println("Writing file: " + outputClassFile + " from SWC: " + swcCU.getAbsoluteFilename());
+                        }
+                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        InputStream fileStream = fileEntry.createInputStream();
+                        IOUtils.copy(fileStream, baos);
+                        fileStream.close();
+                        writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
+
+                        String outputMapFile = outputClassFile + ".map";
+                        fileEntry = swcCU.getSWC().getFile(outputMapFile);
+                        if (fileEntry == null)
+                        {
+                            continue;
+                        }
+                        if (config.isVerbose())
+                        {
+                            System.out.println("Writing file: " + outputMapFile + " from SWC: " + swcCU.getAbsoluteFilename());
+                        }
+                        baos = new ByteArrayOutputStream();
+                        fileStream = fileEntry.createInputStream();
+                        IOUtils.copy(fileStream, baos);
+                        fileStream.close();
+                        writeFileToZip(zipOutputStream, outputMapFile, baos, fileList);
+                    }
                 }
                 if (!config.getCreateTargetWithErrors())
                 {


[royale-compiler] 01/03: COMPJSC: always use / in the file entry path when including .js.map files into SWCs

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 872574b016b2f0cc686409d4f401908f887eff12
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Fri Aug 21 14:17:11 2020 -0700

    COMPJSC: always use / in the file entry path when including .js.map files into SWCs
    
    This matches the behavior of how .js files are included, which seems to have been started as part of making reproducible builds.
---
 .../src/main/java/org/apache/royale/compiler/clients/COMPJSC.java       | 1 +
 .../src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java | 2 ++
 .../src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java | 1 +
 3 files changed, 4 insertions(+)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
index 2d42011..979d70e 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
@@ -544,6 +544,7 @@ public class COMPJSC extends MXMLJSC
                                     cu.getQualifiedNames().get(0),
                                     isExterns ? externsOut : jsOut,
                                     false).getPath();
+                                sourceMapFile = sourceMapFile.replace('\\', '/');
                                 if (config.isVerbose())
                                 {
                                     System.out.println("Writing file: " + sourceMapFile);
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
index 57d2ead..7f85f76 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
@@ -347,6 +347,7 @@ public class COMPJSCNative extends MXMLJSCNative
                                     cu.getQualifiedNames().get(0),
                                     isExterns ? externsOut : jsOut,
                                     false).getPath();
+                            outputClassFile = outputClassFile.replace('\\', '/');
                             if (config.isVerbose())
                             {
                                 System.out.println("Writing file: " + outputClassFile);     	
@@ -362,6 +363,7 @@ public class COMPJSCNative extends MXMLJSCNative
                                     cu.getQualifiedNames().get(0),
                                     isExterns ? externsOut : jsOut,
                                     false).getPath();
+                                sourceMapFile = sourceMapFile.replace('\\', '/');
                                 if (config.isVerbose())
                                 {
                                     System.out.println("Writing file: " + sourceMapFile);
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
index a370772..ed38c4b 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
@@ -431,6 +431,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                                                                                 cu.getQualifiedNames().get(0),
                                                                                 isExterns ? externsOut : jsOut,
                                                                                 false).getPath();
+                                sourceMapFile = sourceMapFile.replace('\\', '/');
                                 if (config.isVerbose())
                                 {
                                     System.out.println("Writing file: " + sourceMapFile);


[royale-compiler] 02/03: COMPJSC: reduce duplicate code for writing zip file entries to SWCs

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 3b7040f6a32102ca61f29b4738708ff887f80868
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Fri Aug 21 14:29:32 2020 -0700

    COMPJSC: reduce duplicate code for writing zip file entries to SWCs
---
 .../apache/royale/compiler/clients/COMPJSC.java    | 102 +++++++++-----------
 .../royale/compiler/clients/COMPJSCNative.java     |  69 ++++++++++++--
 .../royale/compiler/clients/COMPJSCRoyale.java     | 104 ++++++++++-----------
 3 files changed, 152 insertions(+), 123 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
index 979d70e..5c058b9 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
@@ -496,48 +496,9 @@ public class COMPJSC extends MXMLJSC
                             {
                                 System.out.println("Writing file: " + outputClassFile);     	
                             }
-	                        long fileDate = System.currentTimeMillis();
-	                        long zipFileDate = fileDate;
-	                    	String metadataDate = targetSettings.getSWFMetadataDate();
-	                    	if (metadataDate != null)
-	                    	{
-	                    		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
-	                    		try {
-	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-	                    			Date d = sdf.parse(metadataDate);
-	                    			Calendar cal = new GregorianCalendar();
-	                    			cal.setTime(d);
-	                                sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
-	                    			d = sdf.parse(metadataDate);
-	                    			fileDate = d.getTime();
-	                    			ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
-	                    									cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
-	                    			zipFileDate = zdt.toInstant().toEpochMilli();
-	                    		} catch (ParseException e) {
-	                				// TODO Auto-generated catch block
-	                				e.printStackTrace();
-	                			} catch (IllegalArgumentException e1) {
-	                				e1.printStackTrace();
-	                			}
-	                    	}
-	                    	ZipEntry ze = new ZipEntry(outputClassFile);
-	                    	ze.setTime(zipFileDate);
-	                    	ze.setMethod(ZipEntry.STORED);
-	                    	
 	                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
 	                        temp.writeTo(baos);
-	                        ze.setSize(baos.size());
-	                        ze.setCompressedSize(baos.size());
-	                        CRC32 crc = new CRC32();
-	                        crc.reset();
-	                        crc.update(baos.toByteArray());
-	                        ze.setCrc(crc.getValue());
-
-	                        zipOutputStream.putNextEntry(ze);
-	                        baos.writeTo(zipOutputStream);
-                            zipOutputStream.flush();
-	                        zipOutputStream.closeEntry();
-	                        fileList.append("        <file path=\"" + outputClassFile + "\" mod=\"" + fileDate + "\"/>\n");
+                            writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
                             if(sourceMapTemp != null)
                             {
                                 String sourceMapFile = getOutputSourceMapFile(
@@ -549,24 +510,9 @@ public class COMPJSC extends MXMLJSC
                                 {
                                     System.out.println("Writing file: " + sourceMapFile);
                                 }
-                                ze = new ZipEntry(sourceMapFile);
-    	                    	ze.setTime(zipFileDate);
-    	                    	ze.setMethod(ZipEntry.STORED);
-    	                    	
     	                        baos = new ByteArrayOutputStream();
                                 sourceMapTemp.writeTo(baos);
-    	                        ze.setSize(baos.size());
-    	                        ze.setCompressedSize(baos.size());
-    	                        crc = new CRC32();
-    	                        crc.reset();
-    	                        crc.update(baos.toByteArray());
-    	                        ze.setCrc(crc.getValue());
-                                
-                                zipOutputStream.putNextEntry(ze);
-    	                        baos.writeTo(zipOutputStream);
-                                zipOutputStream.flush();
-                                zipOutputStream.closeEntry();
-                                fileList.append("        <file path=\"" + sourceMapFile + "\" mod=\"" + fileDate + "\"/>\n");
+                                writeFileToZip(zipOutputStream, sourceMapFile, baos, fileList);
                             }
                             writer.close();
                         }
@@ -670,6 +616,50 @@ public class COMPJSC extends MXMLJSC
         return compilationSuccess;
     }
 
+    private void writeFileToZip(ZipOutputStream zipOutputStream, String entryFilePath, ByteArrayOutputStream baos, StringBuilder fileList) throws IOException
+    {
+        long fileDate = System.currentTimeMillis();
+        long zipFileDate = fileDate;
+        String metadataDate = targetSettings.getSWFMetadataDate();
+        if (metadataDate != null)
+        {
+            String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+            try {
+                SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+                Date d = sdf.parse(metadataDate);
+                Calendar cal = new GregorianCalendar();
+                cal.setTime(d);
+                sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+                d = sdf.parse(metadataDate);
+                fileDate = d.getTime();
+                ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
+                                        cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
+                zipFileDate = zdt.toInstant().toEpochMilli();
+            } catch (ParseException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (IllegalArgumentException e1) {
+                e1.printStackTrace();
+            }
+        }
+        ZipEntry ze = new ZipEntry(entryFilePath);
+        ze.setTime(zipFileDate);
+        ze.setMethod(ZipEntry.STORED);
+        
+        ze.setSize(baos.size());
+        ze.setCompressedSize(baos.size());
+        CRC32 crc = new CRC32();
+        crc.reset();
+        crc.update(baos.toByteArray());
+        ze.setCrc(crc.getValue());
+
+        zipOutputStream.putNextEntry(ze);
+        baos.writeTo(zipOutputStream);
+        zipOutputStream.flush();
+        zipOutputStream.closeEntry();
+        fileList.append("        <file path=\"" + entryFilePath + "\" mod=\"" + fileDate + "\"/>\n");
+    }
+
     /**
      * Build target artifact.
      * 
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
index 7f85f76..e2b3d11 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
@@ -26,11 +26,20 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Enumeration;
+import java.util.GregorianCalendar;
 import java.util.List;
 import java.util.Set;
+import java.util.TimeZone;
+import java.util.zip.CRC32;
 import java.util.zip.Deflater;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -352,11 +361,9 @@ public class COMPJSCNative extends MXMLJSCNative
                             {
                                 System.out.println("Writing file: " + outputClassFile);     	
                             }
-	                        zipOutputStream.putNextEntry(new ZipEntry(outputClassFile));
-	                        temp.writeTo(zipOutputStream);
-                            zipOutputStream.flush();
-	                        zipOutputStream.closeEntry();
-	                        fileList.append("        <file path=\"" + outputClassFile + "\" mod=\"" + System.currentTimeMillis() + "\"/>\n");
+	                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	                        temp.writeTo(baos);
+                            writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
                             if(sourceMapTemp != null)
                             {
                                 String sourceMapFile = getOutputSourceMapFile(
@@ -368,11 +375,9 @@ public class COMPJSCNative extends MXMLJSCNative
                                 {
                                     System.out.println("Writing file: " + sourceMapFile);
                                 }
-                                zipOutputStream.putNextEntry(new ZipEntry(sourceMapFile));
-                                sourceMapTemp.writeTo(zipOutputStream);
-                                zipOutputStream.flush();
-                                zipOutputStream.closeEntry();
-                                fileList.append("        <file path=\"" + sourceMapFile + "\" mod=\"" + System.currentTimeMillis() + "\"/>\n");
+    	                        baos = new ByteArrayOutputStream();
+                                sourceMapTemp.writeTo(baos);
+                                writeFileToZip(zipOutputStream, sourceMapFile, baos, fileList);
                             }
                             writer.close();
                         }
@@ -408,6 +413,50 @@ public class COMPJSCNative extends MXMLJSCNative
         return compilationSuccess;
     }
 
+    private void writeFileToZip(ZipOutputStream zipOutputStream, String entryFilePath, ByteArrayOutputStream baos, StringBuilder fileList) throws IOException
+    {
+        long fileDate = System.currentTimeMillis();
+        long zipFileDate = fileDate;
+        String metadataDate = targetSettings.getSWFMetadataDate();
+        if (metadataDate != null)
+        {
+            String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+            try {
+                SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+                Date d = sdf.parse(metadataDate);
+                Calendar cal = new GregorianCalendar();
+                cal.setTime(d);
+                sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+                d = sdf.parse(metadataDate);
+                fileDate = d.getTime();
+                ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
+                                        cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
+                zipFileDate = zdt.toInstant().toEpochMilli();
+            } catch (ParseException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (IllegalArgumentException e1) {
+                e1.printStackTrace();
+            }
+        }
+        ZipEntry ze = new ZipEntry(entryFilePath);
+        ze.setTime(zipFileDate);
+        ze.setMethod(ZipEntry.STORED);
+        
+        ze.setSize(baos.size());
+        ze.setCompressedSize(baos.size());
+        CRC32 crc = new CRC32();
+        crc.reset();
+        crc.update(baos.toByteArray());
+        ze.setCrc(crc.getValue());
+
+        zipOutputStream.putNextEntry(ze);
+        baos.writeTo(zipOutputStream);
+        zipOutputStream.flush();
+        zipOutputStream.closeEntry();
+        fileList.append("        <file path=\"" + entryFilePath + "\" mod=\"" + fileDate + "\"/>\n");
+    }
+
     /**
      * Build target artifact.
      * 
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
index ed38c4b..4ed9d8c 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
@@ -382,48 +382,9 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                             {
                                 System.out.println("Writing file: " + outputClassFile);     	
                             }
-	                        long fileDate = System.currentTimeMillis();
-	                        long zipFileDate = fileDate;
-	                    	String metadataDate = targetSettings.getSWFMetadataDate();
-	                    	if (metadataDate != null)
-	                    	{
-	                    		String metadataFormat = targetSettings.getSWFMetadataDateFormat();
-	                    		try {
-	                    			SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
-	                    			Date d = sdf.parse(metadataDate);
-	                    			Calendar cal = new GregorianCalendar();
-	                    			cal.setTime(d);
-	                                sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
-	                    			d = sdf.parse(metadataDate);
-	                    			fileDate = d.getTime();
-	                    			ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
-	                    									cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
-	                    			zipFileDate = zdt.toInstant().toEpochMilli();
-	                    		} catch (ParseException e) {
-	                				// TODO Auto-generated catch block
-	                				e.printStackTrace();
-	                			} catch (IllegalArgumentException e1) {
-	                				e1.printStackTrace();
-	                			}
-	                    	}
-	                    	ZipEntry ze = new ZipEntry(outputClassFile);
-	                    	ze.setTime(zipFileDate);
-	                    	ze.setMethod(ZipEntry.STORED);
-	                    	
 	                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-	                        temp.writeTo(baos);
-	                        ze.setSize(baos.size());
-	                        ze.setCompressedSize(baos.size());
-	                        CRC32 crc = new CRC32();
-	                        crc.reset();
-	                        crc.update(baos.toByteArray());
-	                        ze.setCrc(crc.getValue());
-
-	                        zipOutputStream.putNextEntry(ze);
-	                        baos.writeTo(zipOutputStream);
-                            zipOutputStream.flush();
-                            zipOutputStream.closeEntry();
-                            fileList.append("        <file path=\"" + outputClassFile + "\" mod=\"" + fileDate + "\"/>\n");
+                            temp.writeTo(baos);
+                            writeFileToZip(zipOutputStream, outputClassFile, baos, fileList);
                             
                             if(sourceMapTemp != null)
                             {
@@ -436,24 +397,9 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                                 {
                                     System.out.println("Writing file: " + sourceMapFile);
                                 }
-                                ze = new ZipEntry(sourceMapFile);
-                                ze.setTime(zipFileDate);
-                                ze.setMethod(ZipEntry.STORED);
-                                
                                 baos = new ByteArrayOutputStream();
                                 sourceMapTemp.writeTo(baos);
-                                ze.setSize(baos.size());
-                                ze.setCompressedSize(baos.size());
-                                crc = new CRC32();
-                                crc.reset();
-                                crc.update(baos.toByteArray());
-                                ze.setCrc(crc.getValue());
-                                
-                                zipOutputStream.putNextEntry(ze);
-                                baos.writeTo(zipOutputStream);
-                                zipOutputStream.flush();
-                                zipOutputStream.closeEntry();
-                                fileList.append("        <file path=\"" + sourceMapFile + "\" mod=\"" + fileDate + "\"/>\n");
+                                writeFileToZip(zipOutputStream, sourceMapFile, baos, fileList);
                             }
 	                        writer.close();
                     	}
@@ -534,6 +480,50 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
         return compilationSuccess;
     }
 
+    private void writeFileToZip(ZipOutputStream zipOutputStream, String entryFilePath, ByteArrayOutputStream baos, StringBuilder fileList) throws IOException
+    {
+        long fileDate = System.currentTimeMillis();
+        long zipFileDate = fileDate;
+        String metadataDate = targetSettings.getSWFMetadataDate();
+        if (metadataDate != null)
+        {
+            String metadataFormat = targetSettings.getSWFMetadataDateFormat();
+            try {
+                SimpleDateFormat sdf = new SimpleDateFormat(metadataFormat);
+                Date d = sdf.parse(metadataDate);
+                Calendar cal = new GregorianCalendar();
+                cal.setTime(d);
+                sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+                d = sdf.parse(metadataDate);
+                fileDate = d.getTime();
+                ZonedDateTime zdt = ZonedDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), 
+                                        cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), 0, ZoneId.systemDefault());
+                zipFileDate = zdt.toInstant().toEpochMilli();
+            } catch (ParseException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (IllegalArgumentException e1) {
+                e1.printStackTrace();
+            }
+        }
+        ZipEntry ze = new ZipEntry(entryFilePath);
+        ze.setTime(zipFileDate);
+        ze.setMethod(ZipEntry.STORED);
+        
+        ze.setSize(baos.size());
+        ze.setCompressedSize(baos.size());
+        CRC32 crc = new CRC32();
+        crc.reset();
+        crc.update(baos.toByteArray());
+        ze.setCrc(crc.getValue());
+
+        zipOutputStream.putNextEntry(ze);
+        baos.writeTo(zipOutputStream);
+        zipOutputStream.flush();
+        zipOutputStream.closeEntry();
+        fileList.append("        <file path=\"" + entryFilePath + "\" mod=\"" + fileDate + "\"/>\n");
+    }
+
     /**
      * Build target artifact.
      *