From aph at redhat.com Mon Oct 6 04:49:57 2008 From: aph at redhat.com (Andrew Haley) Date: Mon, 06 Oct 2008 12:49:57 +0100 Subject: preparing a icedtea-1.3 release? In-Reply-To: <48E0DBF8.7070804@redhat.com> References: <48DFA75E.6080906@ubuntu.com> <1222636644.3271.10.camel@dijkstra.wildebeest.org> <20080928212527.GA7083@rivendell.middle-earth.co.uk> <48E0DBF8.7070804@redhat.com> Message-ID: <48E9FB65.7070504@redhat.com> Lillian Angel wrote: > Andrew John Hughes wrote: >> On 23:17 Sun 28 Sep , Mark Wielaard wrote: >>> Hi, >>> >>> On Sun, 2008-09-28 at 17:48 +0200, Matthias Klose wrote: >>>> The last icedtea release 1.2 (bases on b09) was four months ago. I >>>> would like to >>>> prepare a 1.3 release based ob b12. are there currently outstanding >>>> issues? >>> Good idea. There have been lots of improvements since the last official >>> 1.2 release. Including various security and crasher issues, that we >>> really should make sure are picked up by the various distros. >>> >> >> Lillian already mentioned she is working on this in her blog. >> >> http://langel.wordpress.com/2008/09/24/women-in-foss/ >> >> This really should have been sent to distro-pkg-dev as well. > > I have been waiting for the PulseAudio and LiveConnect work before going > ahead with a release. Is everyone ok with waiting for these? Yes. I think it's much better to go with a release when these significant features are added rather than at a fixed time interval. Andrew. From Daniel.Fuchs at Sun.COM Thu Oct 9 03:34:52 2008 From: Daniel.Fuchs at Sun.COM (Daniel Fuchs) Date: Thu, 09 Oct 2008 12:34:52 +0200 Subject: Patches for 6616825, 6651382, 6756202... Message-ID: <48EDDE4C.3070900@sun.com> Hi guys, I have pushed these three patches to our internal OpenJDK 6 workspace yesterday. 6756202: OpenJDK 6 JMX Netbeans projects refers to OpenJDK 7 version of JMX and JDK 6651382: The Java JVM SNMP provider reports incorrect stats when asked for multiple OIDs 6616825: JMX query returns no value in 1.0 compatibility mode - deserialization bug in readObject() I believe they will make it in b13. Best regards, -- daniel http://blogs.sun.com/jmxetc -------------- next part -------------- A non-text attachment was scrubbed... Name: 6open-6616825.patch Type: text/x-patch Size: 11848 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081009/7974d49d/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 6open-6651382.patch Type: text/x-patch Size: 3950 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081009/7974d49d/attachment-0001.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 6open-6756202.patch Type: text/x-patch Size: 730 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081009/7974d49d/attachment-0002.bin From aph at redhat.com Fri Oct 10 03:40:56 2008 From: aph at redhat.com (Andrew Haley) Date: Fri, 10 Oct 2008 11:40:56 +0100 Subject: preparing a icedtea-1.3 release? In-Reply-To: <48DFA75E.6080906@ubuntu.com> References: <48DFA75E.6080906@ubuntu.com> Message-ID: <48EF3138.8060709@redhat.com> Matthias Klose wrote: > The last icedtea release 1.2 (bases on b09) was four months ago. I would like to > prepare a 1.3 release based ob b12. are there currently outstanding issues? > > - general? > - cacao? > - icedtea plugin? > - zero/shark? > > If possible I aim for a release candidate for the next weekend and for a final > release in about two weeks. I think we're nearly ready to go. We're stabilizing PulseAudio support and LiveConnect and doing some testing. Lillian Angel has said that she intends to have 1.3 done and TCK tested between Oct 14-17. I'm running TCK tests today on the current development sources and I'll let you know the results. I'll let Deepak reply re LiveConnect status. Andrew. From Joe.Darcy at Sun.COM Wed Oct 15 10:59:19 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Wed, 15 Oct 2008 10:59:19 -0700 Subject: Patches for OpenJDK 6 build 13 fixes in sound, langtools Message-ID: <48F62F77.6090903@sun.com> Hello. OpenJDK 6 build 13 is gathering fixes; here are patches for fixes I've put back recently. I've applied the patch from http://mail.openjdk.java.net/pipermail/sound-dev/2008-September/000075.html to fix 6748247 Further update Gervill with still more post 1.0 fixes 6748251 Apply IcedTea midi sound patch Subsequently, I've also applied another fix from the Gervill CVS repository: 6758986 Gervill: Turn SoftJitterCorrector, SoftAudioPusher threads into a daemon threads One of the failing langtools tests should now pass: 6707027 langtools/test/tools/javac/processing/model/testgetallmember/Main.java fails and in preparation for being able to run the langtools regression tests faster, I've applied Jon's fix for 6749967 regression tests for apt should be same-vm friendly -Joe -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 6758986.patch Url: http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081015/e7cbf1f3/attachment.ksh -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 6707027.patch Url: http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081015/e7cbf1f3/attachment-0001.ksh -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 6749967.patch Url: http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081015/e7cbf1f3/attachment-0002.ksh From Joe.Darcy at Sun.COM Wed Oct 15 16:49:22 2008 From: Joe.Darcy at Sun.COM (Joe Darcy) Date: Wed, 15 Oct 2008 16:49:22 -0700 Subject: OpenJDK 6 build 13: patches for tests moved over from the closed to open area Message-ID: <48F68182.9040106@sun.com> Hello. For OpenJDK 6 build 13, I've moved some tests in areas I've worked on from the closed (Sun-internal) part of the test tree to the open part: 6601457 Move wrapper class tests from closed to open 6759433 Move Math and StrictMath regression tests from closed to open 6740185 Move java/lang/annotations tests to open Compressed patches to add the GPL-licensed test files attached. -Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: 6601457.patch.gz Type: application/x-gzip Size: 18369 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081015/20eab4d3/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 6759433.patch.gz Type: application/x-gzip Size: 77574 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081015/20eab4d3/attachment-0001.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 6740185.patch.gz Type: application/x-gzip Size: 25781 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081015/20eab4d3/attachment-0002.bin From martinrb at google.com Thu Oct 16 12:46:05 2008 From: martinrb at google.com (Martin Buchholz) Date: Thu, 16 Oct 2008 12:46:05 -0700 Subject: SecurityException in AnnotationInvocationHandler.getMemberMethods Message-ID: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> Hi all, This is a bug report with fix. Joe Darcy, please file a bug and review this change, and perhaps provide a small test case (it is impractical to share the test we have at Google). Description: sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods might throw if there is a security manager that does not allow getDeclaredMethods. The author of this code (Josh Bloch) confirms that the intent was for the doPrivileged block in this method to prevent security exceptions. The methods cannot escape to untrusted code. Evaluation: Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. # HG changeset patch # User martin # Date 1224185752 25200 # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 SecurityException in AnnotationInvocationHandler.getMemberMethods Summary: Move call to getDeclaredMethods inside doPrivileged Reviewed-by: Contributed-by: jjb at google.com diff --git a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java --- a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java +++ b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java @@ -272,14 +272,14 @@ */ private Method[] getMemberMethods() { if (memberMethods == null) { - final Method[] mm = type.getDeclaredMethods(); - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - AccessibleObject.setAccessible(mm, true); - return null; - } - }); - memberMethods = mm; + memberMethods = AccessController.doPrivileged( + new PrivilegedAction() { + public Method[] run() { + final Method[] mm = type.getDeclaredMethods(); + AccessibleObject.setAccessible(mm, true); + return mm; + } + }); } return memberMethods; } From martinrb at google.com Thu Oct 16 17:23:03 2008 From: martinrb at google.com (Martin Buchholz) Date: Thu, 16 Oct 2008 17:23:03 -0700 Subject: JNI crashes in FontManager code Message-ID: <1ccfd1c10810161723m54dfb7dar8a38bdde2aec196b@mail.gmail.com> Hi font maintainers, This is a bug report, with fix, provided by Hiroshi Yamauchi. This is a crash detected by a google test (which is unfortunately impractical to share) which makes this at least a P2 bug. Description: Fixing the bad JNI code in the font manager code. Two issues: o The JNIEnv is unique to the thread. It cannot be saved by one thread and reused by another. Use GetEnv instead. o The 'font2D' jobject needs to be converted into a global reference because its lifetime exceeds the lifetime of a native method call. Evaluation: Appropriately register/free everything with the garbage collector. Fix: # HG changeset patch # User martin # Date 1224202830 25200 # Node ID 3c9d6001d8a90698a3540a2a483717f26a98db78 # Parent 68730f05449cd4f39ce1cb82adc6c4e57f87554f Crash in freetypeScaler.c due to insufficient GC protection Summary: NewGlobalRef/DeleteGlobalRef as needed. Reviewed-by: Contributed-by: yamauchi at google.com diff --git a/make/sun/font/mapfile-vers.openjdk b/make/sun/font/mapfile-vers.openjdk --- a/make/sun/font/mapfile-vers.openjdk +++ b/make/sun/font/mapfile-vers.openjdk @@ -29,6 +29,7 @@ SUNWprivate_1.1 { global: + JNI_OnLoad; getSunFontIDs; newLayoutTableCache; freeLayoutTableCache; diff --git a/src/share/native/sun/font/freetypeScaler.c b/src/share/native/sun/font/freetypeScaler.c --- a/src/share/native/sun/font/freetypeScaler.c +++ b/src/share/native/sun/font/freetypeScaler.c @@ -48,16 +48,6 @@ #define ROUND(x) ((int) (x+0.5)) typedef struct { - /* Important note: - JNI forbids sharing same env between different threads. - We are safe, because pointer is overwritten every time we get into - JNI call (see setupFTContext). - - Pointer is used by font data reading callbacks - such as ReadTTFontFileFunc. - - NB: We may consider switching to JNI_GetEnv. */ - JNIEnv* env; FT_Library library; FT_Face face; jobject font2D; @@ -90,6 +80,13 @@ void z_error(char *s) {} #endif +static JavaVM* jvm = NULL; + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { + jvm = vm; + return JNI_VERSION_1_2; +} + /**************** Error handling utilities *****************/ static jmethodID invalidateScalerMID; @@ -107,6 +104,10 @@ FT_Done_Face(scalerInfo->face); FT_Done_FreeType(scalerInfo->library); + + if (scalerInfo->font2D != NULL) { + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); + } if (scalerInfo->directBuffer != NULL) { (*env)->DeleteGlobalRef(env, scalerInfo->directBuffer); @@ -131,10 +132,9 @@ #define FILEDATACACHESIZE 1024 -/* NB: is it ever called? */ static void CloseTTFontFileFunc(FT_Stream stream) { + JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2); FTScalerInfo *scalerInfo = (FTScalerInfo *) stream->pathname.pointer; - JNIEnv* env = scalerInfo->env; jclass tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont"); jfieldID platNameField = (*env)->GetFieldID(env, tmpClass, "platName", "Ljava/lang/String;"); @@ -150,8 +150,8 @@ unsigned char* destBuffer, unsigned long numBytes) { + JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2); FTScalerInfo *scalerInfo = (FTScalerInfo *) stream->pathname.pointer; - JNIEnv* env = scalerInfo->env; jobject bBuffer; int bread = 0; @@ -245,8 +245,7 @@ if (scalerInfo == NULL) return 0; - scalerInfo->env = env; - scalerInfo->font2D = font2D; + scalerInfo->font2D = (*env)->NewGlobalRef(env, font2D); scalerInfo->fontDataOffset = 0; scalerInfo->fontDataLength = 0; scalerInfo->fileSize = filesize; @@ -263,6 +262,7 @@ */ error = FT_Init_FreeType(&scalerInfo->library); if (error) { + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); free(scalerInfo); return 0; } @@ -331,6 +331,7 @@ } if (scalerInfo->fontData != NULL) free(scalerInfo->fontData); + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); free(scalerInfo); return 0; } @@ -391,8 +392,10 @@ FTScalerContext *context) { int errCode = 0; - scalerInfo->env = env; - scalerInfo->font2D = font2D; + if (scalerInfo->font2D != NULL) { + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); + } + scalerInfo->font2D = (*env)->NewGlobalRef(env, font2D); FT_Set_Transform(scalerInfo->face, &context->transform, NULL); From Joe.Darcy at Sun.COM Fri Oct 17 09:34:34 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Fri, 17 Oct 2008 09:34:34 -0700 Subject: OpenJDK 6 build 12 source posted (directaudio/alsa backend) In-Reply-To: <1222690203.3529.2.camel@dijkstra.wildebeest.org> References: <48CAB08F.6010407@sun.com> <1221402124.3542.40.camel@dijkstra.wildebeest.org> <48D7F80E.6060802@sun.com> <1222164525.3178.48.camel@dijkstra.wildebeest.org> <48D8EB31.60004@sun.com> <1222376952.3266.94.camel@dijkstra.wildebeest.org> <48DD309F.2000206@sun.com> <48E0B14C.4000107@sun.com> <1222690203.3529.2.camel@dijkstra.wildebeest.org> Message-ID: <48F8BE9A.9080101@sun.com> Mark Wielaard wrote: > Hi Alex, > > On Mon, 2008-09-29 at 14:43 +0400, Alex Menkov wrote: > >> Yes, the plan is to drop JavaSound encumbered code from JDK7 (and add Gervill). >> I still have no all required approvals for integrate Gervill into JDK7 :( >> > > Who are you waiting for to get approval and where is this being > discussed? What are the differences in required approvals needed for 6 > and 7? > > Thanks, > > Mark > > After some double checking with our friends in Sun's legal department, the required approvals for using Gervill in JDK 7 were already granted; so only a small matter of programming stands between Gervill and JDK 7 :-) -Joe From Joe.Darcy at Sun.COM Mon Oct 20 15:58:21 2008 From: Joe.Darcy at Sun.COM (Joe Darcy) Date: Mon, 20 Oct 2008 15:58:21 -0700 Subject: Patch to whitespace normalize OpenJDK 6 langtools Message-ID: <48FD0D0D.6050601@sun.com> Attached is a large compressed patch to whitespace normalize the OpenJDK 6 langtools area, fixing Sun bug 6760834 Normalized whitespace of langtools area for OpenJDK 6 -Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: 6760834.patch.gz Type: application/x-gzip Size: 905735 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081020/7c2a36a8/attachment.bin From Joe.Darcy at Sun.COM Mon Oct 20 18:59:09 2008 From: Joe.Darcy at Sun.COM (Joe Darcy) Date: Mon, 20 Oct 2008 18:59:09 -0700 Subject: SecurityException in AnnotationInvocationHandler.getMemberMethods In-Reply-To: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> References: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> Message-ID: <48FD376D.9080105@sun.com> Hello. On 10/16/08 12:46 PM, Martin Buchholz wrote: > Hi all, > > This is a bug report with fix. > Joe Darcy, please file a bug and review this change, > I've filed 6761678 "(ann) SecurityException in AnnotationInvocationHandler.getMemberMethods" for this issue. The problem seems similar to 6370080 "(ann) Method.getAnnotations() sometimes throw SecurityException: doPrivileged or javadoc missing?," which was fixed in JDK 6 and a JDK 5 update release. Martin, can you, Toby, and Josh review any other uses of reflection in the src/share/classes/sun/reflect/annotation package for similar problems so we can address any other such issues now? I've looked over the change and the use of getMemberMethods in equalsImpl and don't see a problem. However, I'd like the security team to give it a once over too; security-dev folk, please take a look at this. Thanks, -Joe > and perhaps provide a small test case (it is impractical > to share the test we have at Google). > > Description: > > sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods > might throw if there is a security manager that does not allow > getDeclaredMethods. > > The author of this code (Josh Bloch) confirms that the intent was for the > doPrivileged block in this method to prevent security exceptions. > The methods cannot escape to untrusted code. > > Evaluation: > > Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. > > # HG changeset patch > # User martin > # Date 1224185752 25200 > # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f > # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 > SecurityException in AnnotationInvocationHandler.getMemberMethods > Summary: Move call to getDeclaredMethods inside doPrivileged > Reviewed-by: > Contributed-by: jjb at google.com > > diff --git a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java > b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java > --- a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java > +++ b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java > @@ -272,14 +272,14 @@ > */ > private Method[] getMemberMethods() { > if (memberMethods == null) { > - final Method[] mm = type.getDeclaredMethods(); > - AccessController.doPrivileged(new PrivilegedAction() { > - public Void run() { > - AccessibleObject.setAccessible(mm, true); > - return null; > - } > - }); > - memberMethods = mm; > + memberMethods = AccessController.doPrivileged( > + new PrivilegedAction() { > + public Method[] run() { > + final Method[] mm = type.getDeclaredMethods(); > + AccessibleObject.setAccessible(mm, true); > + return mm; > + } > + }); > } > return memberMethods; > } > From Joe.Darcy at Sun.COM Mon Oct 20 19:01:23 2008 From: Joe.Darcy at Sun.COM (Joe Darcy) Date: Mon, 20 Oct 2008 19:01:23 -0700 Subject: SecurityException in AnnotationInvocationHandler.getMemberMethods In-Reply-To: <48FD376D.9080105@sun.com> References: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> <48FD376D.9080105@sun.com> Message-ID: <48FD37F3.9070208@sun.com> PS Martin, I haven't written tests that setup and use a security manager, etc., that should go along with this fix. Having a stand-alone regression test along those lines would be helpful. Thanks, -Joe On 10/20/08 06:59 PM, Joe Darcy wrote: > Hello. > > On 10/16/08 12:46 PM, Martin Buchholz wrote: >> Hi all, >> >> This is a bug report with fix. >> Joe Darcy, please file a bug and review this change, >> > > I've filed 6761678 "(ann) SecurityException in > AnnotationInvocationHandler.getMemberMethods" for this issue. The > problem seems similar to 6370080 "(ann) Method.getAnnotations() > sometimes throw SecurityException: doPrivileged or javadoc missing?," > which was fixed in JDK 6 and a JDK 5 update release. > > Martin, can you, Toby, and Josh review any other uses of reflection in > the src/share/classes/sun/reflect/annotation package for similar > problems so we can address any other such issues now? > > I've looked over the change and the use of getMemberMethods in > equalsImpl and don't see a problem. However, I'd like the security > team to give it a once over too; security-dev folk, please take a look > at this. > > Thanks, > > -Joe >> and perhaps provide a small test case (it is impractical >> to share the test we have at Google). >> >> Description: >> >> sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods >> might throw if there is a security manager that does not allow >> getDeclaredMethods. >> >> The author of this code (Josh Bloch) confirms that the intent was for >> the >> doPrivileged block in this method to prevent security exceptions. >> The methods cannot escape to untrusted code. >> >> Evaluation: >> >> Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. >> >> # HG changeset patch >> # User martin >> # Date 1224185752 25200 >> # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f >> # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 >> SecurityException in AnnotationInvocationHandler.getMemberMethods >> Summary: Move call to getDeclaredMethods inside doPrivileged >> Reviewed-by: >> Contributed-by: jjb at google.com >> >> diff --git >> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> --- >> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> +++ >> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> @@ -272,14 +272,14 @@ >> */ >> private Method[] getMemberMethods() { >> if (memberMethods == null) { >> - final Method[] mm = type.getDeclaredMethods(); >> - AccessController.doPrivileged(new >> PrivilegedAction() { >> - public Void run() { >> - AccessibleObject.setAccessible(mm, true); >> - return null; >> - } >> - }); >> - memberMethods = mm; >> + memberMethods = AccessController.doPrivileged( >> + new PrivilegedAction() { >> + public Method[] run() { >> + final Method[] mm = type.getDeclaredMethods(); >> + AccessibleObject.setAccessible(mm, true); >> + return mm; >> + } >> + }); >> } >> return memberMethods; >> } >> > From Sean.Mullan at Sun.COM Tue Oct 21 13:12:12 2008 From: Sean.Mullan at Sun.COM (Sean Mullan) Date: Tue, 21 Oct 2008 16:12:12 -0400 Subject: [security-dev 00357]: Re: SecurityException in AnnotationInvocationHandler.getMemberMethods In-Reply-To: <48FD376D.9080105@sun.com> References: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> <48FD376D.9080105@sun.com> Message-ID: <48FE379C.30200@sun.com> I looked at the code changes and it seems fine to me. --Sean Joe Darcy wrote: > Hello. > > On 10/16/08 12:46 PM, Martin Buchholz wrote: >> Hi all, >> >> This is a bug report with fix. >> Joe Darcy, please file a bug and review this change, >> > > I've filed 6761678 "(ann) SecurityException in > AnnotationInvocationHandler.getMemberMethods" for this issue. The > problem seems similar to 6370080 "(ann) Method.getAnnotations() > sometimes throw SecurityException: doPrivileged or javadoc missing?," > which was fixed in JDK 6 and a JDK 5 update release. > > Martin, can you, Toby, and Josh review any other uses of reflection in > the src/share/classes/sun/reflect/annotation package for similar > problems so we can address any other such issues now? > > I've looked over the change and the use of getMemberMethods in > equalsImpl and don't see a problem. However, I'd like the security team > to give it a once over too; security-dev folk, please take a look at this. > > Thanks, > > -Joe >> and perhaps provide a small test case (it is impractical >> to share the test we have at Google). >> >> Description: >> >> sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods >> might throw if there is a security manager that does not allow >> getDeclaredMethods. >> >> The author of this code (Josh Bloch) confirms that the intent was for the >> doPrivileged block in this method to prevent security exceptions. >> The methods cannot escape to untrusted code. >> >> Evaluation: >> >> Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. >> >> # HG changeset patch >> # User martin >> # Date 1224185752 25200 >> # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f >> # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 >> SecurityException in AnnotationInvocationHandler.getMemberMethods >> Summary: Move call to getDeclaredMethods inside doPrivileged >> Reviewed-by: >> Contributed-by: jjb at google.com >> >> diff --git >> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> --- >> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> +++ >> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >> >> @@ -272,14 +272,14 @@ >> */ >> private Method[] getMemberMethods() { >> if (memberMethods == null) { >> - final Method[] mm = type.getDeclaredMethods(); >> - AccessController.doPrivileged(new PrivilegedAction() { >> - public Void run() { >> - AccessibleObject.setAccessible(mm, true); >> - return null; >> - } >> - }); >> - memberMethods = mm; >> + memberMethods = AccessController.doPrivileged( >> + new PrivilegedAction() { >> + public Method[] run() { >> + final Method[] mm = type.getDeclaredMethods(); >> + AccessibleObject.setAccessible(mm, true); >> + return mm; >> + } >> + }); >> } >> return memberMethods; >> } >> > From martinrb at google.com Tue Oct 21 17:58:33 2008 From: martinrb at google.com (Martin Buchholz) Date: Tue, 21 Oct 2008 17:58:33 -0700 Subject: SecurityException in AnnotationInvocationHandler.getMemberMethods In-Reply-To: <48FD37F3.9070208@sun.com> References: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> <48FD376D.9080105@sun.com> <48FD37F3.9070208@sun.com> Message-ID: <1ccfd1c10810211758u10bfbbf7j2b8b4fcfb050ef20@mail.gmail.com> If I had known when I started how hard it would be, I would never have started writing one... Where are annotations tests supposed to go? They seem under-test-covered. I've put it into a new directory, test/java/lang/annotation Please review. The following fails with current openjdk, passes with proposed fix. /* * Copyright 2008 Sun Microsystems, Inc. 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 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. */ /* * @test * @bug 6761678 * @summary Check properties of Annotations returned from * getParameterAnnotations, including freedom from security * exceptions. * @author Martin Buchholz */ import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; import java.security.Permission; import java.security.Policy; import java.security.ProtectionDomain; @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD, ElementType.PARAMETER }) @interface Named { String value(); } public class ParameterAnnotations { // A security policy that differs from the default only in that it // allows a security manager to be uninstalled. static class MyPolicy extends Policy { final Policy defaultPolicy; MyPolicy(Policy defaultPolicy) { this.defaultPolicy = defaultPolicy; } public boolean implies(ProtectionDomain pd, Permission p) { return p.getName().equals("setSecurityManager") || defaultPolicy.implies(pd, p); } } public void nop(@Named("foo") Object foo, @Named("bar") Object bar) { } void test(String[] args) throws Throwable { // Test without a security manager test1(); // Test with a security manager Policy defaultPolicy = Policy.getPolicy(); Policy.setPolicy(new MyPolicy(defaultPolicy)); System.setSecurityManager(new SecurityManager()); try { test1(); } finally { System.setSecurityManager(null); Policy.setPolicy(defaultPolicy); } } void test1() throws Throwable { for (Method m : thisClass.getMethods()) { if (m.getName().equals("nop")) { Annotation[][] ann = m.getParameterAnnotations(); equal(ann.length, 2); Annotation foo = ann[0][0]; Annotation bar = ann[1][0]; equal(foo.toString(), "@Named(value=foo)"); equal(bar.toString(), "@Named(value=bar)"); check(foo.equals(foo)); check(! foo.equals(bar)); } } } //--------------------- Infrastructure --------------------------- volatile int passed = 0, failed = 0; void pass() {passed++;} void fail() {failed++; Thread.dumpStack();} void fail(String msg) {System.err.println(msg); fail();} void unexpected(Throwable t) {failed++; t.printStackTrace();} void check(boolean cond) {if (cond) pass(); else fail();} void equal(Object x, Object y) { if (x == null ? y == null : x.equals(y)) pass(); else fail(x + " not equal to " + y);} static Class thisClass = new Object(){}.getClass().getEnclosingClass(); public static void main(String[] args) throws Throwable { try {thisClass.getMethod("instanceMain",String[].class) .invoke(thisClass.newInstance(), (Object) args);} catch (Throwable e) {throw e.getCause();}} public void instanceMain(String[] args) throws Throwable { try {test(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} } Martin On Mon, Oct 20, 2008 at 19:01, Joe Darcy wrote: > PS Martin, I haven't written tests that setup and use a security manager, > etc., that should go along with this fix. Having a stand-alone regression > test along those lines would be helpful. > > Thanks, > > -Joe > > On 10/20/08 06:59 PM, Joe Darcy wrote: >> >> Hello. >> >> On 10/16/08 12:46 PM, Martin Buchholz wrote: >>> >>> Hi all, >>> >>> This is a bug report with fix. >>> Joe Darcy, please file a bug and review this change, >>> >> >> I've filed 6761678 "(ann) SecurityException in >> AnnotationInvocationHandler.getMemberMethods" for this issue. The problem >> seems similar to 6370080 "(ann) Method.getAnnotations() sometimes throw >> SecurityException: doPrivileged or javadoc missing?," which was fixed in JDK >> 6 and a JDK 5 update release. >> >> Martin, can you, Toby, and Josh review any other uses of reflection in the >> src/share/classes/sun/reflect/annotation package for similar problems so we >> can address any other such issues now? >> >> I've looked over the change and the use of getMemberMethods in equalsImpl >> and don't see a problem. However, I'd like the security team to give it a >> once over too; security-dev folk, please take a look at this. >> >> Thanks, >> >> -Joe >>> >>> and perhaps provide a small test case (it is impractical >>> to share the test we have at Google). >>> >>> Description: >>> >>> sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods >>> might throw if there is a security manager that does not allow >>> getDeclaredMethods. >>> >>> The author of this code (Josh Bloch) confirms that the intent was for the >>> doPrivileged block in this method to prevent security exceptions. >>> The methods cannot escape to untrusted code. >>> >>> Evaluation: >>> >>> Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. >>> >>> # HG changeset patch >>> # User martin >>> # Date 1224185752 25200 >>> # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f >>> # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 >>> SecurityException in AnnotationInvocationHandler.getMemberMethods >>> Summary: Move call to getDeclaredMethods inside doPrivileged >>> Reviewed-by: >>> Contributed-by: jjb at google.com >>> >>> diff --git >>> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>> >>> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>> --- >>> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>> +++ >>> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>> @@ -272,14 +272,14 @@ >>> */ >>> private Method[] getMemberMethods() { >>> if (memberMethods == null) { >>> - final Method[] mm = type.getDeclaredMethods(); >>> - AccessController.doPrivileged(new PrivilegedAction() { >>> - public Void run() { >>> - AccessibleObject.setAccessible(mm, true); >>> - return null; >>> - } >>> - }); >>> - memberMethods = mm; >>> + memberMethods = AccessController.doPrivileged( >>> + new PrivilegedAction() { >>> + public Method[] run() { >>> + final Method[] mm = type.getDeclaredMethods(); >>> + AccessibleObject.setAccessible(mm, true); >>> + return mm; >>> + } >>> + }); >>> } >>> return memberMethods; >>> } >>> >> > > From Joe.Darcy at Sun.COM Wed Oct 22 11:24:45 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Wed, 22 Oct 2008 11:24:45 -0700 Subject: SecurityException in AnnotationInvocationHandler.getMemberMethods In-Reply-To: <1ccfd1c10810211758u10bfbbf7j2b8b4fcfb050ef20@mail.gmail.com> References: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> <48FD376D.9080105@sun.com> <48FD37F3.9070208@sun.com> <1ccfd1c10810211758u10bfbbf7j2b8b4fcfb050ef20@mail.gmail.com> Message-ID: <48FF6FED.60900@sun.com> Martin Buchholz wrote: > If I had known when I started how hard it would be, > I would never have started writing one... > That is the case with many endeavors ;-) > Where are annotations tests supposed to go? > They seem under-test-covered. > I've put it into a new directory, test/java/lang/annotation > Recently I moved over the existing closed regression tests for annotations to test/java/lang/annotation: http://mail.openjdk.java.net/pipermail/jdk6-dev/2008-October/000231.html so I'll find a home for your tests in there. The newly-opened tests will be in the b13 source drop. Thanks, -Joe > Please review. The following fails with > current openjdk, passes with proposed fix. > > /* > * Copyright 2008 Sun Microsystems, Inc. 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 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. > */ > > /* > * @test > * @bug 6761678 > * @summary Check properties of Annotations returned from > * getParameterAnnotations, including freedom from security > * exceptions. > * @author Martin Buchholz > */ > > import java.lang.annotation.Annotation; > import java.lang.annotation.ElementType; > import java.lang.annotation.Retention; > import java.lang.annotation.RetentionPolicy; > import java.lang.annotation.Target; > import java.lang.reflect.Method; > import java.security.Permission; > import java.security.Policy; > import java.security.ProtectionDomain; > > @Retention(RetentionPolicy.RUNTIME) > @Target({ ElementType.FIELD, ElementType.PARAMETER }) > @interface Named { > String value(); > } > > public class ParameterAnnotations { > > // A security policy that differs from the default only in that it > // allows a security manager to be uninstalled. > static class MyPolicy extends Policy { > final Policy defaultPolicy; > MyPolicy(Policy defaultPolicy) { > this.defaultPolicy = defaultPolicy; > } > public boolean implies(ProtectionDomain pd, Permission p) { > return p.getName().equals("setSecurityManager") || > defaultPolicy.implies(pd, p); > } > } > > public void nop(@Named("foo") Object foo, > @Named("bar") Object bar) { > } > > void test(String[] args) throws Throwable { > // Test without a security manager > test1(); > > // Test with a security manager > Policy defaultPolicy = Policy.getPolicy(); > Policy.setPolicy(new MyPolicy(defaultPolicy)); > System.setSecurityManager(new SecurityManager()); > try { > test1(); > } finally { > System.setSecurityManager(null); > Policy.setPolicy(defaultPolicy); > } > } > > void test1() throws Throwable { > for (Method m : thisClass.getMethods()) { > if (m.getName().equals("nop")) { > Annotation[][] ann = m.getParameterAnnotations(); > equal(ann.length, 2); > Annotation foo = ann[0][0]; > Annotation bar = ann[1][0]; > equal(foo.toString(), "@Named(value=foo)"); > equal(bar.toString(), "@Named(value=bar)"); > check(foo.equals(foo)); > check(! foo.equals(bar)); > } > } > } > > //--------------------- Infrastructure --------------------------- > volatile int passed = 0, failed = 0; > void pass() {passed++;} > void fail() {failed++; Thread.dumpStack();} > void fail(String msg) {System.err.println(msg); fail();} > void unexpected(Throwable t) {failed++; t.printStackTrace();} > void check(boolean cond) {if (cond) pass(); else fail();} > void equal(Object x, Object y) { > if (x == null ? y == null : x.equals(y)) pass(); > else fail(x + " not equal to " + y);} > static Class thisClass = new Object(){}.getClass().getEnclosingClass(); > public static void main(String[] args) throws Throwable { > try {thisClass.getMethod("instanceMain",String[].class) > .invoke(thisClass.newInstance(), (Object) args);} > catch (Throwable e) {throw e.getCause();}} > public void instanceMain(String[] args) throws Throwable { > try {test(args);} catch (Throwable t) {unexpected(t);} > System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); > if (failed > 0) throw new AssertionError("Some tests failed");} > } > > Martin > > On Mon, Oct 20, 2008 at 19:01, Joe Darcy wrote: > >> PS Martin, I haven't written tests that setup and use a security manager, >> etc., that should go along with this fix. Having a stand-alone regression >> test along those lines would be helpful. >> >> Thanks, >> >> -Joe >> >> On 10/20/08 06:59 PM, Joe Darcy wrote: >> >>> Hello. >>> >>> On 10/16/08 12:46 PM, Martin Buchholz wrote: >>> >>>> Hi all, >>>> >>>> This is a bug report with fix. >>>> Joe Darcy, please file a bug and review this change, >>>> >>>> >>> I've filed 6761678 "(ann) SecurityException in >>> AnnotationInvocationHandler.getMemberMethods" for this issue. The problem >>> seems similar to 6370080 "(ann) Method.getAnnotations() sometimes throw >>> SecurityException: doPrivileged or javadoc missing?," which was fixed in JDK >>> 6 and a JDK 5 update release. >>> >>> Martin, can you, Toby, and Josh review any other uses of reflection in the >>> src/share/classes/sun/reflect/annotation package for similar problems so we >>> can address any other such issues now? >>> >>> I've looked over the change and the use of getMemberMethods in equalsImpl >>> and don't see a problem. However, I'd like the security team to give it a >>> once over too; security-dev folk, please take a look at this. >>> >>> Thanks, >>> >>> -Joe >>> >>>> and perhaps provide a small test case (it is impractical >>>> to share the test we have at Google). >>>> >>>> Description: >>>> >>>> sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods >>>> might throw if there is a security manager that does not allow >>>> getDeclaredMethods. >>>> >>>> The author of this code (Josh Bloch) confirms that the intent was for the >>>> doPrivileged block in this method to prevent security exceptions. >>>> The methods cannot escape to untrusted code. >>>> >>>> Evaluation: >>>> >>>> Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. >>>> >>>> # HG changeset patch >>>> # User martin >>>> # Date 1224185752 25200 >>>> # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f >>>> # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 >>>> SecurityException in AnnotationInvocationHandler.getMemberMethods >>>> Summary: Move call to getDeclaredMethods inside doPrivileged >>>> Reviewed-by: >>>> Contributed-by: jjb at google.com >>>> >>>> diff --git >>>> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>> >>>> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>> --- >>>> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>> +++ >>>> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>> @@ -272,14 +272,14 @@ >>>> */ >>>> private Method[] getMemberMethods() { >>>> if (memberMethods == null) { >>>> - final Method[] mm = type.getDeclaredMethods(); >>>> - AccessController.doPrivileged(new PrivilegedAction() { >>>> - public Void run() { >>>> - AccessibleObject.setAccessible(mm, true); >>>> - return null; >>>> - } >>>> - }); >>>> - memberMethods = mm; >>>> + memberMethods = AccessController.doPrivileged( >>>> + new PrivilegedAction() { >>>> + public Method[] run() { >>>> + final Method[] mm = type.getDeclaredMethods(); >>>> + AccessibleObject.setAccessible(mm, true); >>>> + return mm; >>>> + } >>>> + }); >>>> } >>>> return memberMethods; >>>> } >>>> >>>> >> From Joe.Darcy at Sun.COM Thu Oct 23 10:02:01 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Thu, 23 Oct 2008 10:02:01 -0700 Subject: SecurityException in AnnotationInvocationHandler.getMemberMethods In-Reply-To: <48FF6FED.60900@sun.com> References: <1ccfd1c10810161246l51643ddfi7d13e094ad11ccb4@mail.gmail.com> <48FD376D.9080105@sun.com> <48FD37F3.9070208@sun.com> <1ccfd1c10810211758u10bfbbf7j2b8b4fcfb050ef20@mail.gmail.com> <48FF6FED.60900@sun.com> Message-ID: <4900AE09.1010207@sun.com> Joseph D. Darcy wrote: > Martin Buchholz wrote: >> If I had known when I started how hard it would be, >> I would never have started writing one... >> > > That is the case with many endeavors ;-) > >> Where are annotations tests supposed to go? >> They seem under-test-covered. >> I've put it into a new directory, test/java/lang/annotation >> > > Recently I moved over the existing closed regression tests for > annotations to test/java/lang/annotation: > > http://mail.openjdk.java.net/pipermail/jdk6-dev/2008-October/000231.html > so I'll find a home for your tests in there. The newly-opened tests > will be in the b13 source drop. Martin, I've reviewed your test and code and Sean Mullan has reviewed the code too. I verified the test fails with the current build and passes with change. I've putback the code changes and test into OpenJDK 6 b13. The test lives at test/java/lang/annotations/ParameterAnnotations.java; the other annotation tests will go in that directory once I move them over in JDK 7 too. I think you're clear to commit this fix to the JDK 7 repository too. -Joe > > Thanks, > > -Joe > >> Please review. The following fails with >> current openjdk, passes with proposed fix. >> >> /* >> * Copyright 2008 Sun Microsystems, Inc. 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 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. >> */ >> >> /* >> * @test >> * @bug 6761678 >> * @summary Check properties of Annotations returned from >> * getParameterAnnotations, including freedom from security >> * exceptions. >> * @author Martin Buchholz >> */ >> >> import java.lang.annotation.Annotation; >> import java.lang.annotation.ElementType; >> import java.lang.annotation.Retention; >> import java.lang.annotation.RetentionPolicy; >> import java.lang.annotation.Target; >> import java.lang.reflect.Method; >> import java.security.Permission; >> import java.security.Policy; >> import java.security.ProtectionDomain; >> >> @Retention(RetentionPolicy.RUNTIME) >> @Target({ ElementType.FIELD, ElementType.PARAMETER }) >> @interface Named { >> String value(); >> } >> >> public class ParameterAnnotations { >> >> // A security policy that differs from the default only in that it >> // allows a security manager to be uninstalled. >> static class MyPolicy extends Policy { >> final Policy defaultPolicy; >> MyPolicy(Policy defaultPolicy) { >> this.defaultPolicy = defaultPolicy; >> } >> public boolean implies(ProtectionDomain pd, Permission p) { >> return p.getName().equals("setSecurityManager") || >> defaultPolicy.implies(pd, p); >> } >> } >> >> public void nop(@Named("foo") Object foo, >> @Named("bar") Object bar) { >> } >> >> void test(String[] args) throws Throwable { >> // Test without a security manager >> test1(); >> >> // Test with a security manager >> Policy defaultPolicy = Policy.getPolicy(); >> Policy.setPolicy(new MyPolicy(defaultPolicy)); >> System.setSecurityManager(new SecurityManager()); >> try { >> test1(); >> } finally { >> System.setSecurityManager(null); >> Policy.setPolicy(defaultPolicy); >> } >> } >> >> void test1() throws Throwable { >> for (Method m : thisClass.getMethods()) { >> if (m.getName().equals("nop")) { >> Annotation[][] ann = m.getParameterAnnotations(); >> equal(ann.length, 2); >> Annotation foo = ann[0][0]; >> Annotation bar = ann[1][0]; >> equal(foo.toString(), "@Named(value=foo)"); >> equal(bar.toString(), "@Named(value=bar)"); >> check(foo.equals(foo)); >> check(! foo.equals(bar)); >> } >> } >> } >> >> //--------------------- Infrastructure --------------------------- >> volatile int passed = 0, failed = 0; >> void pass() {passed++;} >> void fail() {failed++; Thread.dumpStack();} >> void fail(String msg) {System.err.println(msg); fail();} >> void unexpected(Throwable t) {failed++; t.printStackTrace();} >> void check(boolean cond) {if (cond) pass(); else fail();} >> void equal(Object x, Object y) { >> if (x == null ? y == null : x.equals(y)) pass(); >> else fail(x + " not equal to " + y);} >> static Class thisClass = new >> Object(){}.getClass().getEnclosingClass(); >> public static void main(String[] args) throws Throwable { >> try {thisClass.getMethod("instanceMain",String[].class) >> .invoke(thisClass.newInstance(), (Object) args);} >> catch (Throwable e) {throw e.getCause();}} >> public void instanceMain(String[] args) throws Throwable { >> try {test(args);} catch (Throwable t) {unexpected(t);} >> System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); >> if (failed > 0) throw new AssertionError("Some tests failed");} >> } >> >> Martin >> >> On Mon, Oct 20, 2008 at 19:01, Joe Darcy wrote: >> >>> PS Martin, I haven't written tests that setup and use a security >>> manager, >>> etc., that should go along with this fix. Having a stand-alone >>> regression >>> test along those lines would be helpful. >>> >>> Thanks, >>> >>> -Joe >>> >>> On 10/20/08 06:59 PM, Joe Darcy wrote: >>> >>>> Hello. >>>> >>>> On 10/16/08 12:46 PM, Martin Buchholz wrote: >>>> >>>>> Hi all, >>>>> >>>>> This is a bug report with fix. >>>>> Joe Darcy, please file a bug and review this change, >>>>> >>>>> >>>> I've filed 6761678 "(ann) SecurityException in >>>> AnnotationInvocationHandler.getMemberMethods" for this issue. The >>>> problem >>>> seems similar to 6370080 "(ann) Method.getAnnotations() sometimes >>>> throw >>>> SecurityException: doPrivileged or javadoc missing?," which was >>>> fixed in JDK >>>> 6 and a JDK 5 update release. >>>> >>>> Martin, can you, Toby, and Josh review any other uses of reflection >>>> in the >>>> src/share/classes/sun/reflect/annotation package for similar >>>> problems so we >>>> can address any other such issues now? >>>> >>>> I've looked over the change and the use of getMemberMethods in >>>> equalsImpl >>>> and don't see a problem. However, I'd like the security team to >>>> give it a >>>> once over too; security-dev folk, please take a look at this. >>>> >>>> Thanks, >>>> >>>> -Joe >>>> >>>>> and perhaps provide a small test case (it is impractical >>>>> to share the test we have at Google). >>>>> >>>>> Description: >>>>> >>>>> sun/reflect/annotation/AnnotationInvocationHandler.java.getMemberMethods >>>>> >>>>> might throw if there is a security manager that does not allow >>>>> getDeclaredMethods. >>>>> >>>>> The author of this code (Josh Bloch) confirms that the intent was >>>>> for the >>>>> doPrivileged block in this method to prevent security exceptions. >>>>> The methods cannot escape to untrusted code. >>>>> >>>>> Evaluation: >>>>> >>>>> Yes. Fix provided courtesy of Toby Reyelts and Josh Bloch at Google. >>>>> >>>>> # HG changeset patch >>>>> # User martin >>>>> # Date 1224185752 25200 >>>>> # Node ID 68730f05449cd4f39ce1cb82adc6c4e57f87554f >>>>> # Parent 214ebdcf7252d4862449fe0ae295e6c60a127315 >>>>> SecurityException in AnnotationInvocationHandler.getMemberMethods >>>>> Summary: Move call to getDeclaredMethods inside doPrivileged >>>>> Reviewed-by: >>>>> Contributed-by: jjb at google.com >>>>> >>>>> diff --git >>>>> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>>> >>>>> >>>>> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>>> >>>>> --- >>>>> a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>>> >>>>> +++ >>>>> b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java >>>>> >>>>> @@ -272,14 +272,14 @@ >>>>> */ >>>>> private Method[] getMemberMethods() { >>>>> if (memberMethods == null) { >>>>> - final Method[] mm = type.getDeclaredMethods(); >>>>> - AccessController.doPrivileged(new >>>>> PrivilegedAction() { >>>>> - public Void run() { >>>>> - AccessibleObject.setAccessible(mm, true); >>>>> - return null; >>>>> - } >>>>> - }); >>>>> - memberMethods = mm; >>>>> + memberMethods = AccessController.doPrivileged( >>>>> + new PrivilegedAction() { >>>>> + public Method[] run() { >>>>> + final Method[] mm = >>>>> type.getDeclaredMethods(); >>>>> + AccessibleObject.setAccessible(mm, true); >>>>> + return mm; >>>>> + } >>>>> + }); >>>>> } >>>>> return memberMethods; >>>>> } >>>>> >>>>> >>> > From Joe.Darcy at Sun.COM Thu Oct 23 15:20:31 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Thu, 23 Oct 2008 15:20:31 -0700 Subject: JNI crashes in FontManager code In-Reply-To: <1ccfd1c10810161723m54dfb7dar8a38bdde2aec196b@mail.gmail.com> References: <1ccfd1c10810161723m54dfb7dar8a38bdde2aec196b@mail.gmail.com> Message-ID: <4900F8AF.1010307@sun.com> Hello. 2D-team, I'm not an expert in this part of the platform, but the reasoning Martin has sent seems sound; please review the fix. Thanks, -Joe Martin Buchholz wrote: > Hi font maintainers, > > This is a bug report, with fix, > provided by Hiroshi Yamauchi. > This is a crash detected by a google test > (which is unfortunately impractical to share) > which makes this at least a P2 bug. > > Description: > > Fixing the bad JNI code in the font manager code. Two issues: > > o The JNIEnv is unique to the thread. It cannot be saved by one thread and > reused by another. Use GetEnv instead. > > o The 'font2D' jobject needs to be converted into a global reference because > its lifetime exceeds the lifetime of a native method call. > > Evaluation: > > Appropriately register/free everything with the garbage collector. > > Fix: > > # HG changeset patch > # User martin > # Date 1224202830 25200 > # Node ID 3c9d6001d8a90698a3540a2a483717f26a98db78 > # Parent 68730f05449cd4f39ce1cb82adc6c4e57f87554f > Crash in freetypeScaler.c due to insufficient GC protection > Summary: NewGlobalRef/DeleteGlobalRef as needed. > Reviewed-by: > Contributed-by: yamauchi at google.com > > diff --git a/make/sun/font/mapfile-vers.openjdk > b/make/sun/font/mapfile-vers.openjdk > --- a/make/sun/font/mapfile-vers.openjdk > +++ b/make/sun/font/mapfile-vers.openjdk > @@ -29,6 +29,7 @@ > > SUNWprivate_1.1 { > global: > + JNI_OnLoad; > getSunFontIDs; > newLayoutTableCache; > freeLayoutTableCache; > diff --git a/src/share/native/sun/font/freetypeScaler.c > b/src/share/native/sun/font/freetypeScaler.c > --- a/src/share/native/sun/font/freetypeScaler.c > +++ b/src/share/native/sun/font/freetypeScaler.c > @@ -48,16 +48,6 @@ > #define ROUND(x) ((int) (x+0.5)) > > typedef struct { > - /* Important note: > - JNI forbids sharing same env between different threads. > - We are safe, because pointer is overwritten every time we get into > - JNI call (see setupFTContext). > - > - Pointer is used by font data reading callbacks > - such as ReadTTFontFileFunc. > - > - NB: We may consider switching to JNI_GetEnv. */ > - JNIEnv* env; > FT_Library library; > FT_Face face; > jobject font2D; > @@ -90,6 +80,13 @@ > void z_error(char *s) {} > #endif > > +static JavaVM* jvm = NULL; > + > +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { > + jvm = vm; > + return JNI_VERSION_1_2; > +} > + > /**************** Error handling utilities *****************/ > > static jmethodID invalidateScalerMID; > @@ -107,6 +104,10 @@ > > FT_Done_Face(scalerInfo->face); > FT_Done_FreeType(scalerInfo->library); > + > + if (scalerInfo->font2D != NULL) { > + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); > + } > > if (scalerInfo->directBuffer != NULL) { > (*env)->DeleteGlobalRef(env, scalerInfo->directBuffer); > @@ -131,10 +132,9 @@ > > #define FILEDATACACHESIZE 1024 > > -/* NB: is it ever called? */ > static void CloseTTFontFileFunc(FT_Stream stream) { > + JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2); > FTScalerInfo *scalerInfo = (FTScalerInfo *) stream->pathname.pointer; > - JNIEnv* env = scalerInfo->env; > jclass tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont"); > jfieldID platNameField = > (*env)->GetFieldID(env, tmpClass, "platName", "Ljava/lang/String;"); > @@ -150,8 +150,8 @@ > unsigned char* destBuffer, > unsigned long numBytes) > { > + JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2); > FTScalerInfo *scalerInfo = (FTScalerInfo *) stream->pathname.pointer; > - JNIEnv* env = scalerInfo->env; > jobject bBuffer; > int bread = 0; > > @@ -245,8 +245,7 @@ > if (scalerInfo == NULL) > return 0; > > - scalerInfo->env = env; > - scalerInfo->font2D = font2D; > + scalerInfo->font2D = (*env)->NewGlobalRef(env, font2D); > scalerInfo->fontDataOffset = 0; > scalerInfo->fontDataLength = 0; > scalerInfo->fileSize = filesize; > @@ -263,6 +262,7 @@ > */ > error = FT_Init_FreeType(&scalerInfo->library); > if (error) { > + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); > free(scalerInfo); > return 0; > } > @@ -331,6 +331,7 @@ > } > if (scalerInfo->fontData != NULL) > free(scalerInfo->fontData); > + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); > free(scalerInfo); > return 0; > } > @@ -391,8 +392,10 @@ > FTScalerContext *context) { > int errCode = 0; > > - scalerInfo->env = env; > - scalerInfo->font2D = font2D; > + if (scalerInfo->font2D != NULL) { > + (*env)->DeleteGlobalRef(env, scalerInfo->font2D); > + } > + scalerInfo->font2D = (*env)->NewGlobalRef(env, font2D); > > FT_Set_Transform(scalerInfo->face, &context->transform, NULL); > From Joe.Darcy at Sun.COM Fri Oct 24 09:58:32 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Fri, 24 Oct 2008 09:58:32 -0700 Subject: Patch to fix 6356642 extcheck.exe -verbose throws ArrayIndexOutOfBoundsException exception Message-ID: <4901FEB8.1060200@sun.com> The patch below is for 6356642 "extcheck.exe -verbose throws ArrayIndexOutOfBoundsException exception ," which is fixed in build 13. -Joe --- old/src/share/classes/com/sun/tools/extcheck/ExtCheck.java Thu Oct 23 21:50:41 2008 +++ new/src/share/classes/com/sun/tools/extcheck/ExtCheck.java Thu Oct 23 21:50:41 2008 @@ -1,5 +1,5 @@ /* - * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1998-2008 Sun Microsystems, Inc. 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 @@ -256,13 +256,13 @@ private boolean isNotOlderThan(String already,String target) throws NumberFormatException { - if (already == null || already.length() < 1) { + if (already == null || already.length() < 1) { throw new NumberFormatException("Empty version string"); } - // Until it matches scan and compare numbers - StringTokenizer dtok = new StringTokenizer(target, ".", true); - StringTokenizer stok = new StringTokenizer(already, ".", true); + // Until it matches scan and compare numbers + StringTokenizer dtok = new StringTokenizer(target, ".", true); + StringTokenizer stok = new StringTokenizer(already, ".", true); while (dtok.hasMoreTokens() || stok.hasMoreTokens()) { int dver; int sver; @@ -276,19 +276,19 @@ } else sver = 0; - if (sver < dver) - return false; // Known to be incompatible - if (sver > dver) - return true; // Known to be compatible + if (sver < dver) + return false; // Known to be incompatible + if (sver > dver) + return true; // Known to be compatible - // Check for and absorb separators - if (dtok.hasMoreTokens()) - dtok.nextToken(); - if (stok.hasMoreTokens()) - stok.nextToken(); - // Compare next component - } - // All components numerically equal + // Check for and absorb separators + if (dtok.hasMoreTokens()) + dtok.nextToken(); + if (stok.hasMoreTokens()) + stok.nextToken(); + // Compare next component + } + // All components numerically equal return true; } @@ -307,11 +307,10 @@ } /** - * Print out the error message and exit from the program + * Throws a RuntimeException with a message describing the error. */ - static void error(String message){ - System.err.println(message); - System.exit(-1); + static void error(String message) throws RuntimeException { + throw new RuntimeException(message); } @@ -356,19 +355,19 @@ } private JarFile findJarFile(URL url) throws IOException { - // Optimize case where url refers to a local jar file - if ("file".equals(url.getProtocol())) { - String path = url.getFile().replace('/', File.separatorChar); - File file = new File(path); - if (!file.exists()) { - throw new FileNotFoundException(path); - } - return new JarFile(path); - } - URLConnection uc = getBaseURL().openConnection(); - //uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION); - return ((JarURLConnection)uc).getJarFile(); - } + // Optimize case where url refers to a local jar file + if ("file".equals(url.getProtocol())) { + String path = url.getFile().replace('/', File.separatorChar); + File file = new File(path); + if (!file.exists()) { + throw new FileNotFoundException(path); + } + return new JarFile(path); + } + URLConnection uc = getBaseURL().openConnection(); + //uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION); + return ((JarURLConnection)uc).getJarFile(); + } /* @@ -406,6 +405,4 @@ return urls; } } - - } --- old/src/share/classes/com/sun/tools/extcheck/Main.java Thu Oct 23 21:50:43 2008 +++ new/src/share/classes/com/sun/tools/extcheck/Main.java Thu Oct 23 21:50:43 2008 @@ -1,5 +1,5 @@ /* - * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1998-2008 Sun Microsystems, Inc. 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 @@ -32,8 +32,11 @@ */ public final class Main { + public static final String INSUFFICIENT = "Insufficient number of arguments"; + public static final String MISSING = "Missing argument"; + public static final String DOES_NOT_EXIST = "Jarfile does not exist: "; + public static final String EXTRA = "Extra command line argument: "; - /** * Terminates with one of the following codes * 1 A newer (or same version) jar file is already installed @@ -40,26 +43,36 @@ * 0 No newer jar file was found * -1 An internal error occurred */ - public static void main(String args[]){ - - if (args.length < 1){ - System.err.println("Usage: extcheck [-verbose] "); + public static void main(String args[]) { + try { + realMain(args); + } catch (Exception ex) { + System.err.println(ex.getMessage()); System.exit(-1); } + } + + public static void realMain(String[] args) throws Exception { + if (args.length < 1) { + usage(INSUFFICIENT); + } int argIndex = 0; boolean verboseFlag = false; - if (args[argIndex].equals("-verbose")){ + if (args[argIndex].equals("-verbose")) { verboseFlag = true; argIndex++; + if (argIndex >= args.length) { + usage(MISSING); + } } String jarName = args[argIndex]; argIndex++; File jarFile = new File(jarName); if (!jarFile.exists()){ - ExtCheck.error("Jarfile " + jarName + " does not exist"); + usage(DOES_NOT_EXIST + jarName); } if (argIndex < args.length) { - ExtCheck.error("Extra command line argument :"+args[argIndex]); + usage(EXTRA + args[argIndex]); } ExtCheck jt = ExtCheck.create(jarFile,verboseFlag); boolean result = jt.checkInstalledAgainstTarget(); @@ -68,7 +81,9 @@ } else { System.exit(1); } - } + private static void usage(String msg) throws Exception { + throw new Exception(msg + "\nUsage: extcheck [-verbose] "); + } } --- /dev/null Thu Oct 23 21:50:45 2008 +++ new/test/com/sun/tools/extcheck/TestExtcheckArgs.java Thu Oct 23 21:50:45 2008 @@ -0,0 +1,92 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 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. + */ + +/** + * @test + * @bug 6356642 + * @summary Verify that extcheck exits appropriately when invalid args are given. + * @run shell TestExtcheckArgs.sh + * @author Dave Bristor + */ + +import java.io.File; +import com.sun.tools.extcheck.Main; + +/* + * Test extcheck by using Runtime.exec instead of invoking + * com.sun.tools.extcheck.Main.main, since the latter does its own + * System.exit under the conditions checked here. + */ +public class TestExtcheckArgs { + public static void realMain(String[] args) throws Throwable { + String testJar = System.getenv("TESTJAVA") + File.separator + + "lib" + File.separator + "jconsole.jar"; + + verify(new String[] { + }, Main.INSUFFICIENT); + verify(new String[] { + "-verbose" + }, Main.MISSING); + verify(new String[] { + "-verbose", + "foo" + }, Main.DOES_NOT_EXIST); + verify(new String[] { + testJar, + "bar" + }, Main.EXTRA); + verify(new String[] { + "-verbose", + testJar, + "bar" + }, Main.EXTRA); + } + + static void verify(String[] args, String expected) throws Throwable { + try { + Main.realMain(args); + fail(); + } catch (Exception ex) { + if (ex.getMessage().startsWith(expected)) { + pass(); + } else { + fail("Unexpected message: " + ex.getMessage()); + } + } + } + + //--------------------- Infrastructure --------------------------- + static volatile int passed = 0, failed = 0; + static boolean pass() {passed++; return true;} + static boolean fail() {failed++; Thread.dumpStack(); return false;} + static boolean fail(String msg) {System.out.println(msg); return fail();} + static void unexpected(Throwable t) {failed++; t.printStackTrace();} + static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;} + static boolean equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) return pass(); + else return fail(x + " not equal to " + y);} + public static void main(String[] args) throws Throwable { + try {realMain(args);} catch (Throwable t) {unexpected(t);} + System.out.println("\nPassed = " + passed + " failed = " + failed); + if (failed > 0) throw new AssertionError("Some tests failed");} +} --- /dev/null Thu Oct 23 21:50:46 2008 +++ new/test/com/sun/tools/extcheck/TestExtcheckArgs.sh Thu Oct 23 21:50:46 2008 @@ -0,0 +1,47 @@ +#! /bin/sh + +# +# Copyright 2008 Sun Microsystems, Inc. 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 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. +# + +if [ "x$TESTJAVA" = x ]; then + TESTJAVA=$1; shift + TESTCLASSES=. + TESTSRC=. +fi +export TESTJAVA + +case "`uname`" in Windows*|CYGWIN* ) PS=';';; *) PS=':';; esac + +${TESTJAVA}/bin/javac -d ${TESTCLASSES} -classpath ${TESTJAVA}/lib/tools.jar${PS}${TESTCLASSES} ${TESTSRC}/TestExtcheckArgs.java +rc=$? +if [ $rc != 0 ]; then + echo Compilation failure with exit status $rc + exit $rc +fi + +${TESTJAVA}/bin/java -classpath ${TESTJAVA}/lib/tools.jar${PS}${TESTCLASSES} TestExtcheckArgs +rc=$? +if [ $rc != 0 ]; then + echo Execution failure with exit status $rc + exit $rc +fi From Joe.Darcy at Sun.COM Fri Oct 24 14:49:49 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Fri, 24 Oct 2008 14:49:49 -0700 Subject: Patch to update and correct man pages Message-ID: <490242FD.7060703@sun.com> Hello. Recently it came to my attention that the javac man page included in OpenJDK 6 was out of date. Working with the Sun JDK docs team, I've brought over and implemented various fixes to the English man pages and regenerated the output. The attached patch addresses these four Sun bugs: 6757036 Update manpages for OpenJDK 6 6392810 javac manpage needs to be updated to include JSR 269 and other Mustang options 6504867 Man page errors: link to Annotation Processing, -version, and -fullversion. 6326773 Typo in java.sun.com/..../javac.html -Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: manpages.patch.gz Type: application/gzip Size: 129242 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081024/ae4bb2c1/attachment.bin From Daniel.Fuchs at Sun.COM Mon Oct 27 08:06:28 2008 From: Daniel.Fuchs at Sun.COM (Daniel Fuchs) Date: Mon, 27 Oct 2008 16:06:28 +0100 Subject: Patch to fix 6754672: java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory Message-ID: <4905D8F4.7000704@sun.com> which is fixed in next Open JDK 6 build. Best regards, -- daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: 6open.6754672.patch Type: text/x-patch Size: 776 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/jdk6-dev/attachments/20081027/e8cded6d/attachment.bin From Joe.Darcy at Sun.COM Mon Oct 27 18:40:20 2008 From: Joe.Darcy at Sun.COM (Joe Darcy) Date: Mon, 27 Oct 2008 18:40:20 -0700 Subject: Patches for backports of javac fixes Message-ID: <49066D84.7020508@sun.com> Hello. The following patch fixes the pair of bugs 6725036 javac returns incorrect value for lastModifiedTime() when source is a zip file archive 6657499 javac 1.6.0 fails to compile class with inner class These fixes are in OpenJDK 6 build 13. -Joe --- old/src/share/classes/com/sun/tools/javac/zip/ZipFileIndexEntry.java Mon Oct 27 17:28:20 2008 +++ new/src/share/classes/com/sun/tools/javac/zip/ZipFileIndexEntry.java Mon Oct 27 17:28:20 2008 @@ -26,6 +26,7 @@ package com.sun.tools.javac.zip; import java.io.File; +import java.util.Calendar; public final class ZipFileIndexEntry implements Comparable { public static final ZipFileIndexEntry[] EMPTY_ARRAY = {}; @@ -83,13 +84,20 @@ return javatime; } - // From java.util.zip - private static long dosToJavaTime(int nativetime) { - // Bootstrap build problems prevent me from using the code directly - // Convert the raw/native time to a long for now - return (long)nativetime; + // based on dosToJavaTime in java.util.Zip, but avoiding the + // use of deprecated Date constructor + private static long dosToJavaTime(int dtime) { + Calendar c = Calendar.getInstance(); + c.set(Calendar.YEAR, ((dtime >> 25) & 0x7f) + 1980); + c.set(Calendar.MONTH, ((dtime >> 21) & 0x0f) - 1); + c.set(Calendar.DATE, ((dtime >> 16) & 0x1f)); + c.set(Calendar.HOUR_OF_DAY, ((dtime >> 11) & 0x1f)); + c.set(Calendar.MINUTE, ((dtime >> 5) & 0x3f)); + c.set(Calendar.SECOND, ((dtime << 1) & 0x3e)); + c.set(Calendar.MILLISECOND, 0); + return c.getTimeInMillis(); } - + void setNativeTime(int natTime) { nativetime = natTime; } --- old/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Oct 27 17:28:22 2008 +++ new/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Oct 27 17:28:22 2008 @@ -1820,7 +1820,7 @@ chk.earlyRefError(tree.pos(), sym.kind == VAR ? sym : thisSym(tree.pos(), env)); } Env env1 = env; - if (sym.kind != ERR && sym.owner != null && sym.owner != env1.enclClass.sym) { + if (sym.kind != ERR && sym.kind != TYP && sym.owner != null && sym.owner != env1.enclClass.sym) { // If the found symbol is inaccessible, then it is // accessed through an enclosing instance. Locate this // enclosing instance: --- /dev/null Mon Oct 27 17:28:24 2008 +++ new/test/tools/javac/T6725036.java Mon Oct 27 17:28:24 2008 @@ -0,0 +1,96 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 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. + */ + +/* + * @test + * @bug 6725036 + * @summary javac returns incorrect value for lastModifiedTime() when + * source is a zip file archive + */ + +import java.io.File; +import java.util.Date; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import javax.tools.JavaFileObject; + +import com.sun.tools.javac.util.JavacFileManager; +import com.sun.tools.javac.zip.ZipFileIndex; +import com.sun.tools.javac.zip.ZipFileIndexEntry; +import com.sun.tools.javac.util.JavacFileManager.ZipFileIndexArchive; +import com.sun.tools.javac.util.Context; + +public class T6725036 { + public static void main(String... args) throws Exception { + new T6725036().run(); + } + + void run() throws Exception { + String TEST_ENTRY_NAME = "java/lang/String.class"; + + File f = new File(System.getProperty("java.home")); + if (!f.getName().equals("jre")) + f = new File(f, "jre"); + File rt_jar = new File(new File(f, "lib"), "rt.jar"); + + JarFile j = new JarFile(rt_jar); + JarEntry je = j.getJarEntry(TEST_ENTRY_NAME); + long jarEntryTime = je.getTime(); + + ZipFileIndex zfi = + ZipFileIndex.getZipFileIndex(rt_jar, 0, false, null, false); + long zfiTime = zfi.getLastModified(TEST_ENTRY_NAME); + + check(je, jarEntryTime, zfi + ":" + TEST_ENTRY_NAME, zfiTime); + + Context context = new Context(); + JavacFileManager fm = new JavacFileManager(context, false, null); + ZipFileIndexArchive zfia = + fm.new ZipFileIndexArchive(fm, zfi); + int sep = TEST_ENTRY_NAME.lastIndexOf("/"); + JavaFileObject jfo = + zfia.getFileObject(TEST_ENTRY_NAME.substring(0, sep + 1), + TEST_ENTRY_NAME.substring(sep + 1)); + long jfoTime = jfo.getLastModified(); + + check(je, jarEntryTime, jfo, jfoTime); + + if (errors > 0) + throw new Exception(errors + " occurred"); + } + + void check(Object ref, long refTime, Object test, long testTime) { + if (refTime == testTime) + return; + System.err.println("Error: "); + System.err.println("Expected: " + getText(ref, refTime)); + System.err.println(" Found: " + getText(test, testTime)); + errors++; + } + + String getText(Object x, long t) { + return String.format("%14d", t) + " (" + new Date(t) + ") from " + x; + } + + int errors; +} --- /dev/null Mon Oct 27 17:28:24 2008 +++ new/test/tools/javac/generics/T6657499.java Mon Oct 27 17:28:24 2008 @@ -0,0 +1,44 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 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. + */ + +/* + * @test + * + * @bug 6657499 + * @summary generics: javac 1.6.0 fails to compile class with inner class + * @author Maurizio Cimadamore + * + */ + +public class T6657499 { + T t; + public T test() { + class Local {private T t;}; + class Local2 {T m() {return t;}}; + T t3 = new Local().t; + return new Local2().m(); + } + public static void main(String[] args) { + String s = new T6657499().test(); + } +} From Joe.Darcy at Sun.COM Fri Oct 31 15:48:16 2008 From: Joe.Darcy at Sun.COM (Joseph D. Darcy) Date: Fri, 31 Oct 2008 15:48:16 -0700 Subject: OpenJDK 6 and 6u10 features Message-ID: <490B8B30.40605@sun.com> Greetings. OpenJDK 6 build 12 contained ports of bug fixes from a number of 6u10 component areas (corba, jaxp, jaxws, langtools). [1] Most changes from the core jdk component area of 6u10 were not ported. The porting effort that took place of a relatively small number of bugs to a subset of the full OpenJDK code base was still a sizeable effort. [2] The full set of changes made to the core jdk in 6u10 is many times larger with a proportionally larger porting cost. We at Sun do not plan to do a wholesale port of those 6u10 features from the core jdk to OpenJDK 6. However, over the coming months we will be porting those 6u10 features to OpenJDK 7 and we would welcome community assistance in backporting appropriate features from OpenJDK 7 to OpenJDK 6. (These jdk area features in 6u10 are separate from plugin and webstart functionality.) Kelly has made substantial progress in preparing the OpenJDK 6 Mercurial repositories and at least trial versions of them should be available within a few weeks. -Joe [1] http://mail.openjdk.java.net/pipermail/jdk6-dev/2008-September/000150.html [2] http://blogs.sun.com/darcy/entry/openjdk_6_logistics_of_partial From gnu_andrew at member.fsf.org Fri Oct 31 16:29:06 2008 From: gnu_andrew at member.fsf.org (Andrew John Hughes) Date: Fri, 31 Oct 2008 23:29:06 +0000 Subject: OpenJDK 6 and 6u10 features In-Reply-To: <490B8B30.40605@sun.com> References: <490B8B30.40605@sun.com> Message-ID: <17c6771e0810311629m5a388751t5d861b120aec8ee2@mail.gmail.com> 2008/10/31 Joseph D. Darcy : > Greetings. > > OpenJDK 6 build 12 contained ports of bug fixes from a number of 6u10 > component areas (corba, jaxp, jaxws, langtools). [1] Most changes from the > core jdk component area of 6u10 were not ported. The porting effort that > took place of a relatively small number of bugs to a subset of the full > OpenJDK code base was still a sizeable effort. [2] The full set of changes > made to the core jdk in 6u10 is many times larger with a proportionally > larger porting cost. We at Sun do not plan to do a wholesale port of those > 6u10 features from the core jdk to OpenJDK 6. However, over the coming > months we will be porting those 6u10 features to OpenJDK 7 and we would > welcome community assistance in backporting appropriate features from > OpenJDK 7 to OpenJDK 6. I'm not too surprised by this. OpenJDK7 is clearly the development focus for Sun and has seen development at a level several orders of magnitude higher than that of OpenJDK6. However, for the time being, this is pointless for pretty much anyone else, as we're unlikely to be using OpenJDK7 for at least another year (there is as yet no platform specification and thus no feature set for the release). I read your blog and I don't see what not porting the changes to OpenJDK6 would achieve. All the work mentioned there is going to apply just as much to OpenJDK7, and essentially all the 7 to 6 port would be is applying the changesets to the OpenJDK6 tree. Of course, if the changesets are clearly marked as they go into OpenJDK7, we can easily apply such patches to IcedTea6, where they can then later be consumed by OpenJDK6. The markup part is essential, because patches going into the dozens of JDK7 mercurial trees is going to be extremely difficult to track from our side. But the effort needed would seem to be in trawling the bug database and converting from the Teamware sources, which the community obviously can't do because neither system is fully accessible outside Sun. Once they are in OpenJDK7, the work is virtually done AFAICS. I think the real issue to address is why development work on 6 is still being performed on closed Teamware repositories and resulting in these kind of issues in the first place. We may be able to work round things this time, but unless the actual process that created this mess changes, we'll have to go through all of this again for u11 and however many others follow. Really, the priority should be getting the OpenJDK6 Mercurial repositories setup and developing updates to 6 there, where they can be trivially merged to 7. (These jdk area features in 6u10 are separate from > plugin and webstart functionality.) > Are there any plans for these to appear yet? > Kelly has made substantial progress in preparing the OpenJDK 6 Mercurial > repositories and at least trial versions of them should be available within > a few weeks. > Does this still include updating HotSpot to b11? > -Joe > > [1] > http://mail.openjdk.java.net/pipermail/jdk6-dev/2008-September/000150.html > [2] http://blogs.sun.com/darcy/entry/openjdk_6_logistics_of_partial > > Thanks, -- Andrew :-) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8