();
suppressedExceptions.add(exception);
}
@@ -835,7 +846,10 @@ public class Throwable implements Serializable {
* suppressed to deliver this exception.
* @since 1.7
*/
- public Throwable[] getSuppressedExceptions() {
- return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
+ public synchronized Throwable[] getSuppressedExceptions() {
+ if (suppressedExceptions == null)
+ return EMPTY_THROWABLE_ARRAY;
+ else
+ return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
}
}
diff --git a/jdk/src/share/classes/java/net/HttpCookie.java b/jdk/src/share/classes/java/net/HttpCookie.java
index 5b00869ab95..07d9cee3e8a 100644
--- a/jdk/src/share/classes/java/net/HttpCookie.java
+++ b/jdk/src/share/classes/java/net/HttpCookie.java
@@ -1093,14 +1093,8 @@ public final class HttpCookie implements Cloneable {
return sb.toString();
}
- private static SimpleDateFormat[] cDateFormats = null;
- static {
- cDateFormats = new SimpleDateFormat[COOKIE_DATE_FORMATS.length];
- for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
- cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
- cDateFormats[i].setTimeZone(TimeZone.getTimeZone("GMT"));
- }
- }
+ static final TimeZone GMT = TimeZone.getTimeZone("GMT");
+
/*
* @param dateString a date string in one of the formats
* defined in Netscape cookie spec
@@ -1109,12 +1103,14 @@ public final class HttpCookie implements Cloneable {
* time and the time specified by dateString
*/
private long expiryDate2DeltaSeconds(String dateString) {
- for (SimpleDateFormat df : cDateFormats) {
+ for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
+ SimpleDateFormat df = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
+ df.setTimeZone(GMT);
try {
Date date = df.parse(dateString);
return (date.getTime() - whenCreated) / 1000;
} catch (Exception e) {
-
+ // Ignore, try the next date format
}
}
return 0;
diff --git a/jdk/src/share/classes/java/net/URI.java b/jdk/src/share/classes/java/net/URI.java
index c05b7b2abaa..9b891b4b4dd 100644
--- a/jdk/src/share/classes/java/net/URI.java
+++ b/jdk/src/share/classes/java/net/URI.java
@@ -856,9 +856,7 @@ public final class URI
try {
return new URI(str);
} catch (URISyntaxException x) {
- IllegalArgumentException y = new IllegalArgumentException();
- y.initCause(x);
- throw y;
+ throw new IllegalArgumentException(x.getMessage(), x);
}
}
diff --git a/jdk/src/share/classes/java/security/KeyStore.java b/jdk/src/share/classes/java/security/KeyStore.java
index 7ecac8025c1..c1e2e4649e7 100644
--- a/jdk/src/share/classes/java/security/KeyStore.java
+++ b/jdk/src/share/classes/java/security/KeyStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -131,17 +131,19 @@ import javax.security.auth.callback.*;
* to read existing entries from the keystore, or to write new entries
* into the keystore:
*
+ * KeyStore.ProtectionParameter protParam =
+ * new KeyStore.PasswordProtection(password);
+ *
* // get my private key
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
- * ks.getEntry("privateKeyAlias", password);
+ * ks.getEntry("privateKeyAlias", protParam);
* PrivateKey myPrivateKey = pkEntry.getPrivateKey();
*
* // save my secret key
* javax.crypto.SecretKey mySecretKey;
* KeyStore.SecretKeyEntry skEntry =
* new KeyStore.SecretKeyEntry(mySecretKey);
- * ks.setEntry("secretKeyAlias", skEntry,
- * new KeyStore.PasswordProtection(password));
+ * ks.setEntry("secretKeyAlias", skEntry, protParam);
*
* // store away the keystore
* java.io.FileOutputStream fos = null;
diff --git a/jdk/src/share/classes/java/sql/Date.java b/jdk/src/share/classes/java/sql/Date.java
index 39cf98ce93f..7c2356e75c2 100644
--- a/jdk/src/share/classes/java/sql/Date.java
+++ b/jdk/src/share/classes/java/sql/Date.java
@@ -103,27 +103,46 @@ public class Date extends java.util.Date {
* JDBC date escape format (yyyy-mm-dd)
*/
public static Date valueOf(String s) {
- int year;
- int month;
- int day;
+ final int YEAR_LENGTH = 4;
+ final int MONTH_LENGTH = 2;
+ final int DAY_LENGTH = 2;
+ final int MAX_MONTH = 12;
+ final int MAX_DAY = 31;
int firstDash;
int secondDash;
+ Date d = null;
- if (s == null) throw new java.lang.IllegalArgumentException();
-
- firstDash = s.indexOf('-');
- secondDash = s.indexOf('-', firstDash+1);
- if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
- year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
- month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
- day = Integer.parseInt(s.substring(secondDash+1));
- } else {
+ if (s == null) {
throw new java.lang.IllegalArgumentException();
}
- return new Date(year, month, day);
+ firstDash = s.indexOf('-');
+ secondDash = s.indexOf('-', firstDash + 1);
+
+ if ((firstDash > 0) && (secondDash > 0) && (secondDash < s.length() - 1)) {
+ String yyyy = s.substring(0, firstDash);
+ String mm = s.substring(firstDash + 1, secondDash);
+ String dd = s.substring(secondDash + 1);
+ if (yyyy.length() == YEAR_LENGTH && mm.length() == MONTH_LENGTH &&
+ dd.length() == DAY_LENGTH) {
+ int year = Integer.parseInt(yyyy);
+ int month = Integer.parseInt(mm);
+ int day = Integer.parseInt(dd);
+
+ if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
+ d = new Date(year - 1900, month - 1, day);
+ }
+ }
+ }
+ if (d == null) {
+ throw new java.lang.IllegalArgumentException();
+ }
+
+ return d;
+
}
+
/**
* Formats a date in the date escape format yyyy-mm-dd.
*
diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java
index 8ca98bbe15a..bcf00a37547 100644
--- a/jdk/src/share/classes/javax/swing/JTable.java
+++ b/jdk/src/share/classes/javax/swing/JTable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -946,7 +946,6 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
/**
* Returns the height of a table row, in pixels.
- * The default row height is 16.0.
*
* @return the height in pixels of a table row
* @see #setRowHeight
diff --git a/jdk/src/share/classes/sun/font/GlyphDisposedListener.java b/jdk/src/share/classes/sun/font/GlyphDisposedListener.java
index 41a38380c75..efe3cb564c0 100644
--- a/jdk/src/share/classes/sun/font/GlyphDisposedListener.java
+++ b/jdk/src/share/classes/sun/font/GlyphDisposedListener.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.font;
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Dasher.java b/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
index 1a1f328adc4..f5b5e049143 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
@@ -36,117 +36,71 @@ package sun.java2d.pisces;
* semantics are unclear.
*
*/
-public class Dasher extends LineSink {
+public class Dasher implements LineSink {
+ private final LineSink output;
+ private final float[] dash;
+ private final float startPhase;
+ private final boolean startDashOn;
+ private final int startIdx;
- LineSink output;
- int[] dash;
- int startPhase;
- boolean startDashOn;
- int startIdx;
+ private final float m00, m10, m01, m11;
+ private final float det;
- int idx;
- boolean dashOn;
- int phase;
+ private boolean firstDashOn;
+ private boolean starting;
- int sx, sy;
- int x0, y0;
+ private int idx;
+ private boolean dashOn;
+ private float phase;
- int m00, m01;
- int m10, m11;
+ private float sx, sy;
+ private float x0, y0;
+ private float sx1, sy1;
- Transform4 transform;
-
- boolean symmetric;
- long ldet;
-
- boolean firstDashOn;
- boolean starting;
- int sx1, sy1;
-
- /**
- * Empty constructor. setOutput
and
- * setParameters
must be called prior to calling any
- * other methods.
- */
- public Dasher() {}
/**
* Constructs a Dasher
.
*
* @param output an output LineSink
.
- * @param dash an array of int
s containing the dash
- * pattern in S15.16 format.
- * @param phase an int
containing the dash phase in
- * S15.16 format.
+ * @param dash an array of int
s containing the dash pattern
+ * @param phase an int
containing the dash phase
* @param transform a Transform4
object indicating
* the transform that has been previously applied to all incoming
* coordinates. This is required in order to compute dash lengths
* properly.
*/
public Dasher(LineSink output,
- int[] dash, int phase,
- Transform4 transform) {
- setOutput(output);
- setParameters(dash, phase, transform);
- }
-
- /**
- * Sets the output LineSink
of this
- * Dasher
.
- *
- * @param output an output LineSink
.
- */
- public void setOutput(LineSink output) {
- this.output = output;
- }
-
- /**
- * Sets the parameters of this Dasher
.
- *
- * @param dash an array of int
s containing the dash
- * pattern in S15.16 format.
- * @param phase an int
containing the dash phase in
- * S15.16 format.
- * @param transform a Transform4
object indicating
- * the transform that has been previously applied to all incoming
- * coordinates. This is required in order to compute dash lengths
- * properly.
- */
- public void setParameters(int[] dash, int phase,
- Transform4 transform) {
+ float[] dash, float phase,
+ float a00, float a01, float a10, float a11) {
if (phase < 0) {
throw new IllegalArgumentException("phase < 0 !");
}
+ this.output = output;
+
// Normalize so 0 <= phase < dash[0]
int idx = 0;
dashOn = true;
- int d;
+ float d;
while (phase >= (d = dash[idx])) {
phase -= d;
idx = (idx + 1) % dash.length;
dashOn = !dashOn;
}
- this.dash = new int[dash.length];
- for (int i = 0; i < dash.length; i++) {
- this.dash[i] = dash[i];
- }
+ this.dash = dash;
this.startPhase = this.phase = phase;
this.startDashOn = dashOn;
this.startIdx = idx;
- this.transform = transform;
-
- this.m00 = transform.m00;
- this.m01 = transform.m01;
- this.m10 = transform.m10;
- this.m11 = transform.m11;
- this.ldet = ((long)m00*m11 - (long)m01*m10) >> 16;
- this.symmetric = (m00 == m11 && m10 == -m01);
+ m00 = a00;
+ m01 = a01;
+ m10 = a10;
+ m11 = a11;
+ det = m00 * m11 - m01 * m10;
}
- public void moveTo(int x0, int y0) {
+ public void moveTo(float x0, float y0) {
output.moveTo(x0, y0);
this.idx = startIdx;
this.dashOn = this.startDashOn;
@@ -160,7 +114,7 @@ public class Dasher extends LineSink {
output.lineJoin();
}
- private void goTo(int x1, int y1) {
+ private void goTo(float x1, float y1) {
if (dashOn) {
if (starting) {
this.sx1 = x1;
@@ -180,52 +134,64 @@ public class Dasher extends LineSink {
this.y0 = y1;
}
- public void lineTo(int x1, int y1) {
+ public void lineTo(float x1, float y1) {
+ // The widened line is squished to a 0 width one, so no drawing is done
+ if (det == 0) {
+ goTo(x1, y1);
+ return;
+ }
+ float dx = x1 - x0;
+ float dy = y1 - y0;
+
+
+ // Compute segment length in the untransformed
+ // coordinate system
+
+ float la = (dy*m00 - dx*m10)/det;
+ float lb = (dy*m01 - dx*m11)/det;
+ float origLen = (float) Math.hypot(la, lb);
+
+ if (origLen == 0) {
+ // Let the output LineSink deal with cases where dx, dy are 0.
+ goTo(x1, y1);
+ return;
+ }
+
+ // The scaling factors needed to get the dx and dy of the
+ // transformed dash segments.
+ float cx = dx / origLen;
+ float cy = dy / origLen;
+
while (true) {
- int d = dash[idx] - phase;
- int lx = x1 - x0;
- int ly = y1 - y0;
-
- // Compute segment length in the untransformed
- // coordinate system
- // IMPL NOTE - use fixed point
-
- int l;
- if (symmetric) {
- l = (int)((PiscesMath.hypot(lx, ly)*65536L)/ldet);
- } else{
- long la = ((long)ly*m00 - (long)lx*m10)/ldet;
- long lb = ((long)ly*m01 - (long)lx*m11)/ldet;
- l = (int)PiscesMath.hypot(la, lb);
- }
-
- if (l < d) {
+ float leftInThisDashSegment = dash[idx] - phase;
+ if (origLen < leftInThisDashSegment) {
goTo(x1, y1);
// Advance phase within current dash segment
- phase += l;
+ phase += origLen;
+ return;
+ } else if (origLen == leftInThisDashSegment) {
+ goTo(x1, y1);
+ phase = 0f;
+ idx = (idx + 1) % dash.length;
+ dashOn = !dashOn;
return;
}
- long t;
- int xsplit, ysplit;
-// // For zero length dashses, SE appears to move 1/8 unit
-// // in device space
-// if (d == 0) {
-// double dlx = lx/65536.0;
-// double dly = ly/65536.0;
-// len = PiscesMath.hypot(dlx, dly);
-// double dt = 1.0/(8*len);
-// double dxsplit = (x0/65536.0) + dt*dlx;
-// double dysplit = (y0/65536.0) + dt*dly;
-// xsplit = (int)(dxsplit*65536.0);
-// ysplit = (int)(dysplit*65536.0);
-// } else {
- t = ((long)d << 16)/l;
- xsplit = x0 + (int)(t*(x1 - x0) >> 16);
- ysplit = y0 + (int)(t*(y1 - y0) >> 16);
-// }
- goTo(xsplit, ysplit);
+ float dashx, dashy;
+ float dashdx = dash[idx] * cx;
+ float dashdy = dash[idx] * cy;
+ if (phase == 0) {
+ dashx = x0 + dashdx;
+ dashy = y0 + dashdy;
+ } else {
+ float p = (leftInThisDashSegment) / dash[idx];
+ dashx = x0 + p * dashdx;
+ dashy = y0 + p * dashdy;
+ }
+ goTo(dashx, dashy);
+
+ origLen -= (dash[idx] - phase);
// Advance to next dash segment
idx = (idx + 1) % dash.length;
dashOn = !dashOn;
@@ -233,6 +199,7 @@ public class Dasher extends LineSink {
}
}
+
public void close() {
lineTo(sx, sy);
if (firstDashOn) {
diff --git a/jdk/src/share/classes/sun/java2d/pisces/LineSink.java b/jdk/src/share/classes/sun/java2d/pisces/LineSink.java
index 6f92dd4a416..81300a25fa0 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/LineSink.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/LineSink.java
@@ -39,16 +39,16 @@ package sun.java2d.pisces;
* LineSink
interface.
*
*/
-public abstract class LineSink {
+public interface LineSink {
/**
* Moves the current drawing position to the point (x0,
* y0)
.
*
- * @param x0 the X coordinate in S15.16 format
- * @param y0 the Y coordinate in S15.16 format
+ * @param x0 the X coordinate
+ * @param y0 the Y coordinate
*/
- public abstract void moveTo(int x0, int y0);
+ public void moveTo(float x0, float y0);
/**
* Provides a hint that the current segment should be joined to
@@ -65,29 +65,29 @@ public abstract class LineSink {
*
Other LineSink
classes should simply pass this
* hint to their output sink as needed.
*/
- public abstract void lineJoin();
+ public void lineJoin();
/**
* Draws a line from the current drawing position to the point
* (x1, y1)
and sets the current drawing position to
* (x1, y1)
.
*
- * @param x1 the X coordinate in S15.16 format
- * @param y1 the Y coordinate in S15.16 format
+ * @param x1 the X coordinate
+ * @param y1 the Y coordinate
*/
- public abstract void lineTo(int x1, int y1);
+ public void lineTo(float x1, float y1);
/**
* Closes the current path by drawing a line from the current
* drawing position to the point specified by the moset recent
* moveTo
command.
*/
- public abstract void close();
+ public void close();
/**
* Ends the current path. It may be necessary to end a path in
* order to allow end caps to be drawn.
*/
- public abstract void end();
+ public void end();
}
diff --git a/jdk/src/share/classes/sun/java2d/pisces/PiscesMath.java b/jdk/src/share/classes/sun/java2d/pisces/PiscesMath.java
deleted file mode 100644
index 0a6e9421687..00000000000
--- a/jdk/src/share/classes/sun/java2d/pisces/PiscesMath.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.java2d.pisces;
-
-public class PiscesMath {
-
- private PiscesMath() {}
-
- private static final int SINTAB_LG_ENTRIES = 10;
- private static final int SINTAB_ENTRIES = 1 << SINTAB_LG_ENTRIES;
- private static int[] sintab;
-
- public static final int PI = (int)(Math.PI*65536.0);
- public static final int TWO_PI = (int)(2.0*Math.PI*65536.0);
- public static final int PI_OVER_TWO = (int)((Math.PI/2.0)*65536.0);
- public static final int SQRT_TWO = (int)(Math.sqrt(2.0)*65536.0);
-
- static {
- sintab = new int[SINTAB_ENTRIES + 1];
- for (int i = 0; i < SINTAB_ENTRIES + 1; i++) {
- double theta = i*(Math.PI/2.0)/SINTAB_ENTRIES;
- sintab[i] = (int)(Math.sin(theta)*65536.0);
- }
- }
-
- public static int sin(int theta) {
- int sign = 1;
- if (theta < 0) {
- theta = -theta;
- sign = -1;
- }
- // 0 <= theta
- while (theta >= TWO_PI) {
- theta -= TWO_PI;
- }
- // 0 <= theta < 2*PI
- if (theta >= PI) {
- theta = TWO_PI - theta;
- sign = -sign;
- }
- // 0 <= theta < PI
- if (theta > PI_OVER_TWO) {
- theta = PI - theta;
- }
- // 0 <= theta <= PI/2
- int itheta = (int)((long)theta*SINTAB_ENTRIES/(PI_OVER_TWO));
- return sign*sintab[itheta];
- }
-
- public static int cos(int theta) {
- return sin(PI_OVER_TWO - theta);
- }
-
-// public static double sqrt(double x) {
-// double dsqrt = Math.sqrt(x);
-// int ix = (int)(x*65536.0);
-// Int Isqrt = Isqrt(Ix);
-
-// Long Lx = (Long)(X*65536.0);
-// Long Lsqrt = Lsqrt(Lx);
-
-// System.Out.Println();
-// System.Out.Println("X = " + X);
-// System.Out.Println("Dsqrt = " + Dsqrt);
-
-// System.Out.Println("Ix = " + Ix);
-// System.Out.Println("Isqrt = " + Isqrt/65536.0);
-
-// System.Out.Println("Lx = " + Lx);
-// System.Out.Println("Lsqrt = " + Lsqrt/65536.0);
-
-// Return Dsqrt;
-// }
-
- // From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
- public static int isqrt(int x) {
- int fracbits = 16;
-
- int root = 0;
- int remHi = 0;
- int remLo = x;
- int count = 15 + fracbits/2;
-
- do {
- remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
- remLo <<= 2;
- root <<= 1;
- int testdiv = (root << 1) + 1;
- if (remHi >= testdiv) {
- remHi -= testdiv;
- root++;
- }
- } while (count-- != 0);
-
- return root;
- }
-
- public static long lsqrt(long x) {
- int fracbits = 16;
-
- long root = 0;
- long remHi = 0;
- long remLo = x;
- int count = 31 + fracbits/2;
-
- do {
- remHi = (remHi << 2) | (remLo >>> 62); // N.B. - unsigned shift R
- remLo <<= 2;
- root <<= 1;
- long testDiv = (root << 1) + 1;
- if (remHi >= testDiv) {
- remHi -= testDiv;
- root++;
- }
- } while (count-- != 0);
-
- return root;
- }
-
- public static double hypot(double x, double y) {
- // new RuntimeException().printStackTrace();
- return Math.sqrt(x*x + y*y);
- }
-
- public static int hypot(int x, int y) {
- return (int)((lsqrt((long)x*x + (long)y*y) + 128) >> 8);
- }
-
- public static long hypot(long x, long y) {
- return (lsqrt(x*x + y*y) + 128) >> 8;
- }
-}
diff --git a/jdk/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java b/jdk/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
index 6446cb109e3..ee2b35e6809 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
@@ -27,6 +27,7 @@ package sun.java2d.pisces;
import java.awt.Shape;
import java.awt.BasicStroke;
+import java.awt.geom.FlatteningPathIterator;
import java.awt.geom.Path2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator;
@@ -37,23 +38,9 @@ import sun.java2d.pipe.RenderingEngine;
import sun.java2d.pipe.AATileGenerator;
public class PiscesRenderingEngine extends RenderingEngine {
- public static Transform4 IdentT4 = new Transform4();
public static double defaultFlat = 0.1;
- static int FloatToS15_16(float flt) {
- flt = flt * 65536f + 0.5f;
- if (flt <= -(65536f * 65536f)) {
- return Integer.MIN_VALUE;
- } else if (flt >= (65536f * 65536f)) {
- return Integer.MAX_VALUE;
- } else {
- return (int) Math.floor(flt);
- }
- }
-
- static float S15_16ToFloat(int fix) {
- return (fix / 65536f);
- }
+ private static enum NormMode {OFF, ON_NO_AA, ON_WITH_AA}
/**
* Create a widened path as specified by the parameters.
@@ -85,18 +72,19 @@ public class PiscesRenderingEngine extends RenderingEngine {
strokeTo(src,
null,
width,
+ NormMode.OFF,
caps,
join,
miterlimit,
dashes,
dashphase,
new LineSink() {
- public void moveTo(int x0, int y0) {
- p2d.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0));
+ public void moveTo(float x0, float y0) {
+ p2d.moveTo(x0, y0);
}
public void lineJoin() {}
- public void lineTo(int x1, int y1) {
- p2d.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1));
+ public void lineTo(float x1, float y1) {
+ p2d.lineTo(x1, y1);
}
public void close() {
p2d.closePath();
@@ -142,14 +130,17 @@ public class PiscesRenderingEngine extends RenderingEngine {
boolean antialias,
final PathConsumer2D consumer)
{
- strokeTo(src, at, bs, thin, normalize, antialias,
+ NormMode norm = (normalize) ?
+ ((antialias) ? NormMode.ON_WITH_AA : NormMode.ON_NO_AA)
+ : NormMode.OFF;
+ strokeTo(src, at, bs, thin, norm, antialias,
new LineSink() {
- public void moveTo(int x0, int y0) {
- consumer.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0));
+ public void moveTo(float x0, float y0) {
+ consumer.moveTo(x0, y0);
}
public void lineJoin() {}
- public void lineTo(int x1, int y1) {
- consumer.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1));
+ public void lineTo(float x1, float y1) {
+ consumer.lineTo(x1, y1);
}
public void close() {
consumer.closePath();
@@ -164,7 +155,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
AffineTransform at,
BasicStroke bs,
boolean thin,
- boolean normalize,
+ NormMode normalize,
boolean antialias,
LineSink lsink)
{
@@ -181,6 +172,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
strokeTo(src,
at,
lw,
+ normalize,
bs.getEndCap(),
bs.getLineJoin(),
bs.getMiterLimit(),
@@ -258,6 +250,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
void strokeTo(Shape src,
AffineTransform at,
float width,
+ NormMode normalize,
int caps,
int join,
float miterlimit,
@@ -265,36 +258,139 @@ public class PiscesRenderingEngine extends RenderingEngine {
float dashphase,
LineSink lsink)
{
- Transform4 t4;
-
- if (at == null || at.isIdentity()) {
- t4 = IdentT4;
- } else {
- t4 = new Transform4(FloatToS15_16((float) at.getScaleX()),
- FloatToS15_16((float) at.getShearX()),
- FloatToS15_16((float) at.getShearY()),
- FloatToS15_16((float) at.getScaleY()));
+ float a00 = 1f, a01 = 0f, a10 = 0f, a11 = 1f;
+ if (at != null && !at.isIdentity()) {
+ a00 = (float)at.getScaleX();
+ a01 = (float)at.getShearX();
+ a10 = (float)at.getShearY();
+ a11 = (float)at.getScaleY();
}
-
- lsink = new Stroker(lsink,
- FloatToS15_16(width),
- caps,
- join,
- FloatToS15_16(miterlimit),
- t4);
+ lsink = new Stroker(lsink, width, caps, join, miterlimit, a00, a01, a10, a11);
if (dashes != null) {
- int fdashes[] = new int[dashes.length];
- for (int i = 0; i < dashes.length; i++) {
- fdashes[i] = FloatToS15_16(dashes[i]);
+ lsink = new Dasher(lsink, dashes, dashphase, a00, a01, a10, a11);
+ }
+ PathIterator pi;
+ if (normalize != NormMode.OFF) {
+ pi = new FlatteningPathIterator(
+ new NormalizingPathIterator(src.getPathIterator(at), normalize),
+ defaultFlat);
+ } else {
+ pi = src.getPathIterator(at, defaultFlat);
+ }
+ pathTo(pi, lsink);
+ }
+
+ private static class NormalizingPathIterator implements PathIterator {
+
+ private final PathIterator src;
+
+ // the adjustment applied to the current position.
+ private float curx_adjust, cury_adjust;
+ // the adjustment applied to the last moveTo position.
+ private float movx_adjust, movy_adjust;
+
+ // constants used in normalization computations
+ private final float lval, rval;
+
+ NormalizingPathIterator(PathIterator src, NormMode mode) {
+ this.src = src;
+ switch (mode) {
+ case ON_NO_AA:
+ // round to nearest (0.25, 0.25) pixel
+ lval = rval = 0.25f;
+ break;
+ case ON_WITH_AA:
+ // round to nearest pixel center
+ lval = 0f;
+ rval = 0.5f;
+ break;
+ case OFF:
+ throw new InternalError("A NormalizingPathIterator should " +
+ "not be created if no normalization is being done");
+ default:
+ throw new InternalError("Unrecognized normalization mode");
}
- lsink = new Dasher(lsink,
- fdashes,
- FloatToS15_16(dashphase),
- t4);
}
- PathIterator pi = src.getPathIterator(at, defaultFlat);
- pathTo(pi, lsink);
+ public int currentSegment(float[] coords) {
+ int type = src.currentSegment(coords);
+
+ int lastCoord;
+ switch(type) {
+ case PathIterator.SEG_CUBICTO:
+ lastCoord = 4;
+ break;
+ case PathIterator.SEG_QUADTO:
+ lastCoord = 2;
+ break;
+ case PathIterator.SEG_LINETO:
+ case PathIterator.SEG_MOVETO:
+ lastCoord = 0;
+ break;
+ case PathIterator.SEG_CLOSE:
+ // we don't want to deal with this case later. We just exit now
+ curx_adjust = movx_adjust;
+ cury_adjust = movy_adjust;
+ return type;
+ default:
+ throw new InternalError("Unrecognized curve type");
+ }
+
+ // normalize endpoint
+ float x_adjust = (float)Math.floor(coords[lastCoord] + lval) + rval -
+ coords[lastCoord];
+ float y_adjust = (float)Math.floor(coords[lastCoord+1] + lval) + rval -
+ coords[lastCoord + 1];
+
+ coords[lastCoord ] += x_adjust;
+ coords[lastCoord + 1] += y_adjust;
+
+ // now that the end points are done, normalize the control points
+ switch(type) {
+ case PathIterator.SEG_CUBICTO:
+ coords[0] += curx_adjust;
+ coords[1] += cury_adjust;
+ coords[2] += x_adjust;
+ coords[3] += y_adjust;
+ break;
+ case PathIterator.SEG_QUADTO:
+ coords[0] += (curx_adjust + x_adjust) / 2;
+ coords[1] += (cury_adjust + y_adjust) / 2;
+ break;
+ case PathIterator.SEG_LINETO:
+ break;
+ case PathIterator.SEG_MOVETO:
+ movx_adjust = x_adjust;
+ movy_adjust = y_adjust;
+ break;
+ case PathIterator.SEG_CLOSE:
+ throw new InternalError("This should be handled earlier.");
+ }
+ curx_adjust = x_adjust;
+ cury_adjust = y_adjust;
+ return type;
+ }
+
+ public int currentSegment(double[] coords) {
+ float[] tmp = new float[6];
+ int type = this.currentSegment(tmp);
+ for (int i = 0; i < 6; i++) {
+ coords[i] = (float) tmp[i];
+ }
+ return type;
+ }
+
+ public int getWindingRule() {
+ return src.getWindingRule();
+ }
+
+ public boolean isDone() {
+ return src.isDone();
+ }
+
+ public void next() {
+ src.next();
+ }
}
void pathTo(PathIterator pi, LineSink lsink) {
@@ -302,13 +398,11 @@ public class PiscesRenderingEngine extends RenderingEngine {
while (!pi.isDone()) {
switch (pi.currentSegment(coords)) {
case PathIterator.SEG_MOVETO:
- lsink.moveTo(FloatToS15_16(coords[0]),
- FloatToS15_16(coords[1]));
+ lsink.moveTo(coords[0], coords[1]);
break;
case PathIterator.SEG_LINETO:
lsink.lineJoin();
- lsink.lineTo(FloatToS15_16(coords[0]),
- FloatToS15_16(coords[1]));
+ lsink.lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_CLOSE:
lsink.lineJoin();
@@ -378,18 +472,28 @@ public class PiscesRenderingEngine extends RenderingEngine {
int bbox[])
{
PiscesCache pc = PiscesCache.createInstance();
- Renderer r = new Renderer();
- r.setCache(pc);
- r.setAntialiasing(3, 3);
- r.beginRendering(clip.getLoX(), clip.getLoY(),
- clip.getWidth(), clip.getHeight());
+ Renderer r;
+ NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF;
if (bs == null) {
- PathIterator pi = s.getPathIterator(at, defaultFlat);
- r.setWindingRule(pi.getWindingRule());
+ PathIterator pi;
+ if (normalize) {
+ pi = new FlatteningPathIterator(
+ new NormalizingPathIterator(s.getPathIterator(at), norm),
+ defaultFlat);
+ } else {
+ pi = s.getPathIterator(at, defaultFlat);
+ }
+ r = new Renderer(3, 3,
+ clip.getLoX(), clip.getLoY(),
+ clip.getWidth(), clip.getHeight(),
+ pi.getWindingRule(), pc);
pathTo(pi, r);
} else {
- r.setWindingRule(PathIterator.WIND_NON_ZERO);
- strokeTo(s, at, bs, thin, normalize, true, r);
+ r = new Renderer(3, 3,
+ clip.getLoX(), clip.getLoY(),
+ clip.getWidth(), clip.getHeight(),
+ PathIterator.WIND_NON_ZERO, pc);
+ strokeTo(s, at, bs, thin, norm, true, r);
}
r.endRendering();
PiscesTileGenerator ptg = new PiscesTileGenerator(pc, r.MAX_AA_ALPHA);
@@ -420,3 +524,4 @@ public class PiscesRenderingEngine extends RenderingEngine {
}
}
}
+
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Renderer.java b/jdk/src/share/classes/sun/java2d/pisces/Renderer.java
index fa58146a5ad..9768e90a77b 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Renderer.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Renderer.java
@@ -25,447 +25,441 @@
package sun.java2d.pisces;
-public class Renderer extends LineSink {
+import java.util.Arrays;
+
+public class Renderer implements LineSink {
+
+///////////////////////////////////////////////////////////////////////////////
+// Scan line iterator and edge crossing data.
+//////////////////////////////////////////////////////////////////////////////
+
+ private int[] crossings;
+
+ // This is an array of indices into the edge array. It is initialized to
+ // [i * SIZEOF_STRUCT_EDGE for i in range(0, edgesSize/SIZEOF_STRUCT_EDGE)]
+ // (where range(i, j) is i,i+1,...,j-1 -- just like in python).
+ // The reason for keeping this is because we need the edges array sorted
+ // by y0, but we don't want to move all that data around, so instead we
+ // sort the indices into the edge array, and use edgeIndices to access
+ // the edges array. This is meant to simulate a pointer array (hence the name)
+ private int[] edgePtrs;
+
+ // crossing bounds. The bounds are not necessarily tight (the scan line
+ // at minY, for example, might have no crossings). The x bounds will
+ // be accumulated as crossings are computed.
+ private int minY, maxY;
+ private int minX, maxX;
+ private int nextY;
+
+ // indices into the edge pointer list. They indicate the "active" sublist in
+ // the edge list (the portion of the list that contains all the edges that
+ // cross the next scan line).
+ private int lo, hi;
+
+ private static final int INIT_CROSSINGS_SIZE = 50;
+ private void ScanLineItInitialize() {
+ crossings = new int[INIT_CROSSINGS_SIZE];
+ edgePtrs = new int[edgesSize / SIZEOF_STRUCT_EDGE];
+ for (int i = 0; i < edgePtrs.length; i++) {
+ edgePtrs[i] = i * SIZEOF_STRUCT_EDGE;
+ }
+
+ qsort(0, edgePtrs.length - 1);
+
+ // We don't care if we clip some of the line off with ceil, since
+ // no scan line crossings will be eliminated (in fact, the ceil is
+ // the y of the first scan line crossing).
+ nextY = minY = Math.max(boundsMinY, (int)Math.ceil(edgeMinY));
+ maxY = Math.min(boundsMaxY, (int)Math.ceil(edgeMaxY));
+
+ for (lo = 0; lo < edgePtrs.length && edges[edgePtrs[lo]+Y1] <= nextY; lo++)
+ ;
+ for (hi = lo; hi < edgePtrs.length && edges[edgePtrs[hi]+CURY] <= nextY; hi++)
+ ; // the active list is *edgePtrs[lo] (inclusive) *edgePtrs[hi] (exclusive)
+ for (int i = lo; i < hi; i++) {
+ setCurY(edgePtrs[i], nextY);
+ }
+
+ // We accumulate X in the iterator because accumulating it in addEdge
+ // like we do with Y does not do much good: if there's an edge
+ // (0,0)->(1000,10000), and if y gets clipped to 1000, then the x
+ // bound should be 100, but the accumulator from addEdge would say 1000,
+ // so we'd still have to accumulate the X bounds as we add crossings.
+ minX = boundsMinX;
+ maxX = boundsMaxX;
+ }
+
+ private int ScanLineItCurrentY() {
+ return nextY - 1;
+ }
+
+ private int ScanLineItGoToNextYAndComputeCrossings() {
+ // we go through the active list and remove the ones that don't cross
+ // the nextY scanline.
+ int crossingIdx = 0;
+ for (int i = lo; i < hi; i++) {
+ if (edges[edgePtrs[i]+Y1] <= nextY) {
+ edgePtrs[i] = edgePtrs[lo++];
+ }
+ }
+ if (hi - lo > crossings.length) {
+ int newSize = Math.max(hi - lo, crossings.length * 2);
+ crossings = Arrays.copyOf(crossings, newSize);
+ }
+ // Now every edge between lo and hi crosses nextY. Compute it's
+ // crossing and put it in the crossings array.
+ for (int i = lo; i < hi; i++) {
+ addCrossing(nextY, getCurCrossing(edgePtrs[i]), (int)edges[edgePtrs[i]+OR], crossingIdx);
+ gotoNextY(edgePtrs[i]);
+ crossingIdx++;
+ }
+
+ nextY++;
+ // Expand active list to include new edges.
+ for (; hi < edgePtrs.length && edges[edgePtrs[hi]+CURY] <= nextY; hi++) {
+ setCurY(edgePtrs[hi], nextY);
+ }
+
+ Arrays.sort(crossings, 0, crossingIdx);
+ return crossingIdx;
+ }
+
+ private boolean ScanLineItHasNext() {
+ return nextY < maxY;
+ }
+
+ private void addCrossing(int y, int x, int or, int idx) {
+ if (x < minX) {
+ minX = x;
+ }
+ if (x > maxX) {
+ maxX = x;
+ }
+ x <<= 1;
+ crossings[idx] = ((or == 1) ? (x | 0x1) : x);
+ }
+
+
+ // quicksort implementation for sorting the edge indices ("pointers")
+ // by increasing y0. first, last are indices into the "pointer" array
+ // It sorts the pointer array from first (inclusive) to last (inclusive)
+ private void qsort(int first, int last) {
+ if (last > first) {
+ int p = partition(first, last);
+ if (first < p - 1) {
+ qsort(first, p - 1);
+ }
+ if (p < last) {
+ qsort(p, last);
+ }
+ }
+ }
+
+ // i, j are indices into edgePtrs.
+ private int partition(int i, int j) {
+ int pivotVal = edgePtrs[i];
+ while (i <= j) {
+ // edges[edgePtrs[i]+1] is equivalent to (*(edgePtrs[i])).y0 in C
+ while (edges[edgePtrs[i]+CURY] < edges[pivotVal+CURY]) { i++; }
+ while (edges[edgePtrs[j]+CURY] > edges[pivotVal+CURY]) { j--; }
+ if (i <= j) {
+ int tmp = edgePtrs[i];
+ edgePtrs[i] = edgePtrs[j];
+ edgePtrs[j] = tmp;
+ i++;
+ j--;
+ }
+ }
+ return i;
+ }
+
+//============================================================================
+
+
+//////////////////////////////////////////////////////////////////////////////
+// EDGE LIST
+//////////////////////////////////////////////////////////////////////////////
+
+ private static final int INIT_NUM_EDGES = 1000;
+ private static final int SIZEOF_STRUCT_EDGE = 5;
+
+ // The following array is a poor man's struct array:
+ // it simulates a struct array by having
+ // edges[SIZEOF_STRUCT_EDGE * i + j] be the jth field in the ith element
+ // of an array of edge structs.
+ private float[] edges;
+ private int edgesSize; // size of the edge list.
+ private static final int Y1 = 0;
+ private static final int SLOPE = 1;
+ private static final int OR = 2; // the orientation. This can be -1 or 1.
+ // -1 means up, 1 means down.
+ private static final int CURY = 3; // j = 5 corresponds to the "current Y".
+ // Each edge keeps track of the last scanline
+ // crossing it computed, and this is the y coord of
+ // that scanline.
+ private static final int CURX = 4; //the x coord of the current crossing.
+
+ // Note that while the array is declared as a float[] not all of it's
+ // elements should be floats. currentY and Orientation should be ints (or int and
+ // byte respectively), but they all need to be the same type. This isn't
+ // really a problem because floats can represent exactly all 23 bit integers,
+ // which should be more than enough.
+ // Note, also, that we only need x1 for slope computation, so we don't need
+ // to store it. x0, y0 don't need to be stored either. They can be put into
+ // curx, cury, and it's ok if they're lost when curx and cury are changed.
+ // We take this undeniably ugly and error prone approach (instead of simply
+ // making an Edge class) for performance reasons. Also, it would probably be nicer
+ // to have one array for each field, but that would defeat the purpose because
+ // it would make poor use of the processor cache, since we tend to access
+ // all the fields for one edge at a time.
+
+ private float edgeMinY;
+ private float edgeMaxY;
+
+
+ private void addEdge(float x0, float y0, float x1, float y1) {
+ float or = (y0 < y1) ? 1f : -1f; // orientation: 1 = UP; -1 = DOWN
+ if (or == -1) {
+ float tmp = y0;
+ y0 = y1;
+ y1 = tmp;
+ tmp = x0;
+ x0 = x1;
+ x1 = tmp;
+ }
+ // skip edges that don't cross a scanline
+ if (Math.ceil(y0) >= Math.ceil(y1)) {
+ return;
+ }
+
+ int newSize = edgesSize + SIZEOF_STRUCT_EDGE;
+ if (edges.length < newSize) {
+ edges = Arrays.copyOf(edges, newSize * 2);
+ }
+ edges[edgesSize+CURX] = x0;
+ edges[edgesSize+CURY] = y0;
+ edges[edgesSize+Y1] = y1;
+ edges[edgesSize+SLOPE] = (x1 - x0) / (y1 - y0);
+ edges[edgesSize+OR] = or;
+ // the crossing values can't be initialized meaningfully yet. This
+ // will have to wait until setCurY is called
+ edgesSize += SIZEOF_STRUCT_EDGE;
+
+ // Accumulate edgeMinY and edgeMaxY
+ if (y0 < edgeMinY) { edgeMinY = y0; }
+ if (y1 > edgeMaxY) { edgeMaxY = y1; }
+ }
+
+ // As far as the following methods care, this edges extends to infinity.
+ // They can compute the x intersect of any horizontal line.
+ // precondition: idx is the index to the start of the desired edge.
+ // So, if the ith edge is wanted, idx should be SIZEOF_STRUCT_EDGE * i
+ private void setCurY(int idx, int y) {
+ // compute the x crossing of edge at idx and horizontal line y
+ // currentXCrossing = (y - y0)*slope + x0
+ edges[idx + CURX] = (y - edges[idx + CURY]) * edges[idx + SLOPE] + edges[idx+CURX];
+ edges[idx + CURY] = (float)y;
+ }
+
+ private void gotoNextY(int idx) {
+ edges[idx + CURY] += 1f; // i.e. curY += 1
+ edges[idx + CURX] += edges[idx + SLOPE]; // i.e. curXCrossing += slope
+ }
+
+ private int getCurCrossing(int idx) {
+ return (int)edges[idx + CURX];
+ }
+//====================================================================================
+
public static final int WIND_EVEN_ODD = 0;
public static final int WIND_NON_ZERO = 1;
- // Initial edge list size
- // IMPL_NOTE - restore size after growth
- public static final int INITIAL_EDGES = 1000;
-
- // Recommended maximum scratchpad sizes. The arrays will grow
- // larger if needed, but when finished() is called they will be released
- // if they have grown larger than these sizes.
- public static final int DEFAULT_INDICES_SIZE = 8192;
- public static final int DEFAULT_CROSSINGS_SIZE = 32*1024;
-
// Antialiasing
- private int SUBPIXEL_LG_POSITIONS_X;
- private int SUBPIXEL_LG_POSITIONS_Y;
- private int SUBPIXEL_MASK_X;
- private int SUBPIXEL_MASK_Y;
- private int SUBPIXEL_POSITIONS_X;
- private int SUBPIXEL_POSITIONS_Y;
- int MAX_AA_ALPHA;
- private int MAX_AA_ALPHA_DENOM;
- private int HALF_MAX_AA_ALPHA_DENOM;
- private int XSHIFT;
- private int YSHIFT;
- private int YSTEP;
- private int HYSTEP;
- private int YMASK;
-
- private static final int MIN_QUAD_OPT_WIDTH = 100 << 16;
+ final private int SUBPIXEL_LG_POSITIONS_X;
+ final private int SUBPIXEL_LG_POSITIONS_Y;
+ final private int SUBPIXEL_POSITIONS_X;
+ final private int SUBPIXEL_POSITIONS_Y;
+ final private int SUBPIXEL_MASK_X;
+ final private int SUBPIXEL_MASK_Y;
+ final int MAX_AA_ALPHA;
// Cache to store RLE-encoded coverage mask of the current primitive
- PiscesCache cache;
+ final PiscesCache cache;
- // Bounds of the drawing region, at S15.16 precsion
- private int boundsMinX, boundsMinY, boundsMaxX, boundsMaxY;
-
- // Bounds of the current primitive, at subsample precision
- private int rasterMinX, rasterMaxX, rasterMinY, rasterMaxY;
+ // Bounds of the drawing region, at subpixel precision.
+ final private int boundsMinX, boundsMinY, boundsMaxX, boundsMaxY;
// Pixel bounding box for current primitive
- private int bboxX0, bboxY0, bboxX1, bboxY1;
+ private int pix_bboxX0, pix_bboxY0, pix_bboxX1, pix_bboxY1;
// Current winding rule
- private int windingRule;
+ final private int windingRule;
// Current drawing position, i.e., final point of last segment
- private int x0, y0;
+ private float x0, y0;
// Position of most recent 'moveTo' command
- private int sx0, sy0;
+ private float pix_sx0, pix_sy0;
- // Buffer to be filled with one row's worth of alpha values
- private byte[] rowAA; // needs to be short if 16x16 subsampling
-
- // Track the number of vertical extrema of the incoming edge list
- // in order to determine the maximum number of crossings of a
- // scanline
- private int firstOrientation;
- private int lastOrientation;
- private int flips;
-
- // Parameters for emitRow
- private int alphaWidth;
-
- public Renderer() {
- }
-
- public void setAntialiasing(int subpixelLgPositionsX,
- int subpixelLgPositionsY) {
+ public Renderer(int subpixelLgPositionsX, int subpixelLgPositionsY,
+ int pix_boundsX, int pix_boundsY,
+ int pix_boundsWidth, int pix_boundsHeight,
+ int windingRule,
+ PiscesCache cache) {
this.SUBPIXEL_LG_POSITIONS_X = subpixelLgPositionsX;
this.SUBPIXEL_LG_POSITIONS_Y = subpixelLgPositionsY;
+ this.SUBPIXEL_MASK_X = (1 << (SUBPIXEL_LG_POSITIONS_X)) - 1;
+ this.SUBPIXEL_MASK_Y = (1 << (SUBPIXEL_LG_POSITIONS_Y)) - 1;
+ this.SUBPIXEL_POSITIONS_X = 1 << (SUBPIXEL_LG_POSITIONS_X);
+ this.SUBPIXEL_POSITIONS_Y = 1 << (SUBPIXEL_LG_POSITIONS_Y);
+ this.MAX_AA_ALPHA = (SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_Y);
- this.SUBPIXEL_MASK_X =
- (1 << (SUBPIXEL_LG_POSITIONS_X)) - 1;
- this.SUBPIXEL_MASK_Y =
- (1 << (SUBPIXEL_LG_POSITIONS_Y)) - 1;
- this.SUBPIXEL_POSITIONS_X =
- 1 << (SUBPIXEL_LG_POSITIONS_X);
- this.SUBPIXEL_POSITIONS_Y =
- 1 << (SUBPIXEL_LG_POSITIONS_Y);
- this.MAX_AA_ALPHA =
- (SUBPIXEL_POSITIONS_X*SUBPIXEL_POSITIONS_Y);
- this.MAX_AA_ALPHA_DENOM = 255*MAX_AA_ALPHA;
- this.HALF_MAX_AA_ALPHA_DENOM = MAX_AA_ALPHA_DENOM/2;
- this.XSHIFT = 16 - SUBPIXEL_LG_POSITIONS_X;
- this.YSHIFT = 16 - SUBPIXEL_LG_POSITIONS_Y;
- this.YSTEP = 1 << YSHIFT;
- this.HYSTEP = 1 << (YSHIFT - 1);
- this.YMASK = ~(YSTEP - 1);
- }
+ this.edges = new float[SIZEOF_STRUCT_EDGE * INIT_NUM_EDGES];
+ edgeMinY = Float.POSITIVE_INFINITY;
+ edgeMaxY = Float.NEGATIVE_INFINITY;
+ edgesSize = 0;
- public int getSubpixelLgPositionsX() {
- return SUBPIXEL_LG_POSITIONS_X;
- }
-
- public int getSubpixelLgPositionsY() {
- return SUBPIXEL_LG_POSITIONS_Y;
- }
-
- public void setWindingRule(int windingRule) {
this.windingRule = windingRule;
+ this.cache = cache;
+
+ this.boundsMinX = pix_boundsX * SUBPIXEL_POSITIONS_X;
+ this.boundsMinY = pix_boundsY * SUBPIXEL_POSITIONS_Y;
+ this.boundsMaxX = (pix_boundsX + pix_boundsWidth) * SUBPIXEL_POSITIONS_X;
+ this.boundsMaxY = (pix_boundsY + pix_boundsHeight) * SUBPIXEL_POSITIONS_Y;
+
+ this.pix_bboxX0 = pix_boundsX;
+ this.pix_bboxY0 = pix_boundsY;
+ this.pix_bboxX1 = pix_boundsX + pix_boundsWidth;
+ this.pix_bboxY1 = pix_boundsY + pix_boundsHeight;
}
- public int getWindingRule() {
- return windingRule;
+ private float tosubpixx(float pix_x) {
+ return pix_x * SUBPIXEL_POSITIONS_X;
+ }
+ private float tosubpixy(float pix_y) {
+ return pix_y * SUBPIXEL_POSITIONS_Y;
}
- public void beginRendering(int boundsX, int boundsY,
- int boundsWidth, int boundsHeight) {
- lastOrientation = 0;
- flips = 0;
-
- resetEdges();
-
- this.boundsMinX = boundsX << 16;
- this.boundsMinY = boundsY << 16;
- this.boundsMaxX = (boundsX + boundsWidth) << 16;
- this.boundsMaxY = (boundsY + boundsHeight) << 16;
-
- this.bboxX0 = boundsX;
- this.bboxY0 = boundsY;
- this.bboxX1 = boundsX + boundsWidth;
- this.bboxY1 = boundsY + boundsHeight;
- }
-
- public void moveTo(int x0, int y0) {
- // System.out.println("Renderer: moveTo " + x0/65536.0 + " " + y0/65536.0);
+ public void moveTo(float pix_x0, float pix_y0) {
close();
- this.sx0 = this.x0 = x0;
- this.sy0 = this.y0 = y0;
- this.lastOrientation = 0;
+ this.pix_sx0 = pix_x0;
+ this.pix_sy0 = pix_y0;
+ this.y0 = tosubpixy(pix_y0);
+ this.x0 = tosubpixx(pix_x0);
}
- public void lineJoin() {
- // System.out.println("Renderer: lineJoin");
- // do nothing
- }
+ public void lineJoin() { /* do nothing */ }
- public void lineTo(int x1, int y1) {
- // System.out.println("Renderer: lineTo " + x1/65536.0 + " " + y1/65536.0);
+ public void lineTo(float pix_x1, float pix_y1) {
+ float x1 = tosubpixx(pix_x1);
+ float y1 = tosubpixy(pix_y1);
// Ignore horizontal lines
- // Next line will count flip
if (y0 == y1) {
this.x0 = x1;
return;
}
- int orientation = (y0 < y1) ? 1 : -1;
- if (lastOrientation == 0) {
- firstOrientation = orientation;
- } else if (orientation != lastOrientation) {
- ++flips;
- }
- lastOrientation = orientation;
-
- // Bias Y by 1 ULP so endpoints never lie on a scanline
- addEdge(x0, y0 | 0x1, x1, y1 | 0x1);
+ addEdge(x0, y0, x1, y1);
this.x0 = x1;
this.y0 = y1;
}
public void close() {
- // System.out.println("Renderer: close");
-
- int orientation = lastOrientation;
- if (y0 != sy0) {
- orientation = (y0 < sy0) ? 1 : -1;
- }
- if (orientation != firstOrientation) {
- ++flips;
- }
- lineTo(sx0, sy0);
+ // lineTo expects its input in pixel coordinates.
+ lineTo(pix_sx0, pix_sy0);
}
public void end() {
close();
- // System.out.println("Renderer: end");
- // do nothing
- }
-
- // Scan convert a single edge
- private void computeCrossingsForEdge(int index,
- int boundsMinY, int boundsMaxY) {
- int iy0 = edges[index + 1];
- int iy1 = edges[index + 3];
-
- // Clip to valid Y range
- int clipy0 = (iy0 > boundsMinY) ? iy0 : boundsMinY;
- int clipy1 = (iy1 < boundsMaxY) ? iy1 : boundsMaxY;
-
- int minY = ((clipy0 + HYSTEP) & YMASK) + HYSTEP;
- int maxY = ((clipy1 - HYSTEP) & YMASK) + HYSTEP;
-
- // IMPL_NOTE - If line falls outside the valid X range, could
- // draw a vertical line instead
-
- // Exit if no scanlines are crossed
- if (minY > maxY) {
- return;
- }
-
- // Scan convert line using a DDA approach
-
- int ix0 = edges[index];
- int ix1 = edges[index + 2];
- long dx = ((long) ix1) - ix0;
- long dy = ((long) iy1) - iy0;
-
- // Compute first crossing point at y = minY
- int orientation = edges[index + 4];
- int y = minY;
- long lx = (((long) y) - iy0)*dx/dy + ix0;
- addCrossing(y >> YSHIFT, (int)(lx >> XSHIFT), orientation);
-
- // Advance y to next scanline, exit if past endpoint
- y += YSTEP;
- if (y > maxY) {
- return;
- }
-
- // Compute xstep only if additional scanlines are crossed
- // For each scanline, add xstep to lx and YSTEP to y and
- // emit the new crossing
- long xstep = ((long)YSTEP*dx)/dy;
- for (; y <= maxY; y += YSTEP) {
- lx += xstep;
- addCrossing(y >> YSHIFT, (int)(lx >> XSHIFT), orientation);
- }
- }
-
- private void computeBounds() {
- rasterMinX = crossingMinX & ~SUBPIXEL_MASK_X;
- rasterMaxX = crossingMaxX | SUBPIXEL_MASK_X;
- rasterMinY = crossingMinY & ~SUBPIXEL_MASK_Y;
- rasterMaxY = crossingMaxY | SUBPIXEL_MASK_Y;
-
- // If nothing was drawn, we have:
- // minX = Integer.MAX_VALUE and maxX = Integer.MIN_VALUE
- // so nothing to render
- if (rasterMinX > rasterMaxX || rasterMinY > rasterMaxY) {
- rasterMinX = 0;
- rasterMaxX = -1;
- rasterMinY = 0;
- rasterMaxY = -1;
- return;
- }
-
- if (rasterMinX < boundsMinX >> XSHIFT) {
- rasterMinX = boundsMinX >> XSHIFT;
- }
- if (rasterMinY < boundsMinY >> YSHIFT) {
- rasterMinY = boundsMinY >> YSHIFT;
- }
- if (rasterMaxX > boundsMaxX >> XSHIFT) {
- rasterMaxX = boundsMaxX >> XSHIFT;
- }
- if (rasterMaxY > boundsMaxY >> YSHIFT) {
- rasterMaxY = boundsMaxY >> YSHIFT;
- }
- }
-
- private int clamp(int x, int min, int max) {
- if (x < min) {
- return min;
- } else if (x > max) {
- return max;
- }
- return x;
}
private void _endRendering() {
- if (flips == 0) {
- bboxX0 = bboxY0 = 0;
- bboxX1 = bboxY1 = -1;
- return;
- }
+ // Mask to determine the relevant bit of the crossing sum
+ // 0x1 if EVEN_ODD, all bits if NON_ZERO
+ int mask = (windingRule == WIND_EVEN_ODD) ? 0x1 : ~0x0;
- // Special case for filling a single rect with a flat, opaque color
- // REMIND: This special case was not originally written to fill a
- // cache object and called directly to a Blit - it needs some code
- // to fill the cache instead to be useful for this usage...
- if (false /* Does not work with cache (yet?) */ &&
- edgeIdx == 10 &&
- edges[0] == edges[2] &&
- edges[1] == edges[6] &&
- edges[3] == edges[8] &&
- edges[5] == edges[7] &&
- Math.abs(edges[0] - edges[5]) > MIN_QUAD_OPT_WIDTH)
- {
+ // add 1 to better deal with the last pixel in a pixel row.
+ int width = ((boundsMaxX - boundsMinX) >> SUBPIXEL_LG_POSITIONS_X) + 1;
+ byte[] alpha = new byte[width+1];
- int x0 = edges[0] >> XSHIFT;
- int y0 = edges[1] >> YSHIFT;
- int x1 = edges[5] >> XSHIFT;
- int y1 = edges[3] >> YSHIFT;
+ // Now we iterate through the scanlines. We must tell emitRow the coord
+ // of the first non-transparent pixel, so we must keep accumulators for
+ // the first and last pixels of the section of the current pixel row
+ // that we will emit.
+ // We also need to accumulate pix_bbox*, but the iterator does it
+ // for us. We will just get the values from it once this loop is done
+ int pix_maxX = Integer.MIN_VALUE;
+ int pix_minX = Integer.MAX_VALUE;
- if (x0 > x1) {
- int tmp = x0;
- x0 = x1;
- x1 = tmp;
- }
- if (y0 > y1) {
- int tmp = y0;
- y0 = y1;
- y1 = tmp;
+ int y = boundsMinY; // needs to be declared here so we emit the last row properly.
+ ScanLineItInitialize();
+ for ( ; ScanLineItHasNext(); ) {
+ int numCrossings = ScanLineItGoToNextYAndComputeCrossings();
+ y = ScanLineItCurrentY();
+
+ if (numCrossings > 0) {
+ int lowx = crossings[0] >> 1;
+ int highx = crossings[numCrossings - 1] >> 1;
+ int x0 = Math.max(lowx, boundsMinX);
+ int x1 = Math.min(highx, boundsMaxX);
+
+ pix_minX = Math.min(pix_minX, x0 >> SUBPIXEL_LG_POSITIONS_X);
+ pix_maxX = Math.max(pix_maxX, x1 >> SUBPIXEL_LG_POSITIONS_X);
}
- int bMinX = this.boundsMinX >> XSHIFT;
- int bMinY = this.boundsMinY >> YSHIFT;
- int bMaxX = this.boundsMaxX >> XSHIFT;
- int bMaxY = this.boundsMaxY >> YSHIFT;
+ int sum = 0;
+ int prev = boundsMinX;
+ for (int i = 0; i < numCrossings; i++) {
+ int curxo = crossings[i];
+ int curx = curxo >> 1;
+ int crorientation = ((curxo & 0x1) == 0x1) ? 1 : -1;
+ if ((sum & mask) != 0) {
+ int x0 = Math.max(prev, boundsMinX);
+ int x1 = Math.min(curx, boundsMaxX);
+ if (x0 < x1) {
+ x0 -= boundsMinX; // turn x0, x1 from coords to indeces
+ x1 -= boundsMinX; // in the alpha array.
- // Clip to image bounds in supersampled coordinates
- x0 = clamp(x0, bMinX, bMaxX);
- x1 = clamp(x1, bMinX, bMaxX);
- y0 = clamp(y0, bMinY, bMaxY);
- y1 = clamp(y1, bMinY, bMaxY);
+ int pix_x = x0 >> SUBPIXEL_LG_POSITIONS_X;
+ int pix_xmaxm1 = (x1 - 1) >> SUBPIXEL_LG_POSITIONS_X;
- /*
- * REMIND: Need to fill the cache here instead...
- Blit.fillRectSrcOver(this,
- imageData, imageType,
- imageOffset,
- imageScanlineStride, imagePixelStride,
- width, height,
- x0, y0, x1, y1,
- cred, cgreen, cblue);
- */
-
- bboxX0 = x0 >> SUBPIXEL_LG_POSITIONS_X;
- bboxY0 = y0 >> SUBPIXEL_LG_POSITIONS_Y;
- bboxX1 = (x1 + SUBPIXEL_POSITIONS_X - 1)
- >> SUBPIXEL_LG_POSITIONS_X;
- bboxY1 = (y1 + SUBPIXEL_POSITIONS_Y - 1)
- >> SUBPIXEL_LG_POSITIONS_Y;
-
- return;
- }
-
- int minY = (edgeMinY > boundsMinY) ? edgeMinY : boundsMinY;
- int maxY = (edgeMaxY < boundsMaxY) ? edgeMaxY : boundsMaxY;
-
- // Check for empty intersection of primitive with the drawing area
- if (minY > maxY) {
- bboxX0 = bboxY0 = 0;
- bboxX1 = bboxY1 = -1;
- return;
- }
-
- // Compute Y extent in subpixel coordinates
- int iminY = (minY >> YSHIFT) & ~SUBPIXEL_MASK_Y;
- int imaxY = (maxY >> YSHIFT) | SUBPIXEL_MASK_Y;
- int yextent = (imaxY - iminY) + 1;
-
- // Maximum number of crossings
- int size = flips*yextent;
-
- int bmax = (boundsMaxY >> YSHIFT) - 1;
- if (imaxY > bmax) {
- imaxY = bmax;
- }
-
- // Initialize X bounds, will be refined for each strip
- bboxX0 = Integer.MAX_VALUE;
- bboxX1 = Integer.MIN_VALUE;
-
- // Set Y bounds
- bboxY0 = iminY >> SUBPIXEL_LG_POSITIONS_Y;
- bboxY1 = (imaxY + SUBPIXEL_POSITIONS_Y - 1) >> SUBPIXEL_LG_POSITIONS_Y;
-
- // Compute number of rows that can be processing using
- // a crossings table no larger than DEFAULT_CROSSINGS_SIZE.
- // However, we must process at least one row, so we grow the table
- // temporarily if needed. This would require an object with a
- // huge number of flips.
- int rows = DEFAULT_CROSSINGS_SIZE/(flips*SUBPIXEL_POSITIONS_Y);
- rows = Math.min(rows, yextent);
- rows = Math.max(rows, 1);
- for (int i = iminY; i <= imaxY; i += rows*SUBPIXEL_POSITIONS_Y) {
- // Compute index of last scanline to be processed in this pass
- int last = Math.min(i + rows*SUBPIXEL_POSITIONS_Y - 1, imaxY);
- setCrossingsExtents(i, last, flips);
-
- int bminY = i << YSHIFT;
- int bmaxY = (last << YSHIFT) | ~YMASK;
-
- // Process edges from the edge list
- int maxIdx = edgeIdx;
- for (int index = 0; index < maxIdx; index += 5) {
- // Test y1 < min:
- //
- // If edge lies entirely above current strip,
- // discard it
- if (edges[index + 3] < bminY) {
- // Overwrite the edge with the last edge
- edgeIdx -= 5;
- int fidx = edgeIdx;
- int tidx = index;
- edges[tidx++] = edges[fidx++];
- edges[tidx++] = edges[fidx++];
- edges[tidx++] = edges[fidx++];
- edges[tidx++] = edges[fidx++];
- edges[tidx ] = edges[fidx ];
-
- maxIdx -= 5;
- index -= 5;
- continue;
+ if (pix_x == pix_xmaxm1) {
+ // Start and end in same pixel
+ alpha[pix_x] += (x1 - x0);
+ alpha[pix_x+1] -= (x1 - x0);
+ } else {
+ int pix_xmax = x1 >> SUBPIXEL_LG_POSITIONS_X;
+ alpha[pix_x] += SUBPIXEL_POSITIONS_X - (x0 & SUBPIXEL_MASK_X);
+ alpha[pix_x+1] += (x0 & SUBPIXEL_MASK_X);
+ alpha[pix_xmax] -= SUBPIXEL_POSITIONS_X - (x1 & SUBPIXEL_MASK_X);
+ alpha[pix_xmax+1] -= (x1 & SUBPIXEL_MASK_X);
+ }
+ }
}
-
- // Test y0 > max:
- //
- // If edge lies entirely below current strip,
- // skip it for now
- if (edges[index + 1] > bmaxY) {
- continue;
- }
-
- computeCrossingsForEdge(index, bminY, bmaxY);
+ sum += crorientation;
+ prev = curx;
}
- computeBounds();
- if (rasterMaxX < rasterMinX) {
- continue;
+ if ((y & SUBPIXEL_MASK_Y) == SUBPIXEL_MASK_Y) {
+ emitRow(alpha, y >> SUBPIXEL_LG_POSITIONS_Y, pix_minX, pix_maxX);
+ pix_minX = Integer.MAX_VALUE;
+ pix_maxX = Integer.MIN_VALUE;
}
-
- bboxX0 = Math.min(bboxX0,
- rasterMinX >> SUBPIXEL_LG_POSITIONS_X);
- bboxX1 = Math.max(bboxX1,
- (rasterMaxX + SUBPIXEL_POSITIONS_X - 1)
- >> SUBPIXEL_LG_POSITIONS_X);
- renderStrip();
}
- // Free up any unusually large scratchpad memory used by the
- // preceding primitive
- crossingListFinished();
+ // Emit final row
+ if (pix_maxX >= pix_minX) {
+ emitRow(alpha, y >> SUBPIXEL_LG_POSITIONS_Y, pix_minX, pix_maxX);
+ }
+ pix_bboxX0 = minX >> SUBPIXEL_LG_POSITIONS_X;
+ pix_bboxX1 = maxX >> SUBPIXEL_LG_POSITIONS_X;
+ pix_bboxY0 = minY >> SUBPIXEL_LG_POSITIONS_Y;
+ pix_bboxY1 = maxY >> SUBPIXEL_LG_POSITIONS_Y;
}
+
public void endRendering() {
// Set up the cache to accumulate the bounding box
if (cache != null) {
@@ -478,176 +472,31 @@ public class Renderer extends LineSink {
_endRendering();
}
- public void getBoundingBox(int[] bbox) {
- bbox[0] = bboxX0;
- bbox[1] = bboxY0;
- bbox[2] = bboxX1 - bboxX0;
- bbox[3] = bboxY1 - bboxY0;
+ public void getBoundingBox(int[] pix_bbox) {
+ pix_bbox[0] = pix_bboxX0;
+ pix_bbox[1] = pix_bboxY0;
+ pix_bbox[2] = pix_bboxX1 - pix_bboxX0;
+ pix_bbox[3] = pix_bboxY1 - pix_bboxY0;
}
- private void renderStrip() {
- // Grow rowAA according to the raster width
- int width = (rasterMaxX - rasterMinX + 1) >> SUBPIXEL_LG_POSITIONS_X;
- alphaWidth = width;
-
- // Allocate one extra entry in rowAA to avoid a conditional in
- // the rendering loop
- int bufLen = width + 1;
- if (this.rowAA == null || this.rowAA.length < bufLen) {
- this.rowAA = new byte[bufLen];
- }
-
- // Mask to determine the relevant bit of the crossing sum
- // 0x1 if EVEN_ODD, all bits if NON_ZERO
- int mask = (windingRule == WIND_EVEN_ODD) ? 0x1 : ~0x0;
-
- int y = 0;
- int prevY = rasterMinY - 1;
-
- int minX = Integer.MAX_VALUE;
- int maxX = Integer.MIN_VALUE;
-
- iterateCrossings();
- while (hasMoreCrossingRows()) {
- y = crossingY;
-
- // Emit any skipped rows
- for (int j = prevY + 1; j < y; j++) {
- if (((j & SUBPIXEL_MASK_Y) == SUBPIXEL_MASK_Y) ||
- (j == rasterMaxY)) {
- emitRow(j >> SUBPIXEL_LG_POSITIONS_Y, 0, -1);
- }
- }
- prevY = y;
-
- if (crossingRowIndex < crossingRowCount) {
- int lx = crossings[crossingRowOffset + crossingRowIndex];
- lx >>= 1;
- int hx = crossings[crossingRowOffset + crossingRowCount - 1];
- hx >>= 1;
- int x0 = lx > rasterMinX ? lx : rasterMinX;
- int x1 = hx < rasterMaxX ? hx : rasterMaxX;
- x0 -= rasterMinX;
- x1 -= rasterMinX;
-
- minX = Math.min(minX, x0 >> SUBPIXEL_LG_POSITIONS_X);
- maxX = Math.max(maxX, x1 >> SUBPIXEL_LG_POSITIONS_X);
- }
-
- int sum = 0;
- int prev = rasterMinX;
- while (crossingRowIndex < crossingRowCount) {
- int crxo = crossings[crossingRowOffset + crossingRowIndex];
- crossingRowIndex++;
-
- int crx = crxo >> 1;
- int crorientation = ((crxo & 0x1) == 0x1) ? 1 : -1;
-
- if ((sum & mask) != 0) {
- // Clip to active X range, if x1 < x0 loop will
- // have no effect
- int x0 = prev > rasterMinX ? prev : rasterMinX;
- int x1 = crx < rasterMaxX ? crx : rasterMaxX;
-
- // Empty spans
- if (x1 > x0) {
- x0 -= rasterMinX;
- x1 -= rasterMinX;
-
- // Accumulate alpha, equivalent to:
- // for (int x = x0; x < x1; x++) {
- // ++rowAA[x >> SUBPIXEL_LG_POSITIONS_X];
- // }
- //
- // In the middle of the span, we can update a full
- // pixel at a time (i.e., SUBPIXEL_POSITIONS_X
- // subpixels)
-
- int x = x0 >> SUBPIXEL_LG_POSITIONS_X;
- int xmaxm1 = (x1 - 1) >> SUBPIXEL_LG_POSITIONS_X;
- if (x == xmaxm1) {
- // Start and end in same pixel
- rowAA[x] += x1 - x0;
- } else {
- // Start and end in different pixels
- rowAA[x++] += SUBPIXEL_POSITIONS_X -
- (x0 & SUBPIXEL_MASK_X);
- int xmax = x1 >> SUBPIXEL_LG_POSITIONS_X;
- while (x < xmax) {
- rowAA[x++] += SUBPIXEL_POSITIONS_X;
- }
- // Note - at this point it is possible that
- // x == width, which implies that
- // x1 & SUBPIXEL_MASK_X == 0. We allocate
- // one extra entry in rowAA so this
- // assignment will be harmless. The alternative
- // is an extra conditional here, or some other
- // scheme to deal with the last pixel better.
- rowAA[x] += x1 & SUBPIXEL_MASK_X;
- }
- }
- }
- sum += crorientation;
- prev = crx;
- }
-
- // Every SUBPIXEL_POSITIONS rows, output an antialiased row
- if (((y & SUBPIXEL_MASK_Y) == SUBPIXEL_MASK_Y) ||
- (y == rasterMaxY)) {
- emitRow(y >> SUBPIXEL_LG_POSITIONS_Y, minX, maxX);
- minX = Integer.MAX_VALUE;
- maxX = Integer.MIN_VALUE;
- }
- }
-
- // Emit final row
- for (int j = prevY + 1; j <= rasterMaxY; j++) {
- if (((j & SUBPIXEL_MASK_Y) == SUBPIXEL_MASK_Y) ||
- (j == rasterMaxY)) {
- emitRow(j >> SUBPIXEL_LG_POSITIONS_Y, minX, maxX);
- minX = Integer.MAX_VALUE;
- maxX = Integer.MIN_VALUE;
- }
- }
- }
-
- private void clearAlpha(byte[] alpha,
- int width,
- int minX, int maxX) {
- if (maxX >= minX) {
- int w = maxX - minX + 1;
- if (w + minX > width) {
- w = width - minX;
- }
-
- int aidx = minX;
- for (int i = 0; i < w; i++, aidx++) {
- alpha[aidx] = (byte)0;
- }
- }
- }
-
- private void emitRow(int y, int minX, int maxX) {
+ private void emitRow(byte[] alphaRow, int pix_y, int pix_from, int pix_to) {
// Copy rowAA data into the cache if one is present
if (cache != null) {
- if (maxX >= minX) {
- int x0 = minX + (rasterMinX >> SUBPIXEL_LG_POSITIONS_X);
- int x1 = maxX + (rasterMinX >> SUBPIXEL_LG_POSITIONS_X);
+ if (pix_to >= pix_from) {
+ cache.startRow(pix_y, pix_from, pix_to);
- cache.startRow(y, x0, x1);
- int srcIdx = minX;
+ // Perform run-length encoding and store results in the cache
+ int from = pix_from - (boundsMinX >> SUBPIXEL_LG_POSITIONS_X);
+ int to = pix_to - (boundsMinX >> SUBPIXEL_LG_POSITIONS_X);
- // Perform run-length encoding
- // and store results in the cache
- byte startVal = rowAA[srcIdx++];
int runLen = 1;
- while (srcIdx <= maxX) {
- byte nextVal = rowAA[srcIdx++];
+ byte startVal = alphaRow[from];
+ for (int i = from + 1; i <= to; i++) {
+ byte nextVal = (byte)(startVal + alphaRow[i]);
if (nextVal == startVal && runLen < 255) {
- ++runLen;
+ runLen++;
} else {
cache.addRLERun(startVal, runLen);
-
runLen = 1;
startVal = nextVal;
}
@@ -656,190 +505,6 @@ public class Renderer extends LineSink {
cache.addRLERun((byte)0, 0);
}
}
-
- clearAlpha(rowAA,
- alphaWidth,
- minX, maxX);
- }
-
- public void setCache(PiscesCache cache) {
- this.cache = cache;
- }
-
- // Edge list data
-
- private int[] edges = new int[5*INITIAL_EDGES];
- private int edgeIdx = 0;
- private int edgeMinY = Integer.MAX_VALUE;
- private int edgeMaxY = Integer.MIN_VALUE;
-
- private void addEdge(int x0, int y0, int x1, int y1) {
- int newLen = edgeIdx + 5;
- if (edges.length < newLen) {
- int[] tmp = new int[Math.max(11*edges.length/10, newLen)];
- System.arraycopy(edges, 0, tmp, 0, edgeIdx);
- this.edges = tmp;
- }
-
- int orientation = 1;
- if (y0 > y1) {
- int tmp = y0;
- y0 = y1;
- y1 = tmp;
-
- orientation = -1;
- }
-
- // Skip edges that don't cross a subsampled scanline
- int eminY = ((y0 + HYSTEP) & YMASK);
- int emaxY = ((y1 - HYSTEP) & YMASK);
- if (eminY > emaxY) {
- return;
- }
-
- if (orientation == -1) {
- int tmp = x0;
- x0 = x1;
- x1 = tmp;
- }
-
- edges[edgeIdx++] = x0;
- edges[edgeIdx++] = y0;
- edges[edgeIdx++] = x1;
- edges[edgeIdx++] = y1;
- edges[edgeIdx++] = orientation;
-
- // Update Y bounds of primitive
- if (y0 < edgeMinY) {
- edgeMinY = y0;
- }
- if (y1 > edgeMaxY) {
- edgeMaxY = y1;
- }
- }
-
- private void resetEdges() {
- this.edgeIdx = 0;
- this.edgeMinY = Integer.MAX_VALUE;
- this.edgeMaxY = Integer.MIN_VALUE;
- }
-
- // Crossing list data
-
- private int[] crossingIndices;
- private int[] crossings;
- private int crossingMinY;
- private int crossingMaxY;
- private int crossingMinX = Integer.MAX_VALUE;
- private int crossingMaxX = Integer.MIN_VALUE;
- private int crossingMaxXEntries;
- private int numCrossings = 0;
- private boolean crossingsSorted = false;
-
- private int crossingY;
- private int crossingRowCount;
- private int crossingRowOffset;
- private int crossingRowIndex;
-
- private void setCrossingsExtents(int minY, int maxY, int maxXEntries) {
- int yextent = maxY - minY + 1;
-
- // Grow indices array as needed
- if (crossingIndices == null || crossingIndices.length < yextent) {
- this.crossingIndices =
- new int[Math.max(yextent, DEFAULT_INDICES_SIZE)];
- }
- // Grow crossings array as needed
- if (crossings == null || crossings.length < yextent*maxXEntries) {
- this.crossings = new int[Math.max(yextent*maxXEntries,
- DEFAULT_CROSSINGS_SIZE)];
- }
- this.crossingMinY = minY;
- this.crossingMaxY = maxY;
- this.crossingMaxXEntries = maxXEntries;
- resetCrossings();
- }
-
- private void resetCrossings() {
- int yextent = crossingMaxY - crossingMinY + 1;
- int start = 0;
- for (int i = 0; i < yextent; i++) {
- crossingIndices[i] = start;
- start += crossingMaxXEntries;
- }
- crossingMinX = Integer.MAX_VALUE;
- crossingMaxX = Integer.MIN_VALUE;
- numCrossings = 0;
- crossingsSorted = false;
- }
-
- // Free sorting arrays if larger than maximum size
- private void crossingListFinished() {
- if (crossings != null && crossings.length > DEFAULT_CROSSINGS_SIZE) {
- crossings = new int[DEFAULT_CROSSINGS_SIZE];
- }
- if (crossingIndices != null &&
- crossingIndices.length > DEFAULT_INDICES_SIZE)
- {
- crossingIndices = new int[DEFAULT_INDICES_SIZE];
- }
- }
-
- private void sortCrossings(int[] x, int off, int len) {
- for (int i = off + 1; i < off + len; i++) {
- int j = i;
- int xj = x[j];
- int xjm1;
-
- while (j > off && (xjm1 = x[j - 1]) > xj) {
- x[j] = xjm1;
- x[j - 1] = xj;
- j--;
- }
- }
- }
-
- private void sortCrossings() {
- int start = 0;
- for (int i = 0; i <= crossingMaxY - crossingMinY; i++) {
- sortCrossings(crossings, start, crossingIndices[i] - start);
- start += crossingMaxXEntries;
- }
- }
-
- private void addCrossing(int y, int x, int orientation) {
- if (x < crossingMinX) {
- crossingMinX = x;
- }
- if (x > crossingMaxX) {
- crossingMaxX = x;
- }
-
- int index = crossingIndices[y - crossingMinY]++;
- x <<= 1;
- crossings[index] = (orientation == 1) ? (x | 0x1) : x;
-
- ++numCrossings;
- }
-
- private void iterateCrossings() {
- if (!crossingsSorted) {
- sortCrossings();
- crossingsSorted = true;
- }
- crossingY = crossingMinY - 1;
- crossingRowOffset = -crossingMaxXEntries;
- }
-
- private boolean hasMoreCrossingRows() {
- if (++crossingY <= crossingMaxY) {
- crossingRowOffset += crossingMaxXEntries;
- int y = crossingY - crossingMinY;
- crossingRowCount = crossingIndices[y] - y*crossingMaxXEntries;
- crossingRowIndex = 0;
- return true;
- } else {
- return false;
- }
+ java.util.Arrays.fill(alphaRow, (byte)0);
}
}
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Stroker.java b/jdk/src/share/classes/sun/java2d/pisces/Stroker.java
index e17283a3bdc..574c460fea9 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Stroker.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Stroker.java
@@ -25,7 +25,7 @@
package sun.java2d.pisces;
-public class Stroker extends LineSink {
+public class Stroker implements LineSink {
private static final int MOVE_TO = 0;
private static final int LINE_TO = 1;
@@ -61,19 +61,15 @@ public class Stroker extends LineSink {
*/
public static final int CAP_SQUARE = 2;
- LineSink output;
+ private final LineSink output;
- int lineWidth;
- int capStyle;
- int joinStyle;
- int miterLimit;
+ private final int capStyle;
+ private final int joinStyle;
- Transform4 transform;
- int m00, m01;
- int m10, m11;
+ private final float m00, m01, m10, m11, det;
- int lineWidth2;
- long scaledLineWidth2;
+ private final float lineWidth2;
+ private final float scaledLineWidth2;
// For any pen offset (pen_dx, pen_dy) that does not depend on
// the line orientation, the pen should be transformed so that:
@@ -88,143 +84,86 @@ public class Stroker extends LineSink {
//
// pen_dx'(r, theta) = r*(m00*cos(theta) + m01*sin(theta))
// pen_dy'(r, theta) = r*(m10*cos(theta) + m11*sin(theta))
- int numPenSegments;
- int[] pen_dx;
- int[] pen_dy;
- boolean[] penIncluded;
- int[] join;
+ private int numPenSegments;
+ private final float[] pen_dx;
+ private final float[] pen_dy;
+ private boolean[] penIncluded;
+ private final float[] join;
- int[] offset = new int[2];
- int[] reverse = new int[100];
- int[] miter = new int[2];
- long miterLimitSq;
+ private final float[] offset = new float[2];
+ private float[] reverse = new float[100];
+ private final float[] miter = new float[2];
+ private final float miterLimitSq;
- int prev;
- int rindex;
- boolean started;
- boolean lineToOrigin;
- boolean joinToOrigin;
+ private int prev;
+ private int rindex;
+ private boolean started;
+ private boolean lineToOrigin;
+ private boolean joinToOrigin;
- int sx0, sy0, sx1, sy1, x0, y0, x1, y1;
- int mx0, my0, mx1, my1, omx, omy;
- int lx0, ly0, lx1, ly1, lx0p, ly0p, px0, py0;
+ private float sx0, sy0, sx1, sy1, x0, y0, px0, py0;
+ private float mx0, my0, omx, omy;
- double m00_2_m01_2;
- double m10_2_m11_2;
- double m00_m10_m01_m11;
-
- /**
- * Empty constructor. setOutput
and
- * setParameters
must be called prior to calling any
- * other methods.
- */
- public Stroker() {}
+ private float m00_2_m01_2;
+ private float m10_2_m11_2;
+ private float m00_m10_m01_m11;
/**
* Constructs a Stroker
.
*
* @param output an output LineSink
.
- * @param lineWidth the desired line width in pixels, in S15.16
- * format.
+ * @param lineWidth the desired line width in pixels
* @param capStyle the desired end cap style, one of
* CAP_BUTT
, CAP_ROUND
or
* CAP_SQUARE
.
* @param joinStyle the desired line join style, one of
* JOIN_MITER
, JOIN_ROUND
or
* JOIN_BEVEL
.
- * @param miterLimit the desired miter limit, in S15.16 format.
+ * @param miterLimit the desired miter limit
* @param transform a Transform4
object indicating
* the transform that has been previously applied to all incoming
* coordinates. This is required in order to produce consistently
* shaped end caps and joins.
*/
public Stroker(LineSink output,
- int lineWidth,
+ float lineWidth,
int capStyle,
int joinStyle,
- int miterLimit,
- Transform4 transform) {
- setOutput(output);
- setParameters(lineWidth, capStyle, joinStyle, miterLimit, transform);
- }
-
- /**
- * Sets the output LineSink
of this
- * Stroker
.
- *
- * @param output an output LineSink
.
- */
- public void setOutput(LineSink output) {
+ float miterLimit,
+ float m00, float m01, float m10, float m11) {
this.output = output;
- }
- /**
- * Sets the parameters of this Stroker
.
- * @param lineWidth the desired line width in pixels, in S15.16
- * format.
- * @param capStyle the desired end cap style, one of
- * CAP_BUTT
, CAP_ROUND
or
- * CAP_SQUARE
.
- * @param joinStyle the desired line join style, one of
- * JOIN_MITER
, JOIN_ROUND
or
- * JOIN_BEVEL
.
- * @param miterLimit the desired miter limit, in S15.16 format.
- * @param transform a Transform4
object indicating
- * the transform that has been previously applied to all incoming
- * coordinates. This is required in order to produce consistently
- * shaped end caps and joins.
- */
- public void setParameters(int lineWidth,
- int capStyle,
- int joinStyle,
- int miterLimit,
- Transform4 transform) {
- this.lineWidth = lineWidth;
- this.lineWidth2 = lineWidth >> 1;
- this.scaledLineWidth2 = ((long)transform.m00*lineWidth2) >> 16;
+ this.lineWidth2 = lineWidth / 2;
+ this.scaledLineWidth2 = m00 * lineWidth2;
this.capStyle = capStyle;
this.joinStyle = joinStyle;
- this.miterLimit = miterLimit;
- this.transform = transform;
- this.m00 = transform.m00;
- this.m01 = transform.m01;
- this.m10 = transform.m10;
- this.m11 = transform.m11;
+ m00_2_m01_2 = m00*m00 + m01*m01;
+ m10_2_m11_2 = m10*m10 + m11*m11;
+ m00_m10_m01_m11 = m00*m10 + m01*m11;
- this.m00_2_m01_2 = (double)m00*m00 + (double)m01*m01;
- this.m10_2_m11_2 = (double)m10*m10 + (double)m11*m11;
- this.m00_m10_m01_m11 = (double)m00*m10 + (double)m01*m11;
+ this.m00 = m00;
+ this.m01 = m01;
+ this.m10 = m10;
+ this.m11 = m11;
+ det = m00*m11 - m01*m10;
- double dm00 = m00/65536.0;
- double dm01 = m01/65536.0;
- double dm10 = m10/65536.0;
- double dm11 = m11/65536.0;
- double determinant = dm00*dm11 - dm01*dm10;
+ float limit = miterLimit * lineWidth2 * det;
+ this.miterLimitSq = limit*limit;
- if (joinStyle == JOIN_MITER) {
- double limit =
- (miterLimit/65536.0)*(lineWidth2/65536.0)*determinant;
- double limitSq = limit*limit;
- this.miterLimitSq = (long)(limitSq*65536.0*65536.0);
- }
-
- this.numPenSegments = (int)(3.14159f*lineWidth/65536.0f);
- if (pen_dx == null || pen_dx.length < numPenSegments) {
- this.pen_dx = new int[numPenSegments];
- this.pen_dy = new int[numPenSegments];
- this.penIncluded = new boolean[numPenSegments];
- this.join = new int[2*numPenSegments];
- }
+ this.numPenSegments = (int)(3.14159f * lineWidth);
+ this.pen_dx = new float[numPenSegments];
+ this.pen_dy = new float[numPenSegments];
+ this.penIncluded = new boolean[numPenSegments];
+ this.join = new float[2*numPenSegments];
for (int i = 0; i < numPenSegments; i++) {
- double r = lineWidth/2.0;
- double theta = (double)i*2.0*Math.PI/numPenSegments;
+ double theta = (i * 2.0 * Math.PI)/numPenSegments;
double cos = Math.cos(theta);
double sin = Math.sin(theta);
- pen_dx[i] = (int)(r*(dm00*cos + dm01*sin));
- pen_dy[i] = (int)(r*(dm10*cos + dm11*sin));
+ pen_dx[i] = (float)(lineWidth2 * (m00*cos + m01*sin));
+ pen_dy[i] = (float)(lineWidth2 * (m10*cos + m11*sin));
}
prev = CLOSE;
@@ -233,32 +172,31 @@ public class Stroker extends LineSink {
lineToOrigin = false;
}
- private void computeOffset(int x0, int y0, int x1, int y1, int[] m) {
- long lx = (long)x1 - (long)x0;
- long ly = (long)y1 - (long)y0;
+ private void computeOffset(float x0, float y0,
+ float x1, float y1, float[] m) {
+ float lx = x1 - x0;
+ float ly = y1 - y0;
- int dx, dy;
+ float dx, dy;
if (m00 > 0 && m00 == m11 && m01 == 0 & m10 == 0) {
- long ilen = PiscesMath.hypot(lx, ly);
+ float ilen = (float)Math.hypot(lx, ly);
if (ilen == 0) {
dx = dy = 0;
} else {
- dx = (int)( (ly*scaledLineWidth2)/ilen);
- dy = (int)(-(lx*scaledLineWidth2)/ilen);
+ dx = (ly * scaledLineWidth2)/ilen;
+ dy = -(lx * scaledLineWidth2)/ilen;
}
} else {
- double dlx = x1 - x0;
- double dly = y1 - y0;
- double det = (double)m00*m11 - (double)m01*m10;
int sdet = (det > 0) ? 1 : -1;
- double a = dly*m00 - dlx*m10;
- double b = dly*m01 - dlx*m11;
- double dh = PiscesMath.hypot(a, b);
- double div = sdet*lineWidth2/(65536.0*dh);
- double ddx = dly*m00_2_m01_2 - dlx*m00_m10_m01_m11;
- double ddy = dly*m00_m10_m01_m11 - dlx*m10_2_m11_2;
- dx = (int)(ddx*div);
- dy = (int)(ddy*div);
+ float a = ly * m00 - lx * m10;
+ float b = ly * m01 - lx * m11;
+ float dh = (float)Math.hypot(a, b);
+ float div = sdet * lineWidth2/dh;
+
+ float ddx = ly * m00_2_m01_2 - lx * m00_m10_m01_m11;
+ float ddy = ly * m00_m10_m01_m11 - lx * m10_2_m11_2;
+ dx = ddx*div;
+ dy = ddy*div;
}
m[0] = dx;
@@ -267,58 +205,43 @@ public class Stroker extends LineSink {
private void ensureCapacity(int newrindex) {
if (reverse.length < newrindex) {
- int[] tmp = new int[Math.max(newrindex, 6*reverse.length/5)];
- System.arraycopy(reverse, 0, tmp, 0, rindex);
- this.reverse = tmp;
+ reverse = java.util.Arrays.copyOf(reverse, 6*reverse.length/5);
}
}
- private boolean isCCW(int x0, int y0,
- int x1, int y1,
- int x2, int y2) {
- int dx0 = x1 - x0;
- int dy0 = y1 - y0;
- int dx1 = x2 - x1;
- int dy1 = y2 - y1;
- return (long)dx0*dy1 < (long)dy0*dx1;
+ private boolean isCCW(float x0, float y0,
+ float x1, float y1,
+ float x2, float y2) {
+ return (x1 - x0) * (y2 - y1) < (y1 - y0) * (x2 - x1);
}
- private boolean side(int x, int y, int x0, int y0, int x1, int y1) {
- long lx = x;
- long ly = y;
- long lx0 = x0;
- long ly0 = y0;
- long lx1 = x1;
- long ly1 = y1;
-
- return (ly0 - ly1)*lx + (lx1 - lx0)*ly + (lx0*ly1 - lx1*ly0) > 0;
+ private boolean side(float x, float y,
+ float x0, float y0,
+ float x1, float y1) {
+ return (y0 - y1)*x + (x1 - x0)*y + (x0*y1 - x1*y0) > 0;
}
- private int computeRoundJoin(int cx, int cy,
- int xa, int ya,
- int xb, int yb,
+ private int computeRoundJoin(float cx, float cy,
+ float xa, float ya,
+ float xb, float yb,
int side,
boolean flip,
- int[] join) {
- int px, py;
+ float[] join) {
+ float px, py;
int ncoords = 0;
boolean centerSide;
if (side == 0) {
centerSide = side(cx, cy, xa, ya, xb, yb);
} else {
- centerSide = (side == 1) ? true : false;
+ centerSide = (side == 1);
}
for (int i = 0; i < numPenSegments; i++) {
px = cx + pen_dx[i];
py = cy + pen_dy[i];
boolean penSide = side(px, py, xa, ya, xb, yb);
- if (penSide != centerSide) {
- penIncluded[i] = true;
- } else {
- penIncluded[i] = false;
- }
+ penIncluded[i] = (penSide != centerSide);
}
int start = -1, end = -1;
@@ -338,10 +261,10 @@ public class Stroker extends LineSink {
}
if (start != -1 && end != -1) {
- long dxa = cx + pen_dx[start] - xa;
- long dya = cy + pen_dy[start] - ya;
- long dxb = cx + pen_dx[start] - xb;
- long dyb = cy + pen_dy[start] - yb;
+ float dxa = cx + pen_dx[start] - xa;
+ float dya = cy + pen_dy[start] - ya;
+ float dxb = cx + pen_dx[start] - xb;
+ float dyb = cy + pen_dy[start] - yb;
boolean rev = (dxa*dxa + dya*dya > dxb*dxb + dyb*dyb);
int i = rev ? end : start;
@@ -362,22 +285,25 @@ public class Stroker extends LineSink {
return ncoords/2;
}
- private static final long ROUND_JOIN_THRESHOLD = 1000L;
- private static final long ROUND_JOIN_INTERNAL_THRESHOLD = 1000000000L;
+ // pisces used to use fixed point arithmetic with 16 decimal digits. I
+ // didn't want to change the values of the constants below when I converted
+ // it to floating point, so that's why the divisions by 2^16 are there.
+ private static final float ROUND_JOIN_THRESHOLD = 1000/65536f;
+ private static final float ROUND_JOIN_INTERNAL_THRESHOLD = 1000000000/65536f;
- private void drawRoundJoin(int x, int y,
- int omx, int omy, int mx, int my,
+ private void drawRoundJoin(float x, float y,
+ float omx, float omy, float mx, float my,
int side,
boolean flip,
boolean rev,
- long threshold) {
+ float threshold) {
if ((omx == 0 && omy == 0) || (mx == 0 && my == 0)) {
return;
}
- long domx = (long)omx - mx;
- long domy = (long)omy - my;
- long len = domx*domx + domy*domy;
+ float domx = omx - mx;
+ float domy = omy - my;
+ float len = domx*domx + domy*domy;
if (len < threshold) {
return;
}
@@ -389,10 +315,10 @@ public class Stroker extends LineSink {
my = -my;
}
- int bx0 = x + omx;
- int by0 = y + omy;
- int bx1 = x + mx;
- int by1 = y + my;
+ float bx0 = x + omx;
+ float by0 = y + omy;
+ float bx1 = x + mx;
+ float by1 = y + my;
int npoints = computeRoundJoin(x, y,
bx0, by0, bx1, by1, side, flip,
@@ -404,40 +330,30 @@ public class Stroker extends LineSink {
// Return the intersection point of the lines (ix0, iy0) -> (ix1, iy1)
// and (ix0p, iy0p) -> (ix1p, iy1p) in m[0] and m[1]
- private void computeMiter(int ix0, int iy0, int ix1, int iy1,
- int ix0p, int iy0p, int ix1p, int iy1p,
- int[] m) {
- long x0 = ix0;
- long y0 = iy0;
- long x1 = ix1;
- long y1 = iy1;
+ private void computeMiter(float x0, float y0, float x1, float y1,
+ float x0p, float y0p, float x1p, float y1p,
+ float[] m) {
+ float x10 = x1 - x0;
+ float y10 = y1 - y0;
+ float x10p = x1p - x0p;
+ float y10p = y1p - y0p;
- long x0p = ix0p;
- long y0p = iy0p;
- long x1p = ix1p;
- long y1p = iy1p;
-
- long x10 = x1 - x0;
- long y10 = y1 - y0;
- long x10p = x1p - x0p;
- long y10p = y1p - y0p;
-
- long den = (x10*y10p - x10p*y10) >> 16;
+ float den = x10*y10p - x10p*y10;
if (den == 0) {
- m[0] = ix0;
- m[1] = iy0;
+ m[0] = x0;
+ m[1] = y0;
return;
}
- long t = (x1p*(y0 - y0p) - x0*y10p + x0p*(y1p - y0)) >> 16;
- m[0] = (int)(x0 + (t*x10)/den);
- m[1] = (int)(y0 + (t*y10)/den);
+ float t = x1p*(y0 - y0p) - x0*y10p + x0p*(y1p - y0);
+ m[0] = x0 + (t*x10)/den;
+ m[1] = y0 + (t*y10)/den;
}
- private void drawMiter(int px0, int py0,
- int x0, int y0,
- int x1, int y1,
- int omx, int omy, int mx, int my,
+ private void drawMiter(float px0, float py0,
+ float x0, float y0,
+ float x1, float y1,
+ float omx, float omy, float mx, float my,
boolean rev) {
if (mx == omx && my == omy) {
return;
@@ -461,11 +377,11 @@ public class Stroker extends LineSink {
miter);
// Compute miter length in untransformed coordinates
- long dx = (long)miter[0] - x0;
- long dy = (long)miter[1] - y0;
- long a = (dy*m00 - dx*m10) >> 16;
- long b = (dy*m01 - dx*m11) >> 16;
- long lenSq = a*a + b*b;
+ float dx = miter[0] - x0;
+ float dy = miter[1] - y0;
+ float a = dy*m00 - dx*m10;
+ float b = dy*m01 - dx*m11;
+ float lenSq = a*a + b*b;
if (lenSq < miterLimitSq) {
emitLineTo(miter[0], miter[1], rev);
@@ -473,7 +389,7 @@ public class Stroker extends LineSink {
}
- public void moveTo(int x0, int y0) {
+ public void moveTo(float x0, float y0) {
// System.out.println("Stroker.moveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
if (lineToOrigin) {
@@ -501,7 +417,7 @@ public class Stroker extends LineSink {
this.joinSegment = true;
}
- public void lineTo(int x1, int y1) {
+ public void lineTo(float x1, float y1) {
// System.out.println("Stroker.lineTo(" + x1/65536.0 + ", " + y1/65536.0 + ")");
if (lineToOrigin) {
@@ -526,10 +442,10 @@ public class Stroker extends LineSink {
joinSegment = false;
}
- private void lineToImpl(int x1, int y1, boolean joinSegment) {
+ private void lineToImpl(float x1, float y1, boolean joinSegment) {
computeOffset(x0, y0, x1, y1, offset);
- int mx = offset[0];
- int my = offset[1];
+ float mx = offset[0];
+ float my = offset[1];
if (!started) {
emitMoveTo(x0 + mx, y0 + my);
@@ -567,10 +483,6 @@ public class Stroker extends LineSink {
emitLineTo(x0 - mx, y0 - my, true);
emitLineTo(x1 - mx, y1 - my, true);
- lx0 = x1 + mx; ly0 = y1 + my;
- lx0p = x1 - mx; ly0p = y1 - my;
- lx1 = x1; ly1 = y1;
-
this.omx = mx;
this.omy = my;
this.px0 = x0;
@@ -594,8 +506,8 @@ public class Stroker extends LineSink {
}
computeOffset(x0, y0, sx0, sy0, offset);
- int mx = offset[0];
- int my = offset[1];
+ float mx = offset[0];
+ float my = offset[1];
// Draw penultimate join
boolean ccw = isCCW(px0, py0, x0, y0, sx0, sy0);
@@ -678,12 +590,10 @@ public class Stroker extends LineSink {
this.prev = MOVE_TO;
}
- long lineLength(long ldx, long ldy) {
- long ldet = ((long)m00*m11 - (long)m01*m10) >> 16;
- long la = ((long)ldy*m00 - (long)ldx*m10)/ldet;
- long lb = ((long)ldy*m01 - (long)ldx*m11)/ldet;
- long llen = (int)PiscesMath.hypot(la, lb);
- return llen;
+ double userSpaceLineLength(double dx, double dy) {
+ double a = (dy*m00 - dx*m10)/det;
+ double b = (dy*m01 - dx*m11)/det;
+ return Math.hypot(a, b);
}
private void finish() {
@@ -692,13 +602,13 @@ public class Stroker extends LineSink {
omx, omy, -omx, -omy, 1, false, false,
ROUND_JOIN_THRESHOLD);
} else if (capStyle == CAP_SQUARE) {
- long ldx = (long)(px0 - x0);
- long ldy = (long)(py0 - y0);
- long llen = lineLength(ldx, ldy);
- long s = (long)lineWidth2*65536/llen;
+ float dx = px0 - x0;
+ float dy = py0 - y0;
+ float len = (float)userSpaceLineLength(dx, dy);
+ float s = lineWidth2/len;
- int capx = x0 - (int)(ldx*s >> 16);
- int capy = y0 - (int)(ldy*s >> 16);
+ float capx = x0 - dx*s;
+ float capy = y0 - dy*s;
emitLineTo(capx + omx, capy + omy);
emitLineTo(capx - omx, capy - omy);
@@ -714,13 +624,13 @@ public class Stroker extends LineSink {
-mx0, -my0, mx0, my0, 1, false, false,
ROUND_JOIN_THRESHOLD);
} else if (capStyle == CAP_SQUARE) {
- long ldx = (long)(sx1 - sx0);
- long ldy = (long)(sy1 - sy0);
- long llen = lineLength(ldx, ldy);
- long s = (long)lineWidth2*65536/llen;
+ float dx = sx1 - sx0;
+ float dy = sy1 - sy0;
+ float len = (float)userSpaceLineLength(dx, dy);
+ float s = lineWidth2/len;
- int capx = sx0 - (int)(ldx*s >> 16);
- int capy = sy0 - (int)(ldy*s >> 16);
+ float capx = sx0 - dx*s;
+ float capy = sy0 - dy*s;
emitLineTo(capx - mx0, capy - my0);
emitLineTo(capx + mx0, capy + my0);
@@ -730,17 +640,17 @@ public class Stroker extends LineSink {
this.joinSegment = false;
}
- private void emitMoveTo(int x0, int y0) {
+ private void emitMoveTo(float x0, float y0) {
// System.out.println("Stroker.emitMoveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
output.moveTo(x0, y0);
}
- private void emitLineTo(int x1, int y1) {
+ private void emitLineTo(float x1, float y1) {
// System.out.println("Stroker.emitLineTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
output.lineTo(x1, y1);
}
- private void emitLineTo(int x1, int y1, boolean rev) {
+ private void emitLineTo(float x1, float y1, boolean rev) {
if (rev) {
ensureCapacity(rindex + 2);
reverse[rindex++] = x1;
@@ -755,3 +665,4 @@ public class Stroker extends LineSink {
output.close();
}
}
+
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Transform4.java b/jdk/src/share/classes/sun/java2d/pisces/Transform4.java
deleted file mode 100644
index bd79b762dba..00000000000
--- a/jdk/src/share/classes/sun/java2d/pisces/Transform4.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.java2d.pisces;
-
-public class Transform4 {
-
- public int m00, m01, m10, m11;
-// double det; // det*65536
-
- public Transform4() {
- this(1 << 16, 0, 0, 1 << 16);
- }
-
- public Transform4(int m00, int m01,
- int m10, int m11) {
- this.m00 = m00;
- this.m01 = m01;
- this.m10 = m10;
- this.m11 = m11;
-
-// this.det = (double)m00*m11 - (double)m01*m10;
- }
-
-// public Transform4 createInverse() {
-// double dm00 = m00/65536.0;
-// double dm01 = m01/65536.0;
-// double dm10 = m10/65536.0;
-// double dm11 = m11/65536.0;
-
-// double invdet = 65536.0/(dm00*dm11 - dm01*dm10);
-
-// int im00 = (int)( dm11*invdet);
-// int im01 = (int)(-dm01*invdet);
-// int im10 = (int)(-dm10*invdet);
-// int im11 = (int)( dm00*invdet);
-
-// return new Transform4(im00, im01, im10, im11);
-// }
-
-// public void transform(int[] point) {
-// }
-
-// /**
-// * Returns the length of the line segment obtained by inverse
-// * transforming the points (x0, y0)
and (x1,
-// * y1)
.
-// */
-// public int getTransformedLength(int x0, int x1, int y0, int y1) {
-// int lx = x1 - x0;
-// int ly = y1 - y0;
-
-// double a = (double)m00*ly - (double)m10*lx;
-// double b = (double)m01*ly - (double)m11*lx;
-// double len = PiscesMath.sqrt((a*a + b*b)/(det*det));
-// return (int)(len*65536.0);
-// }
-
-// public int getType() {
-// }
-
-}
diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/Units.java b/jdk/src/share/classes/sun/jvmstat/monitor/Units.java
index 5e632196df3..906888f9ea8 100644
--- a/jdk/src/share/classes/sun/jvmstat/monitor/Units.java
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/Units.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.jvmstat.monitor;
diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java b/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java
index 1323226d4a5..2d5ff01fc99 100644
--- a/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.jvmstat.monitor;
diff --git a/jdk/src/share/classes/sun/net/www/protocol/file/FileURLConnection.java b/jdk/src/share/classes/sun/net/www/protocol/file/FileURLConnection.java
index 3298546e7b5..787282b823d 100644
--- a/jdk/src/share/classes/sun/net/www/protocol/file/FileURLConnection.java
+++ b/jdk/src/share/classes/sun/net/www/protocol/file/FileURLConnection.java
@@ -59,7 +59,7 @@ public class FileURLConnection extends URLConnection {
String filename;
boolean isDirectory = false;
boolean exists = false;
- List files;
+ List files;
long length = -1;
long lastModified = 0;
@@ -81,7 +81,10 @@ public class FileURLConnection extends URLConnection {
filename = file.toString();
isDirectory = file.isDirectory();
if (isDirectory) {
- files = (List) Arrays.asList(file.list());
+ String[] fileList = file.list();
+ if (fileList == null)
+ throw new FileNotFoundException(filename + " exists, but is not accessible");
+ files = Arrays.asList(fileList);
} else {
is = new BufferedInputStream(new FileInputStream(filename));
@@ -197,7 +200,7 @@ public class FileURLConnection extends URLConnection {
Collections.sort(files, Collator.getInstance());
for (int i = 0 ; i < files.size() ; i++) {
- String fileName = (String)files.get(i);
+ String fileName = files.get(i);
buf.append(fileName);
buf.append("\n");
}
diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
index 713c7d85c21..e888abe26e8 100644
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
@@ -1768,6 +1768,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Not really necessary for a tunnel, but can't hurt
requests.setIfNotSet("Accept", acceptString);
+ if (http.getHttpKeepAliveSet()) {
+ requests.setIfNotSet("Proxy-Connection", "keep-alive");
+ }
+
setPreemptiveProxyAuthentication(requests);
/* Log the CONNECT request */
diff --git a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
index 41b37c9e960..1d7d6758d8e 100644
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -536,9 +536,11 @@ class DatagramChannelImpl
}
}
- private long read0(ByteBuffer[] bufs) throws IOException {
- if (bufs == null)
- throw new NullPointerException();
+ public long read(ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
+ throw new IndexOutOfBoundsException();
synchronized (readLock) {
synchronized (stateLock) {
ensureOpen();
@@ -552,7 +554,7 @@ class DatagramChannelImpl
return 0;
readerThread = NativeThread.current();
do {
- n = IOUtil.read(fd, bufs, nd);
+ n = IOUtil.read(fd, dsts, offset, length, nd);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
return IOStatus.normalize(n);
} finally {
@@ -563,15 +565,6 @@ class DatagramChannelImpl
}
}
- public long read(ByteBuffer[] dsts, int offset, int length)
- throws IOException
- {
- if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
- throw new IndexOutOfBoundsException();
- // ## Fix IOUtil.write so that we can avoid this array copy
- return read0(Util.subsequence(dsts, offset, length));
- }
-
public int write(ByteBuffer buf) throws IOException {
if (buf == null)
throw new NullPointerException();
@@ -599,9 +592,11 @@ class DatagramChannelImpl
}
}
- private long write0(ByteBuffer[] bufs) throws IOException {
- if (bufs == null)
- throw new NullPointerException();
+ public long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
+ throw new IndexOutOfBoundsException();
synchronized (writeLock) {
synchronized (stateLock) {
ensureOpen();
@@ -615,7 +610,7 @@ class DatagramChannelImpl
return 0;
writerThread = NativeThread.current();
do {
- n = IOUtil.write(fd, bufs, nd);
+ n = IOUtil.write(fd, srcs, offset, length, nd);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
return IOStatus.normalize(n);
} finally {
@@ -626,15 +621,6 @@ class DatagramChannelImpl
}
}
- public long write(ByteBuffer[] srcs, int offset, int length)
- throws IOException
- {
- if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
- throw new IndexOutOfBoundsException();
- // ## Fix IOUtil.write so that we can avoid this array copy
- return write0(Util.subsequence(srcs, offset, length));
- }
-
protected void implConfigureBlocking(boolean block) throws IOException {
IOUtil.configureBlocking(fd, block);
}
diff --git a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java
index 1bbd5e025ef..9a52fa4555c 100644
--- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java
+++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java
@@ -143,7 +143,11 @@ public class FileChannelImpl
}
}
- private long read0(ByteBuffer[] dsts) throws IOException {
+ public long read(ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
+ throw new IndexOutOfBoundsException();
ensureOpen();
if (!readable)
throw new NonReadableChannelException();
@@ -156,7 +160,7 @@ public class FileChannelImpl
if (!isOpen())
return 0;
do {
- n = IOUtil.read(fd, dsts, nd);
+ n = IOUtil.read(fd, dsts, offset, length, nd);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
return IOStatus.normalize(n);
} finally {
@@ -167,15 +171,6 @@ public class FileChannelImpl
}
}
- public long read(ByteBuffer[] dsts, int offset, int length)
- throws IOException
- {
- if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
- throw new IndexOutOfBoundsException();
- // ## Fix IOUtil.write so that we can avoid this array copy
- return read0(Util.subsequence(dsts, offset, length));
- }
-
public int write(ByteBuffer src) throws IOException {
ensureOpen();
if (!writable)
@@ -200,7 +195,11 @@ public class FileChannelImpl
}
}
- private long write0(ByteBuffer[] srcs) throws IOException {
+ public long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
+ throw new IndexOutOfBoundsException();
ensureOpen();
if (!writable)
throw new NonWritableChannelException();
@@ -213,7 +212,7 @@ public class FileChannelImpl
if (!isOpen())
return 0;
do {
- n = IOUtil.write(fd, srcs, nd);
+ n = IOUtil.write(fd, srcs, offset, length, nd);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
return IOStatus.normalize(n);
} finally {
@@ -224,16 +223,6 @@ public class FileChannelImpl
}
}
- public long write(ByteBuffer[] srcs, int offset, int length)
- throws IOException
- {
- if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
- throw new IndexOutOfBoundsException();
- // ## Fix IOUtil.write so that we can avoid this array copy
- return write0(Util.subsequence(srcs, offset, length));
- }
-
-
// -- Other operations --
public long position() throws IOException {
@@ -440,24 +429,45 @@ public class FileChannelImpl
}
}
- private long transferToTrustedChannel(long position, int icount,
+ // Maximum size to map when using a mapped buffer
+ private static final long MAPPED_TRANSFER_SIZE = 8L*1024L*1024L;
+
+ private long transferToTrustedChannel(long position, long count,
WritableByteChannel target)
throws IOException
{
- if ( !((target instanceof FileChannelImpl)
- || (target instanceof SelChImpl)))
+ boolean isSelChImpl = (target instanceof SelChImpl);
+ if (!((target instanceof FileChannelImpl) || isSelChImpl))
return IOStatus.UNSUPPORTED;
// Trusted target: Use a mapped buffer
- MappedByteBuffer dbb = null;
- try {
- dbb = map(MapMode.READ_ONLY, position, icount);
- // ## Bug: Closing this channel will not terminate the write
- return target.write(dbb);
- } finally {
- if (dbb != null)
- unmap(dbb);
+ long remaining = count;
+ while (remaining > 0L) {
+ long size = Math.min(remaining, MAPPED_TRANSFER_SIZE);
+ try {
+ MappedByteBuffer dbb = map(MapMode.READ_ONLY, position, size);
+ try {
+ // ## Bug: Closing this channel will not terminate the write
+ int n = target.write(dbb);
+ assert n >= 0;
+ remaining -= n;
+ if (isSelChImpl) {
+ // one attempt to write to selectable channel
+ break;
+ }
+ assert n > 0;
+ position += n;
+ } finally {
+ unmap(dbb);
+ }
+ } catch (IOException ioe) {
+ // Only throw exception if no bytes have been written
+ if (remaining == count)
+ throw ioe;
+ break;
+ }
}
+ return count - remaining;
}
private long transferToArbitraryChannel(long position, int icount,
@@ -535,20 +545,34 @@ public class FileChannelImpl
long position, long count)
throws IOException
{
- // Note we could loop here to accumulate more at once
synchronized (src.positionLock) {
- long p = src.position();
- int icount = (int)Math.min(Math.min(count, Integer.MAX_VALUE),
- src.size() - p);
- // ## Bug: Closing this channel will not terminate the write
- MappedByteBuffer bb = src.map(MapMode.READ_ONLY, p, icount);
- try {
- long n = write(bb, position);
- src.position(p + n);
- return n;
- } finally {
- unmap(bb);
+ long pos = src.position();
+ long max = Math.min(count, src.size() - pos);
+
+ long remaining = max;
+ long p = pos;
+ while (remaining > 0L) {
+ long size = Math.min(remaining, MAPPED_TRANSFER_SIZE);
+ // ## Bug: Closing this channel will not terminate the write
+ MappedByteBuffer bb = src.map(MapMode.READ_ONLY, p, size);
+ try {
+ long n = write(bb, position);
+ assert n > 0;
+ p += n;
+ position += n;
+ remaining -= n;
+ } catch (IOException ioe) {
+ // Only throw exception if no bytes have been written
+ if (remaining == max)
+ throw ioe;
+ break;
+ } finally {
+ unmap(bb);
+ }
}
+ long nwritten = max - remaining;
+ src.position(pos + nwritten);
+ return nwritten;
}
}
diff --git a/jdk/src/share/classes/sun/nio/ch/IOUtil.java b/jdk/src/share/classes/sun/nio/ch/IOUtil.java
index 5b1dd95cddc..86acff63566 100644
--- a/jdk/src/share/classes/sun/nio/ch/IOUtil.java
+++ b/jdk/src/share/classes/sun/nio/ch/IOUtil.java
@@ -38,34 +38,6 @@ class IOUtil {
private IOUtil() { } // No instantiation
- /*
- * Returns the index of first buffer in bufs with remaining,
- * or -1 if there is nothing left
- */
- private static int remaining(ByteBuffer[] bufs) {
- int numBufs = bufs.length;
- for (int i=0; i 0)
- bufs = skipBufs(bufs, nextWithRemaining);
+ return write(fd, bufs, 0, bufs.length, nd);
+ }
- int numBufs = bufs.length;
+ static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length,
+ NativeDispatcher nd)
+ throws IOException
+ {
+ IOVecWrapper vec = IOVecWrapper.get(length);
- // Create shadow to ensure DirectByteBuffers are used
- ByteBuffer[] shadow = new ByteBuffer[numBufs];
+ boolean completed = false;
+ int iov_len = 0;
try {
- for (int i=0; i 0) {
+ vec.setBuffer(iov_len, buf, pos, rem);
+
+ // allocate shadow buffer to ensure I/O is done with direct buffer
+ if (!(buf instanceof DirectBuffer)) {
+ ByteBuffer shadow = Util.getTemporaryDirectBuffer(rem);
+ shadow.put(buf);
+ shadow.flip();
+ vec.setShadow(iov_len, shadow);
+ buf.position(pos); // temporarily restore position in user buffer
+ buf = shadow;
+ pos = shadow.position();
+ }
+
+ vec.putBase(iov_len, ((DirectBuffer)buf).address() + pos);
+ vec.putLen(iov_len, rem);
+ iov_len++;
}
}
+ if (iov_len == 0)
+ return 0L;
- IOVecWrapper vec = null;
- long bytesWritten = 0;
- try {
- // Create a native iovec array
- vec= new IOVecWrapper(numBufs);
-
- // Fill in the iovec array with appropriate data
- for (int i=0; i= len) {
- bytesWritten -= len;
- int newPosition = pos + len;
- nextBuffer.position(newPosition);
- } else { // Buffers not completely filled
- if (bytesWritten > 0) {
- assert(pos + bytesWritten < (long)Integer.MAX_VALUE);
- int newPosition = (int)(pos + bytesWritten);
- nextBuffer.position(newPosition);
- }
- break;
+ long left = bytesWritten;
+ for (int j=0; j 0) {
+ ByteBuffer buf = vec.getBuffer(j);
+ int pos = vec.getPosition(j);
+ int rem = vec.getRemaining(j);
+ int n = (left > rem) ? rem : (int)left;
+ buf.position(pos + n);
+ left -= n;
}
+ // return shadow buffers to buffer pool
+ ByteBuffer shadow = vec.getShadow(j);
+ if (shadow != null)
+ Util.offerLastTemporaryDirectBuffer(shadow);
+ vec.clearRefs(j);
}
- return returnVal;
+
+ completed = true;
+ return bytesWritten;
+
} finally {
- // return any substituted buffers to cache
- for (int i=0; i 0)
- bufs = skipBufs(bufs, nextWithRemaining);
+ return read(fd, bufs, 0, bufs.length, nd);
+ }
- int numBufs = bufs.length;
+ static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length,
+ NativeDispatcher nd)
+ throws IOException
+ {
+ IOVecWrapper vec = IOVecWrapper.get(length);
- // Read into the shadow to ensure DirectByteBuffers are used
- ByteBuffer[] shadow = new ByteBuffer[numBufs];
- boolean usingSlowBuffers = false;
+ boolean completed = false;
+ int iov_len = 0;
try {
- for (int i=0; i 0) {
+ vec.setBuffer(iov_len, buf, pos, rem);
+
+ // allocate shadow buffer to ensure I/O is done with direct buffer
+ if (!(buf instanceof DirectBuffer)) {
+ ByteBuffer shadow = Util.getTemporaryDirectBuffer(rem);
+ vec.setShadow(iov_len, shadow);
+ buf = shadow;
+ pos = shadow.position();
+ }
+
+ vec.putBase(iov_len, ((DirectBuffer)buf).address() + pos);
+ vec.putLen(iov_len, rem);
+ iov_len++;
}
}
+ if (iov_len == 0)
+ return 0L;
- IOVecWrapper vec = null;
- long bytesRead = 0;
- try {
- // Create a native iovec array
- vec = new IOVecWrapper(numBufs);
-
- // Fill in the iovec array with appropriate data
- for (int i=0; i= len) {
- bytesRead -= len;
- int newPosition = pos + len;
- nextBuffer.position(newPosition);
- } else { // Buffers not completely filled
- if (bytesRead > 0) {
- assert(pos + bytesRead < (long)Integer.MAX_VALUE);
- int newPosition = (int)(pos + bytesRead);
- nextBuffer.position(newPosition);
+ long left = bytesRead;
+ for (int j=0; j 0) {
+ ByteBuffer buf = vec.getBuffer(j);
+ int rem = vec.getRemaining(j);
+ int n = (left > rem) ? rem : (int)left;
+ if (shadow == null) {
+ int pos = vec.getPosition(j);
+ buf.position(pos + n);
+ } else {
+ shadow.limit(shadow.position() + n);
+ buf.put(shadow);
}
- break;
+ left -= n;
}
+ if (shadow != null)
+ Util.offerLastTemporaryDirectBuffer(shadow);
+ vec.clearRefs(j);
}
- // Put results from shadow into the slow buffers
- if (usingSlowBuffers) {
- for (int i=0; i cached =
+ new ThreadLocal();
+
+ private IOVecWrapper(int size) {
+ this.size = size;
+ this.buf = new ByteBuffer[size];
+ this.position = new int[size];
+ this.remaining = new int[size];
+ this.shadow = new ByteBuffer[size];
+ this.vecArray = new AllocatedNativeObject(size * SIZE_IOVEC, false);
+ this.address = vecArray.address();
+ }
+
+ static IOVecWrapper get(int size) {
+ IOVecWrapper wrapper = cached.get();
+ if (wrapper != null && wrapper.size < size) {
+ // not big enough; eagerly release memory
+ wrapper.vecArray.free();
+ wrapper = null;
+ }
+ if (wrapper == null) {
+ wrapper = new IOVecWrapper(size);
+ Cleaner.create(wrapper, new Deallocator(wrapper.vecArray));
+ cached.set(wrapper);
+ }
+ return wrapper;
+ }
+
+ void setBuffer(int i, ByteBuffer buf, int pos, int rem) {
+ this.buf[i] = buf;
+ this.position[i] = pos;
+ this.remaining[i] = rem;
+ }
+
+ void setShadow(int i, ByteBuffer buf) {
+ shadow[i] = buf;
+ }
+
+ ByteBuffer getBuffer(int i) {
+ return buf[i];
+ }
+
+ int getPosition(int i) {
+ return position[i];
+ }
+
+ int getRemaining(int i) {
+ return remaining[i];
+ }
+
+ ByteBuffer getShadow(int i) {
+ return shadow[i];
+ }
+
+ void clearRefs(int i) {
+ buf[i] = null;
+ shadow[i] = null;
}
void putBase(int i, long base) {
@@ -78,10 +154,6 @@ class IOVecWrapper {
vecArray.putLong(offset, len);
}
- void free() {
- vecArray.free();
- }
-
static {
addressSize = Util.unsafe().addressSize();
LEN_OFFSET = addressSize;
diff --git a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
index ee84a0e626c..7d42d7d0096 100644
--- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
+++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
@@ -385,9 +385,11 @@ class SocketChannelImpl
}
}
- private long read0(ByteBuffer[] bufs) throws IOException {
- if (bufs == null)
- throw new NullPointerException();
+ public long read(ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
+ throw new IndexOutOfBoundsException();
synchronized (readLock) {
if (!ensureReadOpen())
return -1;
@@ -401,7 +403,7 @@ class SocketChannelImpl
}
for (;;) {
- n = IOUtil.read(fd, bufs, nd);
+ n = IOUtil.read(fd, dsts, offset, length, nd);
if ((n == IOStatus.INTERRUPTED) && isOpen())
continue;
return IOStatus.normalize(n);
@@ -418,15 +420,6 @@ class SocketChannelImpl
}
}
- public long read(ByteBuffer[] dsts, int offset, int length)
- throws IOException
- {
- if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
- throw new IndexOutOfBoundsException();
- // ## Fix IOUtil.write so that we can avoid this array copy
- return read0(Util.subsequence(dsts, offset, length));
- }
-
public int write(ByteBuffer buf) throws IOException {
if (buf == null)
throw new NullPointerException();
@@ -458,9 +451,11 @@ class SocketChannelImpl
}
}
- public long write0(ByteBuffer[] bufs) throws IOException {
- if (bufs == null)
- throw new NullPointerException();
+ public long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
+ throw new IndexOutOfBoundsException();
synchronized (writeLock) {
ensureWriteOpen();
long n = 0;
@@ -472,7 +467,7 @@ class SocketChannelImpl
writerThread = NativeThread.current();
}
for (;;) {
- n = IOUtil.write(fd, bufs, nd);
+ n = IOUtil.write(fd, srcs, offset, length, nd);
if ((n == IOStatus.INTERRUPTED) && isOpen())
continue;
return IOStatus.normalize(n);
@@ -489,15 +484,6 @@ class SocketChannelImpl
}
}
- public long write(ByteBuffer[] srcs, int offset, int length)
- throws IOException
- {
- if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
- throw new IndexOutOfBoundsException();
- // ## Fix IOUtil.write so that we can avoid this array copy
- return write0(Util.subsequence(srcs, offset, length));
- }
-
// package-private
int sendOutOfBandData(byte b) throws IOException {
synchronized (writeLock) {
diff --git a/jdk/src/share/classes/sun/nio/ch/Util.java b/jdk/src/share/classes/sun/nio/ch/Util.java
index b17801cbed7..50d280865cd 100644
--- a/jdk/src/share/classes/sun/nio/ch/Util.java
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java
@@ -41,67 +41,180 @@ import sun.security.action.GetPropertyAction;
class Util {
-
// -- Caches --
// The number of temp buffers in our pool
- private static final int TEMP_BUF_POOL_SIZE = 3;
+ private static final int TEMP_BUF_POOL_SIZE = 8;
- // Per-thread soft cache of the last temporary direct buffer
- private static ThreadLocal>[] bufferPool;
+ // Per-thread cache of temporary direct buffers
+ private static ThreadLocal bufferCache =
+ new ThreadLocal()
+ {
+ @Override
+ protected BufferCache initialValue() {
+ return new BufferCache();
+ }
+ };
- @SuppressWarnings("unchecked")
- static ThreadLocal>[] createThreadLocalBufferPool() {
- return new ThreadLocal[TEMP_BUF_POOL_SIZE];
- }
-
- static {
- bufferPool = createThreadLocalBufferPool();
- for (int i=0; i>();
+ /**
+ * A simple cache of direct buffers.
+ */
+ private static class BufferCache {
+ // the array of buffers
+ private ByteBuffer[] buffers;
+
+ // the number of buffers in the cache
+ private int count;
+
+ // the index of the first valid buffer (undefined if count == 0)
+ private int start;
+
+ private int next(int i) {
+ return (i + 1) % TEMP_BUF_POOL_SIZE;
+ }
+
+ BufferCache() {
+ buffers = new ByteBuffer[TEMP_BUF_POOL_SIZE];
+ }
+
+ /**
+ * Removes and returns a buffer from the cache of at least the given
+ * size (or null if no suitable buffer is found).
+ */
+ ByteBuffer get(int size) {
+ if (count == 0)
+ return null; // cache is empty
+
+ ByteBuffer[] buffers = this.buffers;
+
+ // search for suitable buffer (often the first buffer will do)
+ ByteBuffer buf = buffers[start];
+ if (buf.capacity() < size) {
+ buf = null;
+ int i = start;
+ while ((i = next(i)) != start) {
+ ByteBuffer bb = buffers[i];
+ if (bb == null)
+ break;
+ if (bb.capacity() >= size) {
+ buf = bb;
+ break;
+ }
+ }
+ if (buf == null)
+ return null;
+ // move first element to here to avoid re-packing
+ buffers[i] = buffers[start];
+ }
+
+ // remove first element
+ buffers[start] = null;
+ start = next(start);
+ count--;
+
+ // prepare the buffer and return it
+ buf.rewind();
+ buf.limit(size);
+ return buf;
+ }
+
+ boolean offerFirst(ByteBuffer buf) {
+ if (count >= TEMP_BUF_POOL_SIZE) {
+ return false;
+ } else {
+ start = (start + TEMP_BUF_POOL_SIZE - 1) % TEMP_BUF_POOL_SIZE;
+ buffers[start] = buf;
+ count++;
+ return true;
+ }
+ }
+
+ boolean offerLast(ByteBuffer buf) {
+ if (count >= TEMP_BUF_POOL_SIZE) {
+ return false;
+ } else {
+ int next = (start + count) % TEMP_BUF_POOL_SIZE;
+ buffers[next] = buf;
+ count++;
+ return true;
+ }
+ }
+
+ boolean isEmpty() {
+ return count == 0;
+ }
+
+ ByteBuffer removeFirst() {
+ assert count > 0;
+ ByteBuffer buf = buffers[start];
+ buffers[start] = null;
+ start = next(start);
+ count--;
+ return buf;
+ }
}
+ /**
+ * Returns a temporary buffer of at least the given size
+ */
static ByteBuffer getTemporaryDirectBuffer(int size) {
- ByteBuffer buf = null;
- // Grab a buffer if available
- for (int i=0; i ref = bufferPool[i].get();
- if ((ref != null) && ((buf = ref.get()) != null) &&
- (buf.capacity() >= size)) {
- buf.rewind();
- buf.limit(size);
- bufferPool[i].set(null);
- return buf;
+ BufferCache cache = bufferCache.get();
+ ByteBuffer buf = cache.get(size);
+ if (buf != null) {
+ return buf;
+ } else {
+ // No suitable buffer in the cache so we need to allocate a new
+ // one. To avoid the cache growing then we remove the first
+ // buffer from the cache and free it.
+ if (!cache.isEmpty()) {
+ buf = cache.removeFirst();
+ free(buf);
}
+ return ByteBuffer.allocateDirect(size);
}
-
- // Make a new one
- return ByteBuffer.allocateDirect(size);
}
+ /**
+ * Releases a temporary buffer by returning to the cache or freeing it.
+ */
static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
- if (buf == null)
- return;
- // Put it in an empty slot if such exists
- for (int i=0; i ref = bufferPool[i].get();
- if ((ref == null) || (ref.get() == null)) {
- bufferPool[i].set(new SoftReference(buf));
- return;
- }
- }
- // Otherwise replace a smaller one in the cache if such exists
- for (int i=0; i ref = bufferPool[i].get();
- ByteBuffer inCacheBuf = ref.get();
- if ((inCacheBuf == null) || (buf.capacity() > inCacheBuf.capacity())) {
- bufferPool[i].set(new SoftReference(buf));
- return;
- }
- }
+ offerFirstTemporaryDirectBuffer(buf);
+ }
- // release memory
- ((DirectBuffer)buf).cleaner().clean();
+ /**
+ * Releases a temporary buffer by returning to the cache or freeing it. If
+ * returning to the cache then insert it at the start so that it is
+ * likely to be returned by a subsequent call to getTemporaryDirectBuffer.
+ */
+ static void offerFirstTemporaryDirectBuffer(ByteBuffer buf) {
+ assert buf != null;
+ BufferCache cache = bufferCache.get();
+ if (!cache.offerFirst(buf)) {
+ // cache is full
+ free(buf);
+ }
+ }
+
+ /**
+ * Releases a temporary buffer by returning to the cache or freeing it. If
+ * returning to the cache then insert it at the end. This makes it
+ * suitable for scatter/gather operations where the buffers are returned to
+ * cache in same order that they were obtained.
+ */
+ static void offerLastTemporaryDirectBuffer(ByteBuffer buf) {
+ assert buf != null;
+ BufferCache cache = bufferCache.get();
+ if (!cache.offerLast(buf)) {
+ // cache is full
+ free(buf);
+ }
+ }
+
+ /**
+ * Frees the memory for the given direct buffer
+ */
+ private static void free(ByteBuffer buf) {
+ ((DirectBuffer)buf).cleaner().clean();
}
private static class SelectorWrapper {
diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java b/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
index c9e8ac07c63..e642b268032 100644
--- a/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
+++ b/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
@@ -447,7 +447,9 @@ public class JConsoleResources extends ListResourceBundle {
String ls = System.getProperty("line.separator");
for(int i=0;i (int)sizeof(buffer_space)) {
buffer = malloc(length + 1);
check_and_push(context, buffer, VM_MALLOC_BLK);
diff --git a/jdk/src/solaris/classes/java/io/UnixFileSystem.java b/jdk/src/solaris/classes/java/io/UnixFileSystem.java
index df070bd0039..2c0feb2d5ef 100644
--- a/jdk/src/solaris/classes/java/io/UnixFileSystem.java
+++ b/jdk/src/solaris/classes/java/io/UnixFileSystem.java
@@ -187,7 +187,6 @@ class UnixFileSystem extends FileSystem {
}
}
}
- assert canonicalize0(path).equals(res) || path.startsWith(javaHome);
return res;
}
}
diff --git a/jdk/src/solaris/classes/sun/font/XRGlyphCache.java b/jdk/src/solaris/classes/sun/font/XRGlyphCache.java
index 82c7c6a87d7..9e767242b9f 100644
--- a/jdk/src/solaris/classes/sun/font/XRGlyphCache.java
+++ b/jdk/src/solaris/classes/sun/font/XRGlyphCache.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.font;
diff --git a/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java b/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
index e7f6281ca3a..3ed04017b1b 100644
--- a/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
+++ b/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.font;
diff --git a/jdk/src/solaris/classes/sun/font/XRTextRenderer.java b/jdk/src/solaris/classes/sun/font/XRTextRenderer.java
index 2787160a5b2..c2aa27b43e0 100644
--- a/jdk/src/solaris/classes/sun/font/XRTextRenderer.java
+++ b/jdk/src/solaris/classes/sun/font/XRTextRenderer.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.font;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java b/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java
index 2ea09a3086f..f7040dacde2 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java b/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java
index 218386ffe09..12af979197a 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java b/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java
index 00c9407e7e4..f53493eb25e 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java b/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java
index c65e1761a64..edbde2a9a19 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java b/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java
index 22e56d18685..e4e2d6ffcca 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java b/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java
index dc973d1d397..ec0cd8def15 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java b/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java
index 8410261f4fb..871602dfee4 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java b/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java
index 00368f00481..a1ee140ae3c 100644
--- a/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java
+++ b/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.jules;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java b/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java
index 2866055b692..bc855aa4940 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java b/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java
index a8e22fa49e7..652dbd20637 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java b/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java
index 88128614ae9..bb2070ec9d0 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java b/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java
index 12c03622cc6..a59c5d315a4 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java b/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java
index 241bff3bbc2..bdcd3bd235b 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java b/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java
index 01a8a6954f1..ee5bd62bd84 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java b/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java
index 4937b339f3f..25d110fe7d2 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java b/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java
index 535e648f45e..b7baf36ceba 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java b/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java
index c18894f879f..be5f8891be9 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java b/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java
index ffbea0eb0cd..a9e132c776f 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java b/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java
index 9589e9429af..f272efaa723 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java b/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java
index 3108b122472..a6ffd0defcd 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java b/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java
index 29200de4bf2..d1c3f6b7159 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java b/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java
index 8a6d4f65f12..b4b8c4c15e0 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java b/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java
index 6db898741a2..15f69f10523 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java b/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java
index a2c9dac2683..2e7c111593b 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java b/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java
index ed6a6412a85..978a3c4b905 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java b/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java
index 5ec6c28a477..8be84579bc5 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java b/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java
index 555adcc9ec8..7c3bb297e1a 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java b/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java
index 40536066fc8..7b5d37d95d4 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java b/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java
index 42dec990ffd..27fda71cedb 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java
index f6333e5e71b..e68d078402c 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
index 8bfbd109895..0491e719c59 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java
index 83c30656e24..091d26ee83b 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java b/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java
index 0565b89ec3d..e7e05e4f2cc 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java b/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java
index ef8c0098721..8c99f25b305 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java b/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java
index b6d407f2342..963eb98c03a 100644
--- a/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
package sun.java2d.xr;
diff --git a/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java b/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
index 75a000b7058..53a32c14a64 100644
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
@@ -1141,6 +1141,13 @@ class UnixPath
}
result = result.resolve(element);
}
+
+ // check file exists (without following links)
+ try {
+ UnixFileAttributes.get(result, false);
+ } catch (UnixException x) {
+ x.rethrowAsIOException(result);
+ }
return result;
}
diff --git a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
index e717322c6ea..48d0d8ecfa8 100644
--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
@@ -1052,30 +1052,38 @@ JNIEXPORT void JNICALL
Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
jobject this) {
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
- int fd;
-
- int t = 1;
+ int fd, t = 1;
+#ifdef AF_INET6
+ int domain = ipv6_available() ? AF_INET6 : AF_INET;
+#else
+ int domain = AF_INET;
+#endif
if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return;
- } else {
-#ifdef AF_INET6
- if (ipv6_available()) {
- fd = JVM_Socket(AF_INET6, SOCK_DGRAM, 0);
- } else
-#endif /* AF_INET6 */
- {
- fd = JVM_Socket(AF_INET, SOCK_DGRAM, 0);
- }
}
- if (fd == JVM_IO_ERR) {
+
+ if ((fd = JVM_Socket(domain, SOCK_DGRAM, 0)) == JVM_IO_ERR) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error creating socket");
return;
}
+#ifdef AF_INET6
+ /* Disable IPV6_V6ONLY to ensure dual-socket support */
+ if (domain == AF_INET6) {
+ int arg = 0;
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
+ sizeof(int)) < 0) {
+ NET_ThrowNew(env, errno, "cannot set IPPROTO_IPV6");
+ close(fd);
+ return;
+ }
+ }
+#endif /* AF_INET6 */
+
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char*) &t, sizeof(int));
#ifdef __linux__
@@ -1088,7 +1096,7 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
* On Linux for IPv6 sockets we must set the hop limit
* to 1 to be compatible with default ttl of 1 for IPv4 sockets.
*/
- if (ipv6_available()) {
+ if (domain == AF_INET6) {
int ttl = 1;
setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *)&ttl,
sizeof(ttl));
diff --git a/jdk/src/solaris/native/java/net/PlainSocketImpl.c b/jdk/src/solaris/native/java/net/PlainSocketImpl.c
index 254a1497ff6..060dacdac86 100644
--- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c
+++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c
@@ -181,6 +181,12 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
jboolean stream) {
jobject fdObj, ssObj;
int fd;
+ int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
+#ifdef AF_INET6
+ int domain = ipv6_available() ? AF_INET6 : AF_INET;
+#else
+ int domain = AF_INET;
+#endif
if (socketExceptionCls == NULL) {
jclass c = (*env)->FindClass(env, "java/net/SocketException");
@@ -194,25 +200,29 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
(*env)->ThrowNew(env, socketExceptionCls, "null fd object");
return;
}
-#ifdef AF_INET6
- if (ipv6_available()) {
- fd = JVM_Socket(AF_INET6, (stream ? SOCK_STREAM: SOCK_DGRAM), 0);
- } else
-#endif /* AF_INET6 */
- {
- fd = JVM_Socket(AF_INET, (stream ? SOCK_STREAM: SOCK_DGRAM), 0);
- }
- if (fd == JVM_IO_ERR) {
+
+ if ((fd = JVM_Socket(domain, type, 0)) == JVM_IO_ERR) {
/* note: if you run out of fds, you may not be able to load
* the exception class, and get a NoClassDefFoundError
* instead.
*/
NET_ThrowNew(env, errno, "can't create socket");
return;
- } else {
- (*env)->SetIntField(env, fdObj, IO_fd_fdID, fd);
}
+#ifdef AF_INET6
+ /* Disable IPV6_V6ONLY to ensure dual-socket support */
+ if (domain == AF_INET6) {
+ int arg = 0;
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
+ sizeof(int)) < 0) {
+ NET_ThrowNew(env, errno, "cannot set IPPROTO_IPV6");
+ close(fd);
+ return;
+ }
+ }
+#endif /* AF_INET6 */
+
/*
* If this is a server socket then enable SO_REUSEADDR
* automatically and set to non blocking.
@@ -221,9 +231,15 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
if (ssObj != NULL) {
int arg = 1;
SET_NONBLOCKING(fd);
- JVM_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
- sizeof(arg));
+ if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
+ sizeof(arg)) < 0) {
+ NET_ThrowNew(env, errno, "cannot set SO_REUSEADDR");
+ close(fd);
+ return;
+ }
}
+
+ (*env)->SetIntField(env, fdObj, IO_fd_fdID, fd);
}
/*
diff --git a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c
index 32cd20a3239..58dfb63d0ce 100644
--- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
#include "X11SurfaceData.h"
diff --git a/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c b/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
index d6d468efb03..83fbec0c336 100644
--- a/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
@@ -1,12 +1,12 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
+ * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
#include "GraphicsPrimitiveMgr.h"
diff --git a/jdk/src/solaris/native/sun/nio/ch/Net.c b/jdk/src/solaris/native/sun/nio/ch/Net.c
index e0b3d1c1152..dc3d7c4ac34 100644
--- a/jdk/src/solaris/native/sun/nio/ch/Net.c
+++ b/jdk/src/solaris/native/sun/nio/ch/Net.c
@@ -170,6 +170,22 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
if (fd < 0) {
return handleSocketError(env, errno);
}
+
+#ifdef AF_INET6
+ /* Disable IPV6_V6ONLY to ensure dual-socket support */
+ if (domain == AF_INET6) {
+ int arg = 0;
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
+ sizeof(int)) < 0) {
+ JNU_ThrowByNameWithLastError(env,
+ JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.Net.setIntOption");
+ close(fd);
+ return -1;
+ }
+ }
+#endif
+
if (reuse) {
int arg = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
diff --git a/jdk/src/windows/classes/java/io/Win32FileSystem.java b/jdk/src/windows/classes/java/io/Win32FileSystem.java
index 510b84abf62..490c411b072 100644
--- a/jdk/src/windows/classes/java/io/Win32FileSystem.java
+++ b/jdk/src/windows/classes/java/io/Win32FileSystem.java
@@ -424,7 +424,6 @@ class Win32FileSystem extends FileSystem {
}
}
}
- assert canonicalize0(path).equalsIgnoreCase(res);
return res;
}
}
diff --git a/jdk/test/com/sun/java/swing/plaf/gtk/Test6963870.java b/jdk/test/com/sun/java/swing/plaf/gtk/Test6963870.java
index b7b93cf0205..d7ca68e1120 100644
--- a/jdk/test/com/sun/java/swing/plaf/gtk/Test6963870.java
+++ b/jdk/test/com/sun/java/swing/plaf/gtk/Test6963870.java
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh
index 47367f7de82..71e07441ce2 100644
--- a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh
+++ b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh
@@ -55,7 +55,7 @@ case "$OS" in
Linux )
FS="/"
;;
- Windows* )
+ Windows* | CYGWIN* )
FS="\\"
;;
esac
diff --git a/jdk/test/java/lang/StringBuffer/Capacity.java b/jdk/test/java/lang/StringBuffer/Capacity.java
index eecb766957a..4d2bc83445a 100644
--- a/jdk/test/java/lang/StringBuffer/Capacity.java
+++ b/jdk/test/java/lang/StringBuffer/Capacity.java
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*
diff --git a/jdk/test/java/net/URI/Test.java b/jdk/test/java/net/URI/Test.java
index 449f7d1c19e..39b5b9487d1 100644
--- a/jdk/test/java/net/URI/Test.java
+++ b/jdk/test/java/net/URI/Test.java
@@ -1536,6 +1536,7 @@ public class Test {
serial();
urls();
npes();
+ bugs();
}
@@ -1572,6 +1573,19 @@ public class Test {
}
+ // miscellaneous bugs/rfes that don't fit in with the test framework
+
+ static void bugs() {
+ // 6339649 - include detail message from nested exception
+ try {
+ URI uri = URI.create("http://nowhere.net/should not be permitted");
+ } catch (IllegalArgumentException e) {
+ if ("".equals(e.getMessage()) || e.getMessage() == null) {
+ throw new RuntimeException ("No detail message");
+ }
+ }
+ }
+
public static void main(String[] args) throws Exception {
switch (args.length) {
diff --git a/jdk/test/java/nio/file/Path/Misc.java b/jdk/test/java/nio/file/Path/Misc.java
index 8b2223b2389..3b24c786261 100644
--- a/jdk/test/java/nio/file/Path/Misc.java
+++ b/jdk/test/java/nio/file/Path/Misc.java
@@ -260,6 +260,21 @@ public class Misc {
*/
assertTrue(file.toRealPath(true).isSameFile(file.toRealPath(false)));
+ /**
+ * Test: toRealPath should fail if file does not exist
+ */
+ Path doesNotExist = dir.resolve("DoesNotExist");
+ try {
+ doesNotExist.toRealPath(true);
+ throw new RuntimeException("IOException expected");
+ } catch (IOException expected) {
+ }
+ try {
+ doesNotExist.toRealPath(false);
+ throw new RuntimeException("IOException expected");
+ } catch (IOException expected) {
+ }
+
/**
* Test: toRealPath(true) should resolve links
*/
diff --git a/jdk/test/java/security/cert/CertificateFactory/openssl/BadFooter.java b/jdk/test/java/security/cert/CertificateFactory/openssl/BadFooter.java
index ccacfda3d20..6435221f699 100644
--- a/jdk/test/java/security/cert/CertificateFactory/openssl/BadFooter.java
+++ b/jdk/test/java/security/cert/CertificateFactory/openssl/BadFooter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*
* @test
diff --git a/jdk/test/java/util/zip/GZIP/GZIPInputStreamRead.java b/jdk/test/java/util/zip/GZIP/GZIPInputStreamRead.java
index 839b7002e97..4377554e9c8 100644
--- a/jdk/test/java/util/zip/GZIP/GZIPInputStreamRead.java
+++ b/jdk/test/java/util/zip/GZIP/GZIPInputStreamRead.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JFormattedTextField/Test6462562.java b/jdk/test/javax/swing/JFormattedTextField/Test6462562.java
index 0696a016fba..5fcecbf89ca 100644
--- a/jdk/test/javax/swing/JFormattedTextField/Test6462562.java
+++ b/jdk/test/javax/swing/JFormattedTextField/Test6462562.java
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTabbedPane/6670274/bug6670274.java b/jdk/test/javax/swing/JTabbedPane/6670274/bug6670274.java
index cbb0b1f99f3..648c94e24f5 100644
--- a/jdk/test/javax/swing/JTabbedPane/6670274/bug6670274.java
+++ b/jdk/test/javax/swing/JTabbedPane/6670274/bug6670274.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*@test
diff --git a/jdk/test/javax/swing/JTable/6768387/bug6768387.java b/jdk/test/javax/swing/JTable/6768387/bug6768387.java
index ccf0f39f75b..fbfb30249fd 100644
--- a/jdk/test/javax/swing/JTable/6768387/bug6768387.java
+++ b/jdk/test/javax/swing/JTable/6768387/bug6768387.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTable/6788484/bug6788484.java b/jdk/test/javax/swing/JTable/6788484/bug6788484.java
index cbc23310e87..ded6f1fb72e 100644
--- a/jdk/test/javax/swing/JTable/6788484/bug6788484.java
+++ b/jdk/test/javax/swing/JTable/6788484/bug6788484.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTable/6937798/bug6937798.java b/jdk/test/javax/swing/JTable/6937798/bug6937798.java
index 55cd5bbe5bc..6e063d50dd6 100644
--- a/jdk/test/javax/swing/JTable/6937798/bug6937798.java
+++ b/jdk/test/javax/swing/JTable/6937798/bug6937798.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTableHeader/6884066/bug6884066.java b/jdk/test/javax/swing/JTableHeader/6884066/bug6884066.java
index 5110b9668d5..1b9ee135c67 100644
--- a/jdk/test/javax/swing/JTableHeader/6884066/bug6884066.java
+++ b/jdk/test/javax/swing/JTableHeader/6884066/bug6884066.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTableHeader/6889007/bug6889007.java b/jdk/test/javax/swing/JTableHeader/6889007/bug6889007.java
index b39a130435c..f9ee4850377 100644
--- a/jdk/test/javax/swing/JTableHeader/6889007/bug6889007.java
+++ b/jdk/test/javax/swing/JTableHeader/6889007/bug6889007.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTextArea/6925473/bug6925473.java b/jdk/test/javax/swing/JTextArea/6925473/bug6925473.java
index 9aa116c8b3e..d62a5458e3d 100644
--- a/jdk/test/javax/swing/JTextArea/6925473/bug6925473.java
+++ b/jdk/test/javax/swing/JTextArea/6925473/bug6925473.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JTextArea/6940863/bug6940863.java b/jdk/test/javax/swing/JTextArea/6940863/bug6940863.java
index eb05ee3a57f..ffcd2d44aa5 100644
--- a/jdk/test/javax/swing/JTextArea/6940863/bug6940863.java
+++ b/jdk/test/javax/swing/JTextArea/6940863/bug6940863.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/JViewport/6953396/bug6953396.java b/jdk/test/javax/swing/JViewport/6953396/bug6953396.java
index 0662ccd7439..b134911ad40 100644
--- a/jdk/test/javax/swing/JViewport/6953396/bug6953396.java
+++ b/jdk/test/javax/swing/JViewport/6953396/bug6953396.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/* @test
diff --git a/jdk/test/javax/swing/border/Test6910490.java b/jdk/test/javax/swing/border/Test6910490.java
index 560ec6defac..78dd3dfb872 100644
--- a/jdk/test/javax/swing/border/Test6910490.java
+++ b/jdk/test/javax/swing/border/Test6910490.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
import static java.awt.Color.RED;
diff --git a/jdk/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java b/jdk/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java
index 27e48672336..71b5192c92f 100644
--- a/jdk/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java
+++ b/jdk/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/**
diff --git a/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java b/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
index a96f18e4443..292acd18d81 100644
--- a/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
+++ b/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
import javax.swing.text.*;
diff --git a/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java b/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
index cdaa1d132ba..7a51d1bfd01 100644
--- a/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
+++ b/jdk/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
import javax.swing.text.*;
diff --git a/jdk/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java b/jdk/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
index b8ad6af6888..a5c84229798 100644
--- a/jdk/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
+++ b/jdk/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*
diff --git a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh b/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh
index 917f1c22833..49d5f44be71 100644
--- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh
+++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh
@@ -23,6 +23,7 @@
#
# @test
+# @ignore until 6543856 is fixed
# @bug 4990825
# @summary attach to external but local JVM processes
# @library ../../testlibrary
diff --git a/jdk/test/sun/net/www/protocol/file/DirPermissionDenied.java b/jdk/test/sun/net/www/protocol/file/DirPermissionDenied.java
new file mode 100644
index 00000000000..7ffe3a1d67c
--- /dev/null
+++ b/jdk/test/sun/net/www/protocol/file/DirPermissionDenied.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.io.IOException;
+
+public class DirPermissionDenied {
+ public static void main(String[] args) throws Exception {
+ URL url = new URL("file:" + args[0]);
+
+ try {
+ URLConnection uc = url.openConnection();
+ uc.connect();
+ } catch (IOException e) {
+ // OK
+ } catch (Exception e) {
+ throw new RuntimeException("Failed " + e);
+ }
+
+ try {
+ URLConnection uc = url.openConnection();
+ uc.getInputStream();
+ } catch (IOException e) {
+ // OK
+ } catch (Exception e) {
+ throw new RuntimeException("Failed " + e);
+ }
+
+ try {
+ URLConnection uc = url.openConnection();
+ uc.getContentLengthLong();
+ } catch (IOException e) {
+ // OK
+ } catch (Exception e) {
+ throw new RuntimeException("Failed " + e);
+ }
+ }
+}
diff --git a/jdk/test/sun/net/www/protocol/file/DirPermissionDenied.sh b/jdk/test/sun/net/www/protocol/file/DirPermissionDenied.sh
new file mode 100644
index 00000000000..67930b02bd4
--- /dev/null
+++ b/jdk/test/sun/net/www/protocol/file/DirPermissionDenied.sh
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# @test
+# @bug 6977851
+# @summary NPE from FileURLConnection.connect
+# @build DirPermissionDenied
+# @run shell DirPermissionDenied.sh
+
+TESTDIR="${TESTCLASSES}/DirPermissionDeniedDirectory"
+echo ${TESTDIR}
+
+rm -rf ${TESTDIR}
+mkdir -p ${TESTDIR}
+chmod 333 ${TESTDIR}
+
+$TESTJAVA/bin/java -classpath $TESTCLASSES DirPermissionDenied ${TESTDIR}
+result=$?
+rm -rf ${TESTDIR}
+exit $result
diff --git a/jdk/test/sun/security/krb5/BadKdcDefaultValue.java b/jdk/test/sun/security/krb5/BadKdcDefaultValue.java
new file mode 100644
index 00000000000..1235cce4b9d
--- /dev/null
+++ b/jdk/test/sun/security/krb5/BadKdcDefaultValue.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 6976536
+ * @summary Solaris JREs do not have the krb5.kdc.bad.policy configured by default.
+ * @run main/othervm BadKdcDefaultValue
+ */
+
+import java.security.Security;
+
+public class BadKdcDefaultValue {
+ public static void main(String[] args) throws Exception {
+ if (!"tryLast".equalsIgnoreCase(
+ Security.getProperty("krb5.kdc.bad.policy"))) {
+ throw new Exception("Default value not correct");
+ }
+ }
+}
+
diff --git a/jdk/test/sun/security/krb5/MicroTime.java b/jdk/test/sun/security/krb5/MicroTime.java
index db8aeac0147..6bbf8b8e974 100644
--- a/jdk/test/sun/security/krb5/MicroTime.java
+++ b/jdk/test/sun/security/krb5/MicroTime.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*
* @test
diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java
index 3856ef7ebe1..7481a6cbf04 100644
--- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java
+++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6226610
+ * @bug 6226610 6973030
* @run main/othervm B6226610
* @summary HTTP tunnel connections send user headers to proxy
*/
@@ -36,45 +36,23 @@
import java.io.*;
import java.net.*;
-import javax.net.ssl.*;
-import javax.net.ServerSocketFactory;
-import sun.net.www.*;
-import java.util.Enumeration;
+import sun.net.www.MessageHeader;
public class B6226610 {
static HeaderCheckerProxyTunnelServer proxy;
- // it seems there's no proxy ever if a url points to 'localhost',
- // even if proxy related properties are set. so we need to bind
- // our simple http proxy and http server to a non-loopback address
- static InetAddress firstNonLoAddress = null;
-
- public static void main(String[] args)
+ public static void main(String[] args) throws Exception
{
- try {
- proxy = new HeaderCheckerProxyTunnelServer();
- proxy.start();
- } catch (Exception e) {
- System.out.println("Cannot create proxy: " + e);
- }
+ proxy = new HeaderCheckerProxyTunnelServer();
+ proxy.start();
- try {
- firstNonLoAddress = getNonLoAddress();
-
- if (firstNonLoAddress == null) {
- System.out.println("The test needs at least one non-loopback address to run. Quit now.");
- System.exit(0);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- System.setProperty( "https.proxyHost", firstNonLoAddress.getHostAddress());
- System.setProperty( "https.proxyPort", (new Integer(proxy.getLocalPort())).toString() );
+ String hostname = InetAddress.getLocalHost().getHostName();
try {
- URL u = new URL("https://" + firstNonLoAddress.getHostAddress());
- java.net.URLConnection c = u.openConnection();
+ URL u = new URL("https://" + hostname + "/");
+ System.out.println("Connecting to " + u);
+ InetSocketAddress proxyAddr = new InetSocketAddress(hostname, proxy.getLocalPort());
+ java.net.URLConnection c = u.openConnection(new Proxy(Proxy.Type.HTTP, proxyAddr));
/* I want this header to go to the destination server only, protected
* by SSL
@@ -89,33 +67,15 @@ public class B6226610 {
}
else
System.out.println(e);
-
+ } finally {
+ if (proxy != null) proxy.shutdown();
}
if (HeaderCheckerProxyTunnelServer.failed)
- throw new RuntimeException("Test failed: Proxy should not receive user defined headers for tunneled requests");
+ throw new RuntimeException("Test failed; see output");
}
-
- public static InetAddress getNonLoAddress() throws Exception {
- NetworkInterface loNIC = NetworkInterface.getByInetAddress(InetAddress.getByName("localhost"));
- Enumeration nics = NetworkInterface.getNetworkInterfaces();
- while (nics.hasMoreElements()) {
- NetworkInterface nic = nics.nextElement();
- if (!nic.getName().equalsIgnoreCase(loNIC.getName())) {
- Enumeration addrs = nic.getInetAddresses();
- while (addrs.hasMoreElements()) {
- InetAddress addr = addrs.nextElement();
- if (!addr.isLoopbackAddress())
- return addr;
- }
- }
- }
- return null;
- }
-
}
-
class HeaderCheckerProxyTunnelServer extends Thread
{
public static boolean failed = false;
@@ -139,6 +99,10 @@ class HeaderCheckerProxyTunnelServer extends Thread
}
}
+ void shutdown() {
+ try { ss.close(); } catch (IOException e) {}
+ }
+
public void run()
{
try {
@@ -178,6 +142,15 @@ class HeaderCheckerProxyTunnelServer extends Thread
retrieveConnectInfo(statusLine);
if (mheader.findValue("X-TestHeader") != null) {
+ System.out.println("Proxy should not receive user defined headers for tunneled requests");
+ failed = true;
+ }
+
+ // 6973030
+ String value;
+ if ((value = mheader.findValue("Proxy-Connection")) == null ||
+ !value.equals("keep-alive")) {
+ System.out.println("Proxy-Connection:keep-alive not being sent");
failed = true;
}
diff --git a/jdk/test/tools/jar/JarEntryTime.java b/jdk/test/tools/jar/JarEntryTime.java
index 525d6b9032d..2998b29bc8a 100644
--- a/jdk/test/tools/jar/JarEntryTime.java
+++ b/jdk/test/tools/jar/JarEntryTime.java
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 4225317
+ * @bug 4225317 6969651
* @summary Check extracted files have date as per those in the .jar file
*/
@@ -68,17 +68,9 @@ public class JarEntryTime {
}
public static void realMain(String[] args) throws Throwable {
- final long now = System.currentTimeMillis();
- final long earlier = now - (60L * 60L * 6L * 1000L);
- final long yesterday = now - (60L * 60L * 24L * 1000L);
-
- // ZipEntry's mod date has 2 seconds precision: give extra time to
- // allow for e.g. rounding/truncation and networked/samba drives.
- final long PRECISION = 10000L;
File dirOuter = new File("outer");
File dirInner = new File(dirOuter, "inner");
-
File jarFile = new File("JarEntryTime.jar");
// Remove any leftovers from prior run
@@ -99,6 +91,17 @@ public class JarEntryTime {
PrintWriter pw = new PrintWriter(fileInner);
pw.println("hello, world");
pw.close();
+
+ // Get the "now" from the "last-modified-time" of the last file we
+ // just created, instead of the "System.currentTimeMillis()", to
+ // workaround the possible "time difference" due to nfs.
+ final long now = fileInner.lastModified();
+ final long earlier = now - (60L * 60L * 6L * 1000L);
+ final long yesterday = now - (60L * 60L * 24L * 1000L);
+ // ZipEntry's mod date has 2 seconds precision: give extra time to
+ // allow for e.g. rounding/truncation and networked/samba drives.
+ final long PRECISION = 10000L;
+
dirOuter.setLastModified(now);
dirInner.setLastModified(yesterday);
fileInner.setLastModified(earlier);
diff --git a/jdk/test/tools/pack200/CommandLineTests.java b/jdk/test/tools/pack200/CommandLineTests.java
new file mode 100644
index 00000000000..fefefd2a860
--- /dev/null
+++ b/jdk/test/tools/pack200/CommandLineTests.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2007, 2010 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test CommandLineTests.sh
+ * @bug 6521334 6965836 6965836
+ * @compile -XDignore.symbol.file CommandLineTests.java Pack200Test.java
+ * @run main/timeout=1200 CommandLineTests
+ * @summary An ad hoc test to verify the behavior of pack200/unpack200 CLIs,
+ * and a simulation of pack/unpacking in the install repo.
+ * @author ksrini
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+/*
+ * We try a potpouri of things ie. we have pack.conf to setup some
+ * options as well as a couple of command line options. We also test
+ * the packing and unpacking mechanism using the Java APIs. This also
+ * simulates pack200 the install workspace, noting that this is a simulation
+ * and can only test jars that are guaranteed to be available, also the
+ * configuration may not be in sync with the installer workspace.
+ */
+
+public class CommandLineTests {
+ private static final File CWD = new File(".");
+ private static final File EXP_SDK = new File(CWD, "exp-sdk-image");
+ private static final File EXP_SDK_LIB_DIR = new File(EXP_SDK, "lib");
+ private static final File EXP_SDK_BIN_DIR = new File(EXP_SDK, "bin");
+ private static final File EXP_JRE_DIR = new File(EXP_SDK, "jre");
+ private static final File EXP_JRE_LIB_DIR = new File(EXP_JRE_DIR, "lib");
+ private static final File RtJar = new File(EXP_JRE_LIB_DIR, "rt.jar");
+ private static final File CharsetsJar = new File(EXP_JRE_LIB_DIR, "charsets.jar");
+ private static final File JsseJar = new File(EXP_JRE_LIB_DIR, "jsse.jar");
+ private static final File ToolsJar = new File(EXP_SDK_LIB_DIR, "tools.jar");
+ private static final File javaCmd;
+ private static final File javacCmd;
+ private static final File ConfigFile = new File("pack.conf");
+ private static final List jarList;
+
+ static {
+ javaCmd = Utils.IsWindows
+ ? new File(EXP_SDK_BIN_DIR, "java.exe")
+ : new File(EXP_SDK_BIN_DIR, "java");
+
+ javacCmd = Utils.IsWindows
+ ? new File(EXP_SDK_BIN_DIR, "javac.exe")
+ : new File(EXP_SDK_BIN_DIR, "javac");
+
+ jarList = new ArrayList();
+ jarList.add(RtJar);
+ jarList.add(CharsetsJar);
+ jarList.add(JsseJar);
+ jarList.add(ToolsJar);
+ }
+
+ // init test area with a copy of the sdk
+ static void init() throws IOException {
+ Utils.recursiveCopy(Utils.JavaSDK, EXP_SDK);
+ creatConfigFile();
+ }
+
+ // Hopefully, this should be kept in sync with what the installer does.
+ static void creatConfigFile() throws IOException {
+ FileOutputStream fos = null;
+ PrintStream ps = null;
+ try {
+ fos = new FileOutputStream(ConfigFile);
+ ps = new PrintStream(fos);
+ ps.println("com.sun.java.util.jar.pack.debug.verbose=0");
+ ps.println("pack.modification.time=keep");
+ ps.println("pack.keep.class.order=true");
+ ps.println("pack.deflate.hint=false");
+ // Fail the build, if new or unknown attributes are introduced.
+ ps.println("pack.unknown.attribute=error");
+ ps.println("pack.segment.limit=-1");
+ // BugId: 6328502, These files will be passed-through as-is.
+ ps.println("pack.pass.file.0=java/lang/Error.class");
+ ps.println("pack.pass.file.1=java/lang/LinkageError.class");
+ ps.println("pack.pass.file.2=java/lang/Object.class");
+ ps.println("pack.pass.file.3=java/lang/Throwable.class");
+ ps.println("pack.pass.file.4=java/lang/VerifyError.class");
+ ps.println("pack.pass.file.5=com/sun/demo/jvmti/hprof/Tracker.class");
+ } finally {
+ Utils.close(ps);
+ Utils.close(fos);
+ }
+ }
+
+ static void runPack200(boolean jre) throws IOException {
+ List cmdsList = new ArrayList();
+ for (File f : jarList) {
+ if (jre && f.getName().equals("tools.jar")) {
+ continue; // need not worry about tools.jar for JRE
+ }
+ // make a backup copy for re-use
+ File bakFile = new File(f.getName() + ".bak");
+ if (!bakFile.exists()) { // backup
+ Utils.copyFile(f.getAbsoluteFile(), bakFile.getAbsoluteFile());
+ } else { // restore
+ Utils.copyFile(bakFile.getAbsoluteFile(), f.getAbsoluteFile());
+ }
+ cmdsList.clear();
+ cmdsList.add(Utils.getPack200Cmd());
+ cmdsList.add("-J-esa");
+ cmdsList.add("-J-ea");
+ cmdsList.add(Utils.Is64Bit ? "-J-Xmx1g" : "-J-Xmx512m");
+ cmdsList.add("--repack");
+ cmdsList.add("--config-file=" + ConfigFile.getAbsolutePath());
+ if (jre) {
+ cmdsList.add("--strip-debug");
+ }
+ // NOTE: commented until 6965836 is fixed
+ // cmdsList.add("--code-attribute=StackMapTable=strip");
+ cmdsList.add(f.getAbsolutePath());
+ Utils.runExec(cmdsList);
+ }
+ }
+
+ static void testJRE() throws IOException {
+ runPack200(true);
+ // the speciment JRE
+ List cmdsList = new ArrayList();
+ cmdsList.add(javaCmd.getAbsolutePath());
+ cmdsList.add("-verify");
+ cmdsList.add("-version");
+ Utils.runExec(cmdsList);
+ }
+
+ static void testJDK() throws IOException {
+ runPack200(false);
+ // test the specimen JDK
+ List cmdsList = new ArrayList();
+ cmdsList.add(javaCmd.getAbsolutePath());
+ cmdsList.add("-verify");
+ cmdsList.add("-version");
+ Utils.runExec(cmdsList);
+
+ // invoke javac to test the tools.jar
+ cmdsList.clear();
+ cmdsList.add(javacCmd.getAbsolutePath());
+ cmdsList.add("-J-verify");
+ cmdsList.add("-help");
+ Utils.runExec(cmdsList);
+ }
+ public static void main(String... args) {
+ try {
+ init();
+ testJRE();
+ testJDK();
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ }
+}
diff --git a/jdk/test/tools/pack200/Pack200Props.java b/jdk/test/tools/pack200/Pack200Props.java
new file mode 100644
index 00000000000..61b718ea9d9
--- /dev/null
+++ b/jdk/test/tools/pack200/Pack200Props.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6575373 6969063
+ * @summary verify default properties of the packer/unpacker and segment limit
+ * @compile -XDignore.symbol.file Utils.java Pack200Props.java
+ * @run main Pack200Props
+ * @author ksrini
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Pack200;
+import java.util.jar.Pack200.Packer;
+
+/*
+ * Run this against a large jar file, by default the packer should generate only
+ * one segment, parse the output of the packer to verify if this is indeed true.
+ */
+
+public class Pack200Props {
+
+ public static void main(String... args) {
+ verifyDefaults();
+ File out = new File("test" + Utils.PACK_FILE_EXT);
+ out.delete();
+ verifySegmentLimit(out);
+ }
+
+ static void verifySegmentLimit(File outFile) {
+ File sdkHome = Utils.JavaSDK;
+ File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
+
+ System.out.println("using pack200: " + Utils.getPack200Cmd());
+
+ List cmdsList = new ArrayList<>();
+ cmdsList.add(Utils.getPack200Cmd());
+ cmdsList.add("--effort=1");
+ cmdsList.add("--verbose");
+ cmdsList.add("--no-gzip");
+ cmdsList.add(outFile.getName());
+ cmdsList.add(testJar.getAbsolutePath());
+ List outList = Utils.runExec(cmdsList);
+
+ int count = 0;
+ for (String line : outList) {
+ System.out.println(line);
+ if (line.matches(".*Transmitted.*files of.*input bytes in a segment of.*bytes")) {
+ count++;
+ }
+ }
+ if (count == 0) {
+ throw new RuntimeException("no segments or no output ????");
+ } else if (count > 1) {
+ throw new RuntimeException("multiple segments detected, expected 1");
+ }
+ }
+
+ private static void verifyDefaults() {
+ Map expectedDefaults = new HashMap<>();
+ Packer p = Pack200.newPacker();
+ expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
+ p.FALSE);
+ expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
+ p.FALSE);
+ expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
+ expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
+ expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
+ expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
+ "NH[PHPOHIIH]");
+ expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
+ "NH[PHHII]");
+ expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
+ expectedDefaults.put(p.EFFORT, "5");
+ expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
+ expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
+ expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
+ expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);
+
+ Map props = p.properties();
+ int errors = 0;
+ for (String key : expectedDefaults.keySet()) {
+ String def = expectedDefaults.get(key);
+ String x = props.get(key);
+ if (x == null) {
+ System.out.println("Error: key not found:" + key);
+ errors++;
+ } else {
+ if (!def.equals(x)) {
+ System.out.println("Error: key " + key
+ + "\n value expected: " + def
+ + "\n value obtained: " + x);
+ errors++;
+ }
+ }
+ }
+ if (errors > 0) {
+ throw new RuntimeException(errors +
+ " error(s) encountered in default properties verification");
+ }
+ }
+}
+
diff --git a/jdk/test/tools/pack200/Pack200Simple.sh b/jdk/test/tools/pack200/Pack200Simple.sh
deleted file mode 100644
index 71b9611c963..00000000000
--- a/jdk/test/tools/pack200/Pack200Simple.sh
+++ /dev/null
@@ -1,197 +0,0 @@
-#
-# Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test Pack200Simple.sh
-# @bug 6521334
-# @build Pack200Test
-# @run shell/timeout=1200 Pack200Simple.sh
-# @summary An ad hoc test to verify class-file format.
-# @author Kumar Srinivasan
-
-# The goal of this test is to assist javac or other developers
-# who modify class file formats, to quickly test those modifications
-# without having to build the install workspace. However it must
-# be noted that building the install workspace is the only know
-# way to prevent build breakages.
-
-# Pack200 developers could use this as a basic smoke-test, however
-# please note, there are other more elaborate and thorough tests for
-# this very purpose.
-
-# We try a potpouri of things ie. we have pack.conf to setup some
-# options as well as a couple of command line options. We also test
-# the packing and unpacking mechanism using the Java APIs.
-
-# print error and exit with a message
-errorOut() {
- if [ "x$1" = "x" ]; then
- printf "Error: Unknown error\n"
- else
- printf "Error: %s\n" "$1"
- fi
-
- exit 1
-}
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]; then
- errorOut "TESTJAVA not set. Test cannot execute. Failed."
-fi
-
-if [ "${TESTSRC}" = "" ]; then
- errorOut "TESTSRC not set. Test cannot execute. Failed."
-fi
-
-
-if [ "${TESTCLASSES}" = "" ]; then
- errorOut "TESTCLASSES not set. Test cannot execute. Failed."
-fi
-
-# The common java utils we need
-PACK200=${TESTJAVA}/bin/pack200
-UNPACK200=${TESTJAVA}/bin/unpack200
-JAR=${TESTJAVA}/bin/jar
-
-# For Windows and Linux needs the heap to be set, for others ergonomics
-# will do the rest. It is important to use ea, which can expose class
-# format errors much earlier than later.
-
-OS=`uname -s`
-
-
-case "$OS" in
- Windows*|CYGWIN* )
- PackOptions="-J-Xmx512m -J-ea"
- break
- ;;
-
- Linux )
- PackOptions="-J-Xmx512m -J-ea"
- break
- ;;
-
- * )
- PackOptions="-J-ea"
- ;;
-esac
-
-# Creates a packfile of choice expects 1 argument the filename
-createConfigFile() {
- # optimize for speed
- printf "pack.effort=1\n" > $1
- # we DO want to know about new attributes
- printf "pack.unknown.attribute=error\n" >> $1
- # optimize for speed
- printf "pack.deflate.hint=false\n" >> $1
- # keep the ordering for easy compare
- printf "pack.keep.class.order=true\n" >> $1
-}
-
-
-# Tests a given jar, expects 1 argument the fully qualified
-# name to a test jar, it writes all output to the current
-# directory which is a scratch area.
-testAJar() {
- PackConf="pack.conf"
- createConfigFile $PackConf
-
- # Try some command line options
- CLIPackOptions="$PackOptions -v --no-gzip --segment-limit=10000 --config-file=$PackConf"
-
- jfName=`basename $1`
-
- ${PACK200} $CLIPackOptions ${jfName}.pack $1 > ${jfName}.pack.log 2>&1
- if [ $? != 0 ]; then
- errorOut "$jfName packing failed"
- fi
-
- # We want to test unpack200, therefore we dont use -r with pack
- ${UNPACK200} -v ${jfName}.pack $jfName > ${jfName}.unpack.log 2>&1
- if [ $? != 0 ]; then
- errorOut "$jfName unpacking failed"
- fi
-
- # A quick crc compare test to ensure a well formed zip
- # archive, this is a critical unpack200 behaviour.
-
- unzip -t $jfName > ${jfName}.unzip.log 2>&1
- if [ $? != 0 ]; then
- errorOut "$jfName unzip -t test failed"
- fi
-
- # The PACK200 signature should be at the top of the log
- # this tag is critical for deployment related tools.
-
- head -5 ${jfName}.unzip.log | grep PACK200 > /dev/null 2>&1
- if [ $? != 0 ]; then
- errorOut "$jfName PACK200 signature missing"
- fi
-
-
- # we know the size fields don't match, strip 'em out, its
- # extremely important to ensure that the date stamps match up.
- # Don't EVER sort the output we are checking for correct ordering.
-
- ${JAR} -tvf $1 | sed -e 's/^ *[0-9]* //g'> ${jfName}.ref.txt
- ${JAR} -tvf $jfName | sed -e 's/^ *[0-9]* //g'> ${jfName}.cmp.txt
-
- diff ${jfName}.ref.txt ${jfName}.cmp.txt > ${jfName}.diff.log 2>&1
- if [ $? != 0 ]; then
- errorOut "$jfName files missing"
- fi
-}
-
-# These JARs are the largest and also the most likely specimens to
-# expose class format issues and stress the packer as well.
-
-JLIST="${TESTJAVA}/lib/tools.jar ${TESTJAVA}/jre/lib/rt.jar"
-
-
-# Test the Command Line Interfaces (CLI).
-mkdir cliTestDir
-_pwd=`pwd`
-cd cliTestDir
-
-for jarfile in $JLIST ; do
- if [ -f $jarfile ]; then
- testAJar $jarfile
- else
- errorOut "Error: '$jarFile' does not exist\nTest requires a j2sdk-image\n"
- fi
-done
-cd $_pwd
-
-# Test the Java APIs.
-mkdir apiTestDir
-_pwd=`pwd`
-cd apiTestDir
-
-# Strip out the -J prefixes.
-JavaPackOptions=`printf %s "$PackOptions" | sed -e 's/-J//g'`
-
-# Test the Java APIs now.
-$TESTJAVA/bin/java $JavaPackOptions -cp $TESTCLASSES Pack200Test $JLIST || exit 1
-
-cd $_pwd
-
-exit 0
diff --git a/jdk/test/tools/pack200/Pack200Test.java b/jdk/test/tools/pack200/Pack200Test.java
index 631b50709da..04dbf7327c2 100644
--- a/jdk/test/tools/pack200/Pack200Test.java
+++ b/jdk/test/tools/pack200/Pack200Test.java
@@ -24,111 +24,97 @@
import java.util.*;
import java.io.*;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
import java.util.jar.*;
-import java.util.zip.*;
-/*
- * Pack200Test.java
- *
- * @author ksrini
- */
+ /*
+ * @test
+ * @bug 6521334 6712743
+ * @summary check for memory leaks, test general packer/unpacker functionality\
+ * using native and java unpackers
+ * @compile -XDignore.symbol.file Utils.java Pack200Test.java
+ * @run main/othervm/timeout=1200 -Xmx512m Pack200Test
+ * @author ksrini
+ */
/**
- * These tests are very rudimentary smoke tests to ensure that the packing
- * unpacking process works on a select set of JARs.
+ * Tests the packing/unpacking via the APIs.
*/
public class Pack200Test {
private static ArrayList jarList = new ArrayList();
- static final String PACKEXT = ".pack";
+ static final MemoryMXBean mmxbean = ManagementFactory.getMemoryMXBean();
+ static final long m0 = getUsedMemory();
+ static final int LEAK_TOLERANCE = 20000; // OS and GC related variations.
/** Creates a new instance of Pack200Test */
private Pack200Test() {}
+ static long getUsedMemory() {
+ mmxbean.gc();
+ mmxbean.gc();
+ mmxbean.gc();
+ return mmxbean.getHeapMemoryUsage().getUsed()/1024;
+ }
+
+ private static void leakCheck() throws Exception {
+ long diff = getUsedMemory() - m0;
+ System.out.println(" Info: memory diff = " + diff + "K");
+ if ( diff > LEAK_TOLERANCE) {
+ throw new Exception("memory leak detected " + diff);
+ }
+ }
+
private static void doPackUnpack() {
for (File in : jarList) {
- Pack200.Packer packer = Pack200.newPacker();
- Map p = packer.properties();
- // Take the time optimization vs. space
- p.put(packer.EFFORT, "1"); // CAUTION: do not use 0.
- // Make the memory consumption as effective as possible
- p.put(packer.SEGMENT_LIMIT,"10000");
- // throw an error if an attribute is unrecognized
- p.put(packer.UNKNOWN_ATTRIBUTE, packer.ERROR);
- // ignore all JAR deflation requests to save time
- p.put(packer.DEFLATE_HINT, packer.FALSE);
- // save the file ordering of the original JAR
- p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
-
+ JarOutputStream javaUnpackerStream = null;
+ JarOutputStream nativeUnpackerStream = null;
+ JarFile jarFile = null;
try {
- JarFile jarFile = new JarFile(in);
+ jarFile = new JarFile(in);
// Write out to a jtreg scratch area
- FileOutputStream fos = new FileOutputStream(in.getName() + PACKEXT);
+ File packFile = new File(in.getName() + Utils.PACK_FILE_EXT);
- System.out.print("Packing [" + in.toString() + "]...");
+ System.out.println("Packing [" + in.toString() + "]");
// Call the packer
- packer.pack(jarFile, fos);
+ Utils.pack(jarFile, packFile);
jarFile.close();
- fos.close();
-
- System.out.print("Unpacking...");
- File f = new File(in.getName() + PACKEXT);
+ leakCheck();
+ System.out.println(" Unpacking using java unpacker");
+ File javaUnpackedJar = new File("java-" + in.getName());
// Write out to current directory, jtreg will setup a scratch area
- JarOutputStream jostream = new JarOutputStream(new FileOutputStream(in.getName()));
-
- // Unpack the files
- Pack200.Unpacker unpacker = Pack200.newUnpacker();
- // Call the unpacker
- unpacker.unpack(f, jostream);
- // Must explicitly close the output.
- jostream.close();
- System.out.print("Testing...");
+ javaUnpackerStream = new JarOutputStream(
+ new FileOutputStream(javaUnpackedJar));
+ Utils.unpackj(packFile, javaUnpackerStream);
+ javaUnpackerStream.close();
+ System.out.println(" Testing...java unpacker");
+ leakCheck();
// Ok we have unpacked the file, lets test it.
- doTest(in);
+ Utils.doCompareVerify(in.getAbsoluteFile(), javaUnpackedJar);
+
+ System.out.println(" Unpacking using native unpacker");
+ // Write out to current directory
+ File nativeUnpackedJar = new File("native-" + in.getName());
+ nativeUnpackerStream = new JarOutputStream(
+ new FileOutputStream(nativeUnpackedJar));
+ Utils.unpackn(packFile, nativeUnpackerStream);
+ nativeUnpackerStream.close();
+ System.out.println(" Testing...native unpacker");
+ leakCheck();
+ // the unpackers (native and java) should produce identical bits
+ // so we use use bit wise compare, the verification compare is
+ // very expensive wrt. time.
+ Utils.doCompareBitWise(javaUnpackedJar, nativeUnpackedJar);
System.out.println("Done.");
} catch (Exception e) {
- System.out.println("ERROR: " + e.getMessage());
- System.exit(1);
- }
- }
- }
-
- private static ArrayList getZipFileEntryNames(ZipFile z) {
- ArrayList out = new ArrayList();
- for (ZipEntry ze : Collections.list(z.entries())) {
- out.add(ze.getName());
- }
- return out;
- }
-
- private static void doTest(File in) throws Exception {
- // make sure all the files in the original jar exists in the other
- ArrayList refList = getZipFileEntryNames(new ZipFile(in));
- ArrayList cmpList = getZipFileEntryNames(new ZipFile(in.getName()));
-
- System.out.print(refList.size() + "/" + cmpList.size() + " entries...");
-
- if (refList.size() != cmpList.size()) {
- throw new Exception("Missing: files ?, entries don't match");
- }
-
- for (String ename: refList) {
- if (!cmpList.contains(ename)) {
- throw new Exception("Does not contain : " + ename);
- }
- }
- }
-
- private static void doSanity(String[] args) {
- for (String s: args) {
- File f = new File(s);
- if (f.exists()) {
- jarList.add(f);
- } else {
- System.out.println("Warning: The JAR file " + f.toString() + " does not exist,");
- System.out.println(" this test requires a JDK image, this file will be skipped.");
+ throw new RuntimeException(e);
+ } finally {
+ Utils.close(nativeUnpackerStream);
+ Utils.close(javaUnpackerStream);
+ Utils.close((Closeable) jarFile);
}
}
}
@@ -137,11 +123,12 @@ public class Pack200Test {
* @param args the command line arguments
*/
public static void main(String[] args) {
- if (args.length < 1) {
- System.out.println("Usage: jar1 jar2 jar3 .....");
- System.exit(1);
- }
- doSanity(args);
+ // select the jars carefully, adding more jars will increase the
+ // testing time, especially for jprt.
+ jarList.add(Utils.locateJar("tools.jar"));
+ jarList.add(Utils.locateJar("rt.jar"));
+ jarList.add(Utils.locateJar("golden.jar"));
+ System.out.println(jarList);
doPackUnpack();
}
}
diff --git a/jdk/test/tools/pack200/PackageVersionTest.java b/jdk/test/tools/pack200/PackageVersionTest.java
index 0cd9ca26453..344aadd6b61 100644
--- a/jdk/test/tools/pack200/PackageVersionTest.java
+++ b/jdk/test/tools/pack200/PackageVersionTest.java
@@ -22,13 +22,14 @@
* questions.
*/
-/**
- * @test
- * @bug 6712743
- * @summary verify package versioning
- * @compile -XDignore.symbol.file PackageVersionTest.java
- * @run main PackageVersionTest
- */
+/*
+ * @test
+ * @bug 6712743
+ * @summary verify package versions
+ * @compile -XDignore.symbol.file Utils.java PackageVersionTest.java
+ * @run main PackageVersionTest
+ * @author ksrini
+ */
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
@@ -74,14 +75,6 @@ public class PackageVersionTest {
JAVA5_PACKAGE_MINOR_VERSION);
}
- static void close(Closeable c) {
- if (c == null) {
- return;
- }
- try {
- c.close();
- } catch (IOException ignore) {}
- }
static void createClassFile(String name) {
createJavaFile(name);
@@ -93,7 +86,7 @@ public class PackageVersionTest {
name.substring(name.length() - 1),
name + ".java"
};
- compileJava(javacCmds);
+ Utils.compiler(javacCmds);
}
static void createJavaFile(String name) {
@@ -108,22 +101,8 @@ public class PackageVersionTest {
} catch (IOException ioe) {
throw new RuntimeException("creation of test file failed");
} finally {
- close(ps);
- close(fos);
- }
- }
-
- static void compileJava(String... javacCmds) {
- if (com.sun.tools.javac.Main.compile(javacCmds) != 0) {
- throw new RuntimeException("compilation failed");
- }
- }
-
- static void makeJar(String... jargs) {
- sun.tools.jar.Main jarTool =
- new sun.tools.jar.Main(System.out, System.err, "jartool");
- if (!jarTool.run(jargs)) {
- throw new RuntimeException("jar command failed");
+ Utils.close(ps);
+ Utils.close(fos);
}
}
@@ -136,7 +115,7 @@ public class PackageVersionTest {
jarFileName.getName(),
filename
};
- makeJar(jargs);
+ Utils.jar(jargs);
JarFile jfin = null;
try {
@@ -163,7 +142,7 @@ public class PackageVersionTest {
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage());
} finally {
- close(jfin);
+ Utils.close((Closeable) jfin);
}
}
}
diff --git a/jdk/test/tools/pack200/SegmentLimit.java b/jdk/test/tools/pack200/SegmentLimit.java
deleted file mode 100644
index 249e47b032f..00000000000
--- a/jdk/test/tools/pack200/SegmentLimit.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @bug 6575373
- * @summary verify default segment limit
- * @compile SegmentLimit.java
- * @run main SegmentLimit
- */
-
-import java.io.BufferedReader;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-
-/*
- * Run this against a large jar file, by default the packer should generate only
- * one segment, parse the output of the packer to verify if this is indeed true.
- */
-
-public class SegmentLimit {
-
- private static final File javaHome = new File(System.getProperty("java.home"));
-
- public static void main(String... args) {
- if (!javaHome.getName().endsWith("jre")) {
- throw new RuntimeException("Error: requires an SDK to run");
- }
-
- File out = new File("test" + Pack200Test.PACKEXT);
- out.delete();
- runPack200(out);
- }
-
- static void close(Closeable c) {
- if (c == null) {
- return;
- }
- try {
- c.close();
- } catch (IOException ignore) {}
- }
-
- static void runPack200(File outFile) {
- File binDir = new File(javaHome, "bin");
- File pack200Exe = System.getProperty("os.name").startsWith("Windows")
- ? new File(binDir, "pack200.exe")
- : new File(binDir, "pack200");
- File sdkHome = javaHome.getParentFile();
- File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
-
- System.out.println("using pack200: " + pack200Exe.getAbsolutePath());
-
- String[] cmds = { pack200Exe.getAbsolutePath(),
- "--effort=1",
- "--verbose",
- "--no-gzip",
- outFile.getName(),
- testJar.getAbsolutePath()
- };
- InputStream is = null;
- BufferedReader br = null;
- InputStreamReader ir = null;
-
- FileOutputStream fos = null;
- PrintStream ps = null;
-
- try {
- ProcessBuilder pb = new ProcessBuilder(cmds);
- pb.redirectErrorStream(true);
- Process p = pb.start();
- is = p.getInputStream();
- ir = new InputStreamReader(is);
- br = new BufferedReader(ir);
-
- File logFile = new File("pack200.log");
- fos = new FileOutputStream(logFile);
- ps = new PrintStream(fos);
-
- String line = br.readLine();
- int count = 0;
- while (line != null) {
- line = line.trim();
- if (line.matches(".*Transmitted.*files of.*input bytes in a segment of.*bytes")) {
- count++;
- }
- ps.println(line);
- line=br.readLine();
- }
- p.waitFor();
- if (p.exitValue() != 0) {
- throw new RuntimeException("pack200 failed");
- }
- p.destroy();
- if (count > 1) {
- throw new Error("test fails: check for multiple segments(" +
- count + ") in: " + logFile.getAbsolutePath());
- }
- } catch (IOException ex) {
- throw new RuntimeException(ex.getMessage());
- } catch (InterruptedException ignore){
- } finally {
- close(is);
- close(ps);
- close(fos);
- }
- }
-}
-
diff --git a/jdk/test/tools/pack200/TimeStamp.java b/jdk/test/tools/pack200/TimeStamp.java
new file mode 100644
index 00000000000..3d099e2141c
--- /dev/null
+++ b/jdk/test/tools/pack200/TimeStamp.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.TimeZone;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+
+/*
+ * @test
+ * @bug 6966740
+ * @summary verify identical timestamps, unpacked in any timezone
+ * @compile -XDignore.symbol.file Utils.java TimeStamp.java
+ * @run main/othervm TimeStamp
+ * @author ksrini
+ */
+
+/**
+ * First we pack the file in some time zone say India, then we unpack the file
+ * in the current time zone, and ensure the timestamp recorded in the unpacked
+ * jar are the same.
+ */
+public class TimeStamp {
+ static final TimeZone tz = TimeZone.getDefault();
+
+
+ public static void main(String... args) throws IOException {
+
+ // make a local copy of our test file
+ File srcFile = Utils.locateJar("golden.jar");
+ File goldenFile = new File("golden.jar");
+ Utils.copyFile(srcFile, goldenFile.getAbsoluteFile());
+
+ JarFile goldenJarFile = new JarFile(goldenFile);
+ File packFile = new File("golden.pack");
+
+ // set the test timezone and pack the file
+ TimeZone.setDefault(TimeZone.getTimeZone("IST"));
+ Utils.pack(goldenJarFile, packFile);
+ TimeZone.setDefault(tz); // reset the timezone
+
+ // unpack in the test timezone
+ File istFile = new File("golden.jar.java.IST");
+ unpackJava(packFile, istFile);
+ verifyJar(goldenFile, istFile);
+ istFile.delete();
+
+ // unpack in some other timezone
+ File pstFile = new File("golden.jar.java.PST");
+ unpackJava(packFile, pstFile);
+ verifyJar(goldenFile, pstFile);
+ pstFile.delete();
+
+ // repeat the test for unpack200 tool.
+ istFile = new File("golden.jar.native.IST");
+ unpackNative(packFile, istFile);
+ verifyJar(goldenFile, istFile);
+ istFile.delete();
+
+ pstFile = new File("golden.jar.native.PST");
+ unpackNative(packFile, pstFile);
+ verifyJar(goldenFile, pstFile);
+ pstFile.delete();
+ }
+
+ static void unpackNative(File packFile, File outFile) {
+ String name = outFile.getName();
+ String tzname = name.substring(name.lastIndexOf(".") + 1);
+ HashMap env = new HashMap<>();
+ switch(tzname) {
+ case "PST":
+ env.put("TZ", "US/Pacific");
+ break;
+ case "IST":
+ env.put("TZ", "Asia/Calcutta");
+ break;
+ default:
+ throw new RuntimeException("not implemented: " + tzname);
+ }
+ List cmdsList = new ArrayList<>();
+ cmdsList.add(Utils.getUnpack200Cmd());
+ cmdsList.add(packFile.getName());
+ cmdsList.add(outFile.getName());
+ Utils.runExec(cmdsList, env);
+ }
+
+ static void unpackJava(File packFile, File outFile) throws IOException {
+ String name = outFile.getName();
+ String tzname = name.substring(name.lastIndexOf(".") + 1);
+ JarOutputStream jos = null;
+ try {
+ TimeZone.setDefault(TimeZone.getTimeZone(tzname));
+ jos = new JarOutputStream(new FileOutputStream(outFile));
+ System.out.println("Using timezone: " + TimeZone.getDefault());
+ Utils.unpackj(packFile, jos);
+ } finally {
+ Utils.close(jos);
+ TimeZone.setDefault(tz); // always reset
+ }
+ }
+
+ static void verifyJar(File f1, File f2) throws IOException {
+ int errors = 0;
+ JarFile jf1 = null;
+ JarFile jf2 = null;
+ try {
+ jf1 = new JarFile(f1);
+ jf2 = new JarFile(f2);
+ System.out.println("Verifying: " + f1 + " and " + f2);
+ for (JarEntry je1 : Collections.list(jf1.entries())) {
+ JarEntry je2 = jf2.getJarEntry(je1.getName());
+ if (je1.getTime() != je2.getTime()) {
+ System.out.println("Error:");
+ System.out.println(" expected:" + jf1.getName() + ":"
+ + je1.getName() + ":" + je1.getTime());
+ System.out.println(" obtained:" + jf2.getName() + ":"
+ + je2.getName() + ":" + je2.getTime());
+ errors++;
+ }
+ }
+ } finally {
+ Utils.close(jf1);
+ Utils.close(jf2);
+ }
+ if (errors > 0) {
+ throw new RuntimeException("FAIL:" + errors + " error(s) encounted");
+ }
+ }
+}
diff --git a/jdk/test/tools/pack200/UnpackerMemoryTest.java b/jdk/test/tools/pack200/UnpackerMemoryTest.java
new file mode 100644
index 00000000000..fc63d154f90
--- /dev/null
+++ b/jdk/test/tools/pack200/UnpackerMemoryTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6531345
+ * @summary check for unpacker memory leaks
+ * @compile -XDignore.symbol.file Utils.java UnpackerMemoryTest.java
+ * @run main/othervm/timeout=1200 -Xmx32m UnpackerMemoryTest
+ * @author ksrini
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.IOException;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+
+public class UnpackerMemoryTest {
+
+ private static void createPackFile(File packFile) throws IOException {
+ File tFile = new File("test.dat");
+ FileOutputStream fos = null;
+ PrintStream ps = null;
+ String jarFileName = Utils.baseName(packFile, Utils.PACK_FILE_EXT)
+ + Utils.JAR_FILE_EXT;
+ JarFile jarFile = null;
+ try {
+ fos = new FileOutputStream(tFile);
+ ps = new PrintStream(fos);
+ ps.println("A quick brown fox");
+ Utils.jar("cvf", jarFileName, tFile.getName());
+ jarFile = new JarFile(jarFileName);
+ Utils.pack(jarFile, packFile);
+ } finally {
+ Utils.close(ps);
+ tFile.delete();
+ Utils.close(jarFile);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ String name = "foo";
+ File packFile = new File(name + Utils.PACK_FILE_EXT);
+ createPackFile(packFile);
+ if (!packFile.exists()) {
+ throw new RuntimeException(packFile + " not found");
+ }
+ File jarOut = new File(name + ".out");
+ for (int i = 0; i < 2000; i++) {
+ JarOutputStream jarOS = null;
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(jarOut);
+ jarOS = new JarOutputStream(fos);
+ System.out.println("Unpacking[" + i + "]" + packFile);
+ Utils.unpackn(packFile, jarOS);
+ } finally {
+ Utils.close(jarOS);
+ Utils.close(fos);
+ }
+ }
+ }
+}
+
diff --git a/jdk/test/tools/pack200/Utils.java b/jdk/test/tools/pack200/Utils.java
new file mode 100644
index 00000000000..5cf7663d201
--- /dev/null
+++ b/jdk/test/tools/pack200/Utils.java
@@ -0,0 +1,516 @@
+/*
+ * Copyright (c) 2007, 2010 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ *
+ * @author ksrini
+ */
+
+/*
+ * This class contains all the commonly used utilities used by various tests
+ * in this directory.
+ */
+class Utils {
+ static final String JavaHome = System.getProperty("test.java",
+ System.getProperty("java.home"));
+ static final boolean IsWindows =
+ System.getProperty("os.name").startsWith("Windows");
+ static final boolean Is64Bit =
+ System.getProperty("sun.arch.data.model", "32").equals("64");
+ static final File JavaSDK = new File(JavaHome).getParentFile();
+
+ static final String PACK_FILE_EXT = ".pack";
+ static final String JAVA_FILE_EXT = ".java";
+ static final String CLASS_FILE_EXT = ".class";
+ static final String JAR_FILE_EXT = ".jar";
+
+ static final File TEST_SRC_DIR = new File(System.getProperty("test.src"));
+ static final String VERIFIER_DIR_NAME = "pack200-verifier";
+ static final File VerifierJar = new File(VERIFIER_DIR_NAME + JAR_FILE_EXT);
+
+ private Utils() {} // all static
+
+ static {
+ if (!JavaHome.endsWith("jre")) {
+ throw new RuntimeException("Error: requires an SDK to run");
+ }
+ }
+
+ private static void init() throws IOException {
+ if (VerifierJar.exists()) {
+ return;
+ }
+ File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
+ List javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT));
+ File tmpFile = File.createTempFile("javac", ".tmp");
+ File classesDir = new File("xclasses");
+ classesDir.mkdirs();
+ FileOutputStream fos = null;
+ PrintStream ps = null;
+ try {
+ fos = new FileOutputStream(tmpFile);
+ ps = new PrintStream(fos);
+ for (File f : javaFileList) {
+ ps.println(f.getAbsolutePath());
+ }
+ } finally {
+ close(ps);
+ close(fos);
+ }
+
+ compiler("-d",
+ "xclasses",
+ "@" + tmpFile.getAbsolutePath());
+
+ jar("cvfe",
+ VerifierJar.getName(),
+ "sun.tools.pack.verify.Main",
+ "-C",
+ "xclasses",
+ ".");
+ }
+
+ static void dirlist(File dir) {
+ File[] files = dir.listFiles();
+ System.out.println("--listing " + dir.getAbsolutePath() + "---");
+ for (File f : files) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(f.isDirectory() ? "d " : "- ");
+ sb.append(f.getName());
+ System.out.println(sb);
+ }
+ }
+ static void doCompareVerify(File reference, File specimen) throws IOException {
+ init();
+ List cmds = new ArrayList();
+ cmds.add(getJavaCmd());
+ cmds.add("-jar");
+ cmds.add(VerifierJar.getName());
+ cmds.add(reference.getAbsolutePath());
+ cmds.add(specimen.getAbsolutePath());
+ cmds.add("-O");
+ runExec(cmds);
+ }
+
+ static void doCompareBitWise(File reference, File specimen)
+ throws IOException {
+ init();
+ List cmds = new ArrayList();
+ cmds.add(getJavaCmd());
+ cmds.add("-jar");
+ cmds.add(VerifierJar.getName());
+ cmds.add(reference.getName());
+ cmds.add(specimen.getName());
+ cmds.add("-O");
+ cmds.add("-b");
+ runExec(cmds);
+ }
+
+ static FileFilter createFilter(final String extension) {
+ return new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ String name = pathname.getName();
+ if (name.endsWith(extension)) {
+ return true;
+ }
+ return false;
+ }
+ };
+ }
+
+ static final FileFilter DIR_FILTER = new FileFilter() {
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory()) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ static final FileFilter FILE_FILTER = new FileFilter() {
+ public boolean accept(File pathname) {
+ if (pathname.isFile()) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ private static void setFileAttributes(File src, File dst) throws IOException {
+ dst.setExecutable(src.canExecute());
+ dst.setReadable(src.canRead());
+ dst.setWritable(src.canWrite());
+ dst.setLastModified(src.lastModified());
+ }
+
+ static void copyFile(File src, File dst) throws IOException {
+ if (src.isDirectory()) {
+ dst.mkdirs();
+ setFileAttributes(src, dst);
+ return;
+ } else {
+ File baseDirFile = dst.getParentFile();
+ if (!baseDirFile.exists()) {
+ baseDirFile.mkdirs();
+ }
+ }
+ FileInputStream in = null;
+ FileOutputStream out = null;
+ FileChannel srcChannel = null;
+ FileChannel dstChannel = null;
+ try {
+ in = new FileInputStream(src);
+ out = new FileOutputStream(dst);
+ srcChannel = in.getChannel();
+ dstChannel = out.getChannel();
+
+ long retval = srcChannel.transferTo(0, src.length(), dstChannel);
+ if (src.length() != dst.length()) {
+ throw new IOException("file copy failed for " + src);
+ }
+ } finally {
+ close(srcChannel);
+ close(dstChannel);
+ close(in);
+ close(out);
+ }
+ setFileAttributes(src, dst);
+ }
+
+ static String baseName(File file, String extension) {
+ return baseName(file.getAbsolutePath(), extension);
+ }
+
+ static String baseName(String name, String extension) {
+ int cut = name.length() - extension.length();
+ return name.lastIndexOf(extension) == cut
+ ? name.substring(0, cut)
+ : name;
+
+ }
+
+ /*
+ * Suppose a path is provided which consists of a full path
+ * this method returns the sub path for a full path ex: /foo/bar/baz/foobar.z
+ * and the base path is /foo/bar it will will return baz/foobar.z.
+ */
+ private static String getEntryPath(String basePath, String fullPath) {
+ if (!fullPath.startsWith(basePath)) {
+ return null;
+ }
+ return fullPath.substring(basePath.length());
+ }
+
+ static String getEntryPath(File basePathFile, File fullPathFile) {
+ return getEntryPath(basePathFile.toString(), fullPathFile.toString());
+ }
+
+ public static void recursiveCopy(File src, File dest) throws IOException {
+ if (!src.exists() || !src.canRead()) {
+ throw new IOException("file not found or readable: " + src);
+ }
+ if (dest.exists() && !dest.isDirectory() && !dest.canWrite()) {
+ throw new IOException("file not found or writeable: " + dest);
+ }
+ if (!dest.exists()) {
+ dest.mkdirs();
+ }
+ List a = directoryList(src);
+ for (File f : a) {
+ copyFile(f, new File(dest, getEntryPath(src, f)));
+ }
+ }
+
+ static List directoryList(File dirname) {
+ List dirList = new ArrayList();
+ return directoryList(dirname, dirList, null);
+ }
+
+ private static List directoryList(File dirname, List dirList,
+ File[] dirs) {
+ dirList.addAll(Arrays.asList(dirname.listFiles(FILE_FILTER)));
+ dirs = dirname.listFiles(DIR_FILTER);
+ for (File f : dirs) {
+ if (f.isDirectory() && !f.equals(dirname)) {
+ dirList.add(f);
+ directoryList(f, dirList, dirs);
+ }
+ }
+ return dirList;
+ }
+
+ static void recursiveDelete(File dir) throws IOException {
+ if (dir.isFile()) {
+ dir.delete();
+ } else if (dir.isDirectory()) {
+ File[] entries = dir.listFiles();
+ for (int i = 0; i < entries.length; i++) {
+ if (entries[i].isDirectory()) {
+ recursiveDelete(entries[i]);
+ }
+ entries[i].delete();
+ }
+ dir.delete();
+ }
+ }
+
+ static List findFiles(File startDir, FileFilter filter)
+ throws IOException {
+ List list = new ArrayList();
+ findFiles0(startDir, list, filter);
+ return list;
+ }
+ /*
+ * finds files in the start directory using the the filter, appends
+ * the files to the dirList.
+ */
+ private static void findFiles0(File startDir, List list,
+ FileFilter filter) throws IOException {
+ File[] foundFiles = startDir.listFiles(filter);
+ list.addAll(Arrays.asList(foundFiles));
+ File[] dirs = startDir.listFiles(DIR_FILTER);
+ for (File dir : dirs) {
+ findFiles0(dir, list, filter);
+ }
+ }
+
+ static void close(Closeable c) {
+ if (c == null) {
+ return;
+ }
+ try {
+ c.close();
+ } catch (IOException ignore) {
+ }
+ }
+
+ static void compiler(String... javacCmds) {
+ if (com.sun.tools.javac.Main.compile(javacCmds) != 0) {
+ throw new RuntimeException("compilation failed");
+ }
+ }
+
+ static void jar(String... jargs) {
+ sun.tools.jar.Main jarTool =
+ new sun.tools.jar.Main(System.out, System.err, "jartool");
+ if (!jarTool.run(jargs)) {
+ throw new RuntimeException("jar command failed");
+ }
+ }
+
+ // given a jar file foo.jar will write to foo.pack
+ static void pack(JarFile jarFile, File packFile) throws IOException {
+ Pack200.Packer packer = Pack200.newPacker();
+ Map p = packer.properties();
+ // Take the time optimization vs. space
+ p.put(packer.EFFORT, "1"); // CAUTION: do not use 0.
+ // Make the memory consumption as effective as possible
+ p.put(packer.SEGMENT_LIMIT, "10000");
+ // ignore all JAR deflation requests to save time
+ p.put(packer.DEFLATE_HINT, packer.FALSE);
+ // save the file ordering of the original JAR
+ p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
+ FileOutputStream fos = null;
+ try {
+ // Write out to a jtreg scratch area
+ fos = new FileOutputStream(packFile);
+ // Call the packer
+ packer.pack(jarFile, fos);
+ } finally {
+ close(fos);
+ }
+ }
+
+ // uses java unpacker, slow but useful to discover issues with the packer
+ static void unpackj(File inFile, JarOutputStream jarStream)
+ throws IOException {
+ unpack0(inFile, jarStream, true);
+
+ }
+
+ // uses native unpacker using the java APIs
+ static void unpackn(File inFile, JarOutputStream jarStream)
+ throws IOException {
+ unpack0(inFile, jarStream, false);
+ }
+
+ // given a packed file, create the jar file in the current directory.
+ private static void unpack0(File inFile, JarOutputStream jarStream,
+ boolean useJavaUnpack) throws IOException {
+ // Unpack the files
+ Pack200.Unpacker unpacker = Pack200.newUnpacker();
+ Map props = unpacker.properties();
+ if (useJavaUnpack) {
+ props.put("com.sun.java.util.jar.pack.disable.native", "true");
+ }
+ // Call the unpacker
+ unpacker.unpack(inFile, jarStream);
+ }
+
+ static byte[] getBuffer(ZipFile zf, ZipEntry ze) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte buf[] = new byte[8192];
+ InputStream is = null;
+ try {
+ is = zf.getInputStream(ze);
+ int n = is.read(buf);
+ while (n > 0) {
+ baos.write(buf, 0, n);
+ n = is.read(buf);
+ }
+ return baos.toByteArray();
+ } finally {
+ close(is);
+ }
+ }
+
+ static ArrayList getZipFileEntryNames(ZipFile z) {
+ ArrayList out = new ArrayList();
+ for (ZipEntry ze : Collections.list(z.entries())) {
+ out.add(ze.getName());
+ }
+ return out;
+ }
+ static List runExec(List