You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mu...@apache.org on 2022/09/10 06:47:00 UTC

[xalan-java] branch xalan-j_2_7_1_maint updated: committing fix for, integer truncation issues within xsltc

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

mukulg pushed a commit to branch xalan-j_2_7_1_maint
in repository https://gitbox.apache.org/repos/asf/xalan-java.git


The following commit(s) were added to refs/heads/xalan-j_2_7_1_maint by this push:
     new 2e60d0a9 committing fix for, integer truncation issues within xsltc
2e60d0a9 is described below

commit 2e60d0a9a5b822c4abf9051857973b1c6babfe81
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat Sep 10 12:16:35 2022 +0530

    committing fix for, integer truncation issues within xsltc
---
 src/org/apache/xalan/xsltc/compiler/XSLTC.java | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/org/apache/xalan/xsltc/compiler/XSLTC.java b/src/org/apache/xalan/xsltc/compiler/XSLTC.java
index b859af43..13fad89d 100644
--- a/src/org/apache/xalan/xsltc/compiler/XSLTC.java
+++ b/src/org/apache/xalan/xsltc/compiler/XSLTC.java
@@ -856,9 +856,16 @@ public final class XSLTC {
 		clazz.dump(out);
 		_classes.addElement(out.toByteArray());
 
-		if (_outputType == BYTEARRAY_AND_FILE_OUTPUT)
+		if (_outputType == BYTEARRAY_AND_FILE_OUTPUT) {
+		  // check that the, class to be serialized to filesystem, is of the valid format
+		  // check with the native JVM class loader
+		  byte[] classByteArray = clazz.getBytes();
+		  ByteArrayClassLoader classLoader = new ByteArrayClassLoader(classByteArray);
+		  Class clz = classLoader.findClass(clazz.getClassName());
+		  
 		  clazz.dump(new BufferedOutputStream(
-			new FileOutputStream(getOutputFile(clazz.getClassName()))));
+			new FileOutputStream(getOutputFile(clazz.getClassName()))));		  
+		}
 		else if (_outputType == BYTEARRAY_AND_JAR_OUTPUT)
 		  _bcelClasses.addElement(clazz);
 
@@ -869,6 +876,20 @@ public final class XSLTC {
 	    e.printStackTrace();
 	}
     }
+    
+    public class ByteArrayClassLoader extends ClassLoader {
+
+        byte[] ba;
+        
+        public ByteArrayClassLoader(byte[] bArray) {
+            ba = bArray;
+        }
+        
+        public Class findClass(String name) {            
+            return defineClass(name, ba, 0, ba.length);
+        }
+
+    }
 
     /**
      * File separators are converted to forward slashes for ZIP files.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org