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


The following commit(s) were added to refs/heads/develop by this push:
     new 2737f98c8 EmbedData: Fixed error for duplicate class definitions when 
using Embed metadata even though there were no actual duplicates
2737f98c8 is described below

commit 2737f98c87b48f21271e8cc3bf5bbddafae8dc45
Author: Josh Tynjala <[email protected]>
AuthorDate: Fri Jul 24 15:47:45 2026 -0700

    EmbedData: Fixed error for duplicate class definitions when using Embed 
metadata even though there were no actual duplicates
    
    Made the generation of the EmbedData's uniqueName (which is assigned to the 
the hashCodeSourceName) more consistent. The inconsistent hashCodeSourceName 
was causing the DuplicateClassDefinitionProblem to be reported intermittently.
    
    The result of hashCode() was different between calling EmbedData's 
createTranscoder() method and calling its getQName() method. If the EmbedData 
was used as a key for the embedCompilationUnits in CompilerProject before 
getQName() was called, the hashCode() calculated for put() and the hashCode() 
calculated for get() would be different. The EmbedData wouldn't be found 
because of the HashMap's internal bucketing doesn't associate the EmbedData 
with its new hash, even though equals() wou [...]
    
    Now, in both createTranscoder() and getQName(), the hashCodeSourceName is 
set to the same value by calling the same private getUniqueName(). The 
hashCode() is consistent, and there are no longer duplicate compilation units 
created for the same EmbedData.
    
    Related commits: c97ab3ef32a49784e4cb07ca2630880c633f8c28, 
970df1e7e6a92f4d498772c2dcd43b72f7833b26, and 
b4deb222208eb93003a574a34697781351ebcfab
---
 RELEASE_NOTES.md                                   |  1 +
 .../compiler/internal/embedding/EmbedData.java     | 53 +++++++++++-----------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index eb1d3927a..aae42cdcf 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -93,6 +93,7 @@ Apache Royale Compiler 1.0.0
 - compiler: Fixed operand stack underflow error when using data binding in 
MXML to assign to `<fx:Object>` property.
 - compiler: Fixed race condition in populating metadata on definitions.
 - compiler: Fixed dot character in MXML namespace prefixes not being 
recognized, like `xmlns:com.example="com.example.*"`.
+- compiler: Fixed incorrect duplicate class definition error when using 
`Embed` metadata and there are no duplicates.
 - debugger: Added missing isolate ID to SWF load and unload events.
 - debugger: Fixed debugger targeting the current JDK version instead of the 
intended minimum JDK version.
 - debugger: Fixed localized messages appearing as unprocessed tokens.
diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/embedding/EmbedData.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/embedding/EmbedData.java
index bc8eb097d..c16250c91 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/embedding/EmbedData.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/embedding/EmbedData.java
@@ -439,21 +439,7 @@ public class EmbedData implements IEmbedData
             return false;
         }
 
-        String uniqueName = source;
-        if (source != null)
-        {
-            List<File> sourcePaths = ((IASProject)project).getSourcePath();
-            for (File sourcePath : sourcePaths)
-            {
-                String sourcePathString = sourcePath.getAbsolutePath();
-                if (source.startsWith(sourcePathString))
-                {
-                    uniqueName = source.substring(sourcePathString.length());
-                    uniqueName = uniqueName.replace("\\", "/");
-                    break;
-                }
-            }
-        }
+        final String uniqueName = getUniqueName();
 
         // also check that we have a mimetype set, as don't know what 
transcoder
         // to create without it!
@@ -572,18 +558,7 @@ public class EmbedData implements IEmbedData
             source = swcSource.getContainingSWCPath().concat(source);
         }
 
-        String uniqueName = source;
-        List<File> sourcePaths = ((IASProject)project).getSourcePath();
-        for (File sourcePath : sourcePaths)
-        {
-               String sourcePathString = sourcePath.getAbsolutePath();
-               if (source.startsWith(sourcePathString))
-               {
-                       uniqueName = 
source.substring(sourcePathString.length());
-                       uniqueName = uniqueName.replace("\\", "/");
-                       break;
-               }
-        }
+        final String uniqueName = getUniqueName();
         String filename = FilenameUtils.getName(source);
         filename = filename.replace(".", "_");
         String qname = filename + "$" + 
StringEncoder.stringToMD5String(uniqueName);
@@ -813,4 +788,28 @@ public class EmbedData implements IEmbedData
 
         return sourceFile;
     }
+
+    private String getUniqueName()
+    {
+        String source = (String)getAttribute(EmbedAttribute.SOURCE);
+        if (swcSource != null)
+        {
+            source = EMBED_SWC_SEP.concat(source);
+            source = swcSource.getContainingSWCPath().concat(source);
+        }
+
+        String result = source;
+        List<File> sourcePaths = ((IASProject)project).getSourcePath();
+        for (File sourcePath : sourcePaths)
+        {
+            String sourcePathString = sourcePath.getAbsolutePath();
+            if (source.startsWith(sourcePathString))
+            {
+                result = source.substring(sourcePathString.length());
+                result = result.replace("\\", "/");
+                break;
+            }
+        }
+        return result;
+    }
 }

Reply via email to