From dev-return-4459-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Wed Jun 06 16:29:48 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 9347 invoked from network); 6 Jun 2007 16:29:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jun 2007 16:29:47 -0000 Received: (qmail 45278 invoked by uid 500); 6 Jun 2007 16:29:50 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 45132 invoked by uid 500); 6 Jun 2007 16:29:50 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 45123 invoked by uid 99); 6 Jun 2007 16:29:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2007 09:29:50 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2007 09:29:46 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id D94D9714163 for ; Wed, 6 Jun 2007 09:29:25 -0700 (PDT) Message-ID: <9094947.1181147365871.JavaMail.jira@brutus> Date: Wed, 6 Jun 2007 09:29:25 -0700 (PDT) From: "Jonathan Feinberg (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-251) org.apache.openjpa.enhance.Reflection.getDeclaredMethod() has undefined behavior, leading to VM-dependent crashes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org org.apache.openjpa.enhance.Reflection.getDeclaredMethod() has undefined behavior, leading to VM-dependent crashes ----------------------------------------------------------------------------------------------------------------- Key: OPENJPA-251 URL: https://issues.apache.org/jira/browse/OPENJPA-251 Project: OpenJPA Issue Type: Bug Components: jpa Affects Versions: 1.0.0 Environment: Sun JDK 6.01 Reporter: Jonathan Feinberg Given public interface A { Object getId(); } @Entity public class B implements A { @Id public String getId() { return "foo"; } } B.class.getDeclaredMethods() will include both "public java.lang.String B.getId()" and "public java.lang.Object B.getId()". The order in which these two methods appear is NOT DEFINED! Because org.apache.openjpa.enhance.Reflection.getDeclaredMethod() returns the first matching method, and because that method might well be the abstract one retuning Object, OpenJPA will complain that it cannot persist an ID with a non-explicit strategy, and throw up. Class.getDeclaredMethod() (note singular, not plural) is defined to return the method with the most specific return type under these circumstances, and should therefore be used. Here's my implementation of Reflection.getDeclaredMethod: private static Method getDeclaredMethod(Class cls, String name, Class param) { Class[] params = param == null ? new Class[0] : new Class[] { param }; try { return cls.getDeclaredMethod(name, params); } catch (Exception e) { return null; } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.