Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 13446 invoked from network); 2 Jul 2005 18:58:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Jul 2005 18:58:42 -0000 Received: (qmail 63080 invoked by uid 500); 2 Jul 2005 18:58:41 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 63067 invoked by uid 99); 2 Jul 2005 18:58:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jul 2005 11:58:41 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_40_50,HTML_MESSAGE,HTML_TITLE_EMPTY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [62.154.194.149] (HELO miraculix.spree.de) (62.154.194.149) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jul 2005 11:58:43 -0700 Received: from [172.16.2.80] (vpn-server [192.168.16.104]) by miraculix.spree.de (8.11.6/8.11.6) with ESMTP id j62IwWv26662 for ; Sat, 2 Jul 2005 20:58:32 +0200 Message-ID: <42C6E3D6.9070005@spree.de> Date: Sat, 02 Jul 2005 20:58:30 +0200 From: Michael Bouschen Organization: Tech@Spree Engineering User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: Re: Fix for JDO-77 References: <71CCDBC6-DA36-4E89-8B18-62C025F0012F@Sun.COM> In-Reply-To: <71CCDBC6-DA36-4E89-8B18-62C025F0012F@Sun.COM> Content-Type: multipart/alternative; boundary="------------020904040307060804020204" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------020904040307060804020204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Craig, the changes look good! I would like to propose a few improvements of the method mangleObject you changed. Maybe this should be an extra check in, because they are not related to the fix for JDO-77. (1) We plan to add configuration running the TCK with a security manager. Then the reflection access of method mangleObject should be enclosed in a doPivileged block. (2) The method checks for fields of specific types. Should we add date, BigDecimal, BigInteger, float, double, Float and Double? (3) We could use 'else if' when checking the field types. Regards Michael > Hi, > > Please review this patch. It fixes an illegal access exception when > mangleObject tries to change a final field. The final field was added > to the PCPoint$Oid class. > > The fix checks for final and static modifiers on the field before it > changes it. > > I also changed the method to actually change each field, instead of > simply changing its value to a constant. > > Thanks, > > Craig > >------------------------------------------------------------------------ > >Index: test/java/org/apache/jdo/tck/JDO_Test.java >=================================================================== >--- test/java/org/apache/jdo/tck/JDO_Test.java (revision 208860) >+++ test/java/org/apache/jdo/tck/JDO_Test.java (working copy) >@@ -757,43 +757,47 @@ > Field[] fields = oidClass.getFields(); > for (int i = 0; i < fields.length; ++i) { > Field field = fields[i]; >+ int modifiers = field.getModifiers(); >+ if (java.lang.reflect.Modifier.isFinal(modifiers) || >+ java.lang.reflect.Modifier.isStatic(modifiers)) >+ break; > field.setAccessible(true); > if (debug) > logger.debug("field" + i + " has name: " + field.getName() + > " type: " + field.getType()); > Class fieldType = field.getType(); > if (fieldType == long.class) { >- field.setLong(oid, 10000L); >+ field.setLong(oid, 10000L + field.getLong(oid)); > } > if (fieldType == int.class) { >- field.setInt(oid, 10000); >+ field.setInt(oid, 10000 + field.getInt(oid)); > } > if (fieldType == short.class) { >- field.setShort(oid, (short)10000); >+ field.setShort(oid, (short)(10000 + field.getShort(oid))); > } > if (fieldType == byte.class) { >- field.setByte(oid, (byte)100); >+ field.setByte(oid, (byte)(100 + field.getByte(oid))); > } > if (fieldType == char.class) { >- field.setChar(oid, '0'); >+ field.setChar(oid, (char)(10 + field.getChar(oid))); > } > if (fieldType == String.class) { >- field.set(oid, "This is certainly a challenge"); >+ field.set(oid, "This is certainly a challenge" + (String)field.get(oid)); > } > if (fieldType == Integer.class) { >- field.set(oid, new Integer(10000)); >+ field.set(oid, new Integer(10000 + ((Integer)field.get(oid)).intValue())); > } > if (fieldType == Long.class) { >- field.set(oid, new Long(10000L)); >+ field.set(oid, new Long(10000L + ((Long)field.get(oid)).longValue())); > } > if (fieldType == Short.class) { >- field.set(oid, new Short((short)10000)); >+ field.set(oid, new Short((short)(10000 + ((Short)field.get(oid)).shortValue()))); > } > if (fieldType == Byte.class) { >- field.set(oid, new Byte((byte)100)); >+ field.set(oid, new Byte((byte)(100 + ((Byte)field.get(oid)).byteValue()))); > } > if (fieldType == Character.class) { >- field.set(oid, new Character('0')); >+ field.set(oid, new Character((char)(10 + ((Character)(field.get(oid))).charValue()))); > } > } > } > > > > ------------------------------------------------------------------------ > > > Craig Russell > > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo > > 408 276-5638 mailto:Craig.Russell@sun.com > > P.S. A good JDO? O, Gasp! > > -- Michael Bouschen Tech@Spree Engineering GmbH mailto:mbo.tech@spree.de http://www.tech.spree.de/ Tel.:++49/30/235 520-33 Buelowstr. 66 Fax.:++49/30/2175 2012 D-10783 Berlin --------------020904040307060804020204--