8305814: Update Xalan Java to 2.7.3

Reviewed-by: iris, lancea, naoto
This commit is contained in:
Joe Wang 2023-11-07 19:21:03 +00:00
parent 806529aa77
commit b1625af600
4 changed files with 41 additions and 67 deletions
src/java.xml/share
classes/com/sun/org/apache
xalan/internal
xml/internal/dtm/ref
legal

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -21,16 +21,20 @@
package com.sun.org.apache.xalan.internal.lib;
import com.sun.org.apache.xpath.internal.objects.XBoolean;
import com.sun.org.apache.xpath.internal.objects.XNumber;
import com.sun.org.apache.xpath.internal.objects.XObject;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import com.sun.org.apache.xpath.internal.objects.XBoolean;
import com.sun.org.apache.xpath.internal.objects.XNumber;
import com.sun.org.apache.xpath.internal.objects.XObject;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* This class contains EXSLT dates and times extension functions.
@ -44,7 +48,7 @@ import com.sun.org.apache.xpath.internal.objects.XObject;
*
* @see <a href="http://www.exslt.org/">EXSLT</a>
* @xsl.usage general
* @LastModified: Nov 2017
* @LastModified: Nov 2023
*/
public class ExsltDatetime
@ -75,29 +79,19 @@ public class ExsltDatetime
*/
public static String dateTime()
{
Calendar cal = Calendar.getInstance();
Date datetime = cal.getTime();
// Format for date and time.
SimpleDateFormat dateFormat = new SimpleDateFormat(dt);
StringBuffer buff = new StringBuffer(dateFormat.format(datetime));
// Must also include offset from UTF.
// Get the offset (in milliseconds).
int offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
// If there is no offset, we have "Coordinated
// Universal Time."
if (offset == 0)
buff.append("Z");
else
{
// Convert milliseconds to hours and minutes
int hrs = offset/(60*60*1000);
// In a few cases, the time zone may be +/-hh:30.
int min = offset%(60*60*1000);
char posneg = hrs < 0? '-': '+';
buff.append(posneg).append(formatDigits(hrs)).append(':').append(formatDigits(min));
String resultStr = "";
try {
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(new Date());
XMLGregorianCalendar xCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
xCal.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
resultStr = xCal.toXMLFormat();
}
return buff.toString();
catch (DatatypeConfigurationException ex) {
}
return resultStr;
}
/**
@ -135,6 +129,7 @@ public class ExsltDatetime
public static String date(String datetimeIn)
throws ParseException
{
if ("".equals(datetimeIn)) return EMPTY_STR;
String[] edz = getEraDatetimeZone(datetimeIn);
String leader = edz[0];
String datetime = edz[1];
@ -251,7 +246,7 @@ public class ExsltDatetime
String[] formats = {dt, d, gym, gy};
double yr = getNumber(datetime, formats, Calendar.YEAR);
if (ad || yr == Double.NaN)
if (ad || Double.isNaN(yr))
return yr;
else
return -yr;
@ -604,7 +599,7 @@ public class ExsltDatetime
String[] formats = {dt, d, gym, gy};
double dbl = getNumber(datetime, formats, Calendar.YEAR);
if (dbl == Double.NaN)
if (Double.isNaN(dbl))
return new XNumber(Double.NaN);
int yr = (int)dbl;
return new XBoolean(yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -63,7 +63,7 @@ import java.util.Set;
* @author Morten Jorgensen
* @author Erwin Bolwidt <ejb@klomp.org>
* @author G. Todd Miller
* @LastModified: Sep 2021
* @LastModified: Nov 2023
*/
final class Mode implements Constants {
@ -841,7 +841,7 @@ final class Mode implements Constants {
elemPrio = elemTest.getPriority();
elemPos = elemTest.getPosition();
}
if (elemPrio == Double.NaN || elemPrio < nodePrio ||
if (Double.isNaN(elemPrio) || elemPrio < nodePrio ||
(elemPrio == nodePrio && elemPos < nodePos))
{
ihElem = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
@ -856,7 +856,7 @@ final class Mode implements Constants {
textPrio = textTest.getPriority();
textPos = textTest.getPosition();
}
if (textPrio == Double.NaN || textPrio < nodePrio ||
if (Double.isNaN(textPrio) || textPrio < nodePrio ||
(textPrio == nodePrio && textPos < nodePos))
{
ihText = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
@ -1181,7 +1181,7 @@ final class Mode implements Constants {
elemPos = elemTest.getPosition();
}
if (elemPrio == Double.NaN || elemPrio < nodePrio ||
if (Double.isNaN(elemPrio) || elemPrio < nodePrio ||
(elemPrio == nodePrio && elemPos < nodePos))
{
ihElem = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
@ -1197,7 +1197,7 @@ final class Mode implements Constants {
textPos = textTest.getPosition();
}
if (textPrio == Double.NaN || textPrio < nodePrio ||
if (Double.isNaN(textPrio) || textPrio < nodePrio ||
(textPrio == nodePrio && textPos < nodePos))
{
ihText = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -20,8 +20,8 @@
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.utils.IntVector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/** <p>DTMStringPool is an "interning" mechanism for strings. It will
@ -53,14 +53,12 @@ import java.util.List;
*
* <p>Status: Passed basic test in main().</p>
*
* @LastModified: Oct 2017
* @LastModified: Nov 2023
*/
public class DTMStringPool
{
List<String> m_intToString;
static final int HASHPRIME=101;
int[] m_hashStart=new int[HASHPRIME];
IntVector m_hashChain;
HashMap<String, Integer> m_stringToInt;
public static final int NULL=-1;
/**
@ -71,7 +69,7 @@ public class DTMStringPool
public DTMStringPool(int chainSize)
{
m_intToString = new ArrayList<>();
m_hashChain= new IntVector(chainSize);
m_stringToInt = new HashMap<>();
removeAllElements();
// -sb Add this to force empty strings to be index 0.
@ -86,9 +84,7 @@ public class DTMStringPool
public void removeAllElements()
{
m_intToString.clear();
for(int i=0;i<HASHPRIME;++i)
m_hashStart[i]=NULL;
m_hashChain.removeAllElements();
m_stringToInt.clear();
}
/** @return string whose value is uniquely identified by this integer index.
@ -107,30 +103,13 @@ public class DTMStringPool
{
if(s==null) return NULL;
int hashslot=s.hashCode()%HASHPRIME;
if(hashslot<0) hashslot=-hashslot;
// Is it one we already know?
int hashlast=m_hashStart[hashslot];
int hashcandidate=hashlast;
while(hashcandidate!=NULL)
{
if(m_intToString.get(hashcandidate).equals(s))
return hashcandidate;
hashlast=hashcandidate;
hashcandidate=m_hashChain.elementAt(hashcandidate);
}
Integer index = m_stringToInt.get(s);
if(index != null) return index;
// New value. Add to tables.
int newIndex=m_intToString.size();
m_intToString.add(s);
m_hashChain.addElement(NULL); // Initialize to no-following-same-hash
if(hashlast==NULL) // First for this hash
m_hashStart[hashslot]=newIndex;
else // Link from previous with same hash
m_hashChain.setElementAt(newIndex,hashlast);
m_stringToInt.put(s, newIndex);
return newIndex;
}

@ -1,4 +1,4 @@
## Apache Xalan v2.7.2
## Apache Xalan v2.7.3
### Apache Xalan Notice
<pre>