[cp-patches] [generics] Enum#valueOf implementation
Thanks Robert for reminding me. Here's the unified diff. Again my question if someone can commit this, or give me CVS access rights. Ewout Robert Schuster wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Ewout, welcome onboard! (Looks like Mark should add Savannah user epr to the project.) Your 'patch' does not really look like a unified diff. What you send to classpath-patches should be: - - a unified diff of all the changes source code files, scripts etc (not the ChangeLog) as an attachment - - a ChangeLog entry describing all the details (describe what was done not why) We have a detailed Patch Submission Guide[0] in our mediation wiki. Have a look at it. cu Robert [0] - http://developer.classpath.org/mediation/ClasspathFirstSteps#head-a8b2520531202f1acefb9cb1c8b540999e4eaf21 Ewout Prangsma wrote: I've implemented java.lang.Enum#valueOf in the generics branch. Can someone with CVS access verify and commit this. PS. My FSF paperwork is all done. Thanks Ewout @SuppressWarnings("unchecked") public static S extends EnumS Enum valueOf(ClassS etype, String s) { if (etype == null || s == null) throw new NullPointerException(); try { return (S) etype.getDeclaredField(s).get(null); } catch (NoSuchFieldException exception) { throw new IllegalArgumentException(s); } catch (IllegalAccessException exception) { throw new Error("Unable to access Enum class"); } } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFC4ZQwG9cfwmwwEtoRArszAJ0WQprbEl9CLqtPoOVPfMl1Y7ImVACfaAcQ ZhbgazmSB41BNcRmz3MgQ+0= =rSv+ -END PGP SIGNATURE- --- java\lang\Enum.java Mon Mar 21 14:10:17 2005 +++ ..\jnode\core\src\classpath\5.0\java\lang\Enum.java Fri Jul 22 19:37:59 2005 @@ -38,6 +38,8 @@ package java.lang; import java.io.Serializable; +import java.io.ObjectInputStream.GetField; +import java.lang.reflect.InvocationTargetException; /** * @since 1.5 @@ -60,12 +62,19 @@ this.ordinal = ordinal; } - public static S extends EnumS Enum valueOf(ClassS etype, String s) - { -if (etype == null || s == null) - throw new NullPointerException(); -return null; // FIXME - } + // @classpath-bugfix Implemented this method + @SuppressWarnings(unchecked) + public static S extends EnumS Enum valueOf(ClassS etype, String s) { +if (etype == null || s == null) +throw new NullPointerException(); +try { +return (S) etype.getDeclaredField(s).get(null); +} catch (NoSuchFieldException exception) { +throw new IllegalArgumentException(s); +} catch (IllegalAccessException exception) { +throw new Error(Unable to access Enum class); +} +} public final boolean equals(Object o) { ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: gtk-plaf cleanup
Hi, As discussed on the list and on irc this cleans up the lib/Makefile.am dist-hook to not remove anything from standard.omit. And removes the gtk-plaf files which actually did compile, but didn't work. Consensus was that it was better to start over with a clean gtk-plaf then to reuse these files (sorry Brian). 2005-07-23 Mark Wielaard [EMAIL PROTECTED] * lib/standard.omit: Don't omit gnu/javax/swing/plaf/gtk files. * lib/Makefile.am (dist-hook): Don't remove standard.omit dirs. * gnu/javax/swing/plaf/gtk/GtkBorders.java: Removed. * gnu/javax/swing/plaf/gtk/GtkCheckBoxUI.java: Likewise. * gnu/javax/swing/plaf/gtk/GtkIconFactory.java: Likewise. * gnu/javax/swing/plaf/gtk/GtkLookAndFeel.java: Likewise. * gnu/javax/swing/plaf/gtk/GtkRadioButtonUI.java: Likewise. * gnu/javax/swing/plaf/gtk/GtkSliderUI.java: Likewise. * gnu/javax/swing/plaf/gtk/README: Likewise. * gnu/javax/swing/plaf/gtk/SliderTest.java: Likewise. Committed, Mark Index: lib/Makefile.am === RCS file: /cvsroot/classpath/classpath/lib/Makefile.am,v retrieving revision 1.94 diff -u -r1.94 Makefile.am --- lib/Makefile.am 12 Jul 2005 18:58:00 - 1.94 +++ lib/Makefile.am 24 Jul 2005 14:52:03 - @@ -148,5 +148,3 @@ $(FIND) $(top_distdir)/gnu $(top_distdir)/java $(top_distdir)/javax $(top_distdir)/org $(top_distdir)/vm -name class-dependencies.conf -print | xargs rm -f rm -f $(top_distdir)/gnu/classpath/Configuration.java rm -f $(top_distdir)/java/util/LocaleData.java -# Omit files listed in standard.omit. - ( cd $(top_distdir)/lib ; cat $(top_builddir)/lib/standard.omit | sed -e 's/\$$//' | sed -e 's/\/\.\*//' | xargs rm -fr ) Index: lib/standard.omit === RCS file: /cvsroot/classpath/classpath/lib/standard.omit,v retrieving revision 1.41 diff -u -r1.41 standard.omit --- lib/standard.omit 15 Jul 2005 11:17:45 - 1.41 +++ lib/standard.omit 24 Jul 2005 14:52:03 - @@ -1,4 +1,2 @@ ../gnu/test/.*$ -../gnu/javax/swing/plaf/gtk/.*java$ -../gnu/javax/swing/plaf/gtk/README$ ../gnu/classpath/jdwp/.*$ Index: gnu/javax/swing/plaf/gtk/GtkBorders.java === RCS file: gnu/javax/swing/plaf/gtk/GtkBorders.java diff -N gnu/javax/swing/plaf/gtk/GtkBorders.java --- gnu/javax/swing/plaf/gtk/GtkBorders.java 2 Jul 2005 20:32:15 - 1.4 +++ /dev/null 1 Jan 1970 00:00:00 - @@ -1,83 +0,0 @@ -/* GtkBorders.java - Copyright (c) 1999 by Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.javax.swing.plaf.gtk; -import java.awt.*; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.plaf.*; - -/** - * Optional class, can be used to define nifty borders. - * - * @author Brian Jones - * @see javax.swing.LookAndFeel - */ -public class GtkBorders -{ -public static class ButtonBorder extends AbstractBorder - implements UIResource -{ - private Border raised; // use by default - private Border lowered; // use this one when pressed - - // creat the border -public ButtonBorder() - { - raised = BorderFactory.createRaisedBevelBorder(); - lowered = BorderFactory.createLoweredBevelBorder(); - } - - //
[cp-patches] RFC: strtod patch from early 2004
I've recently moved to a 64-bit architecture (x86_64) and yesterday I encountered some problems building the generics branch with ecj on kaffe and Debian GNU/Linux. Namely, the MIN_DOUBLE value is not recognised as valid. Using parseDouble on this value shows that the fdlibm implementation of strtod reports an underflow and 0 is returned. This lead to me finding the following post: http://lists.gnu.org/archive/html/classpath/2004-01/msg00057.html Applying this patch solves the problem and the right value is returned. Does anyone know what the state of this patch is, and why it wasn't applied? It does solve the problem in this case, but I don't know how it fares in general. Any comments, and testing on some other platforms would be much appreciated. FWIW, the conversion also works with the platform strtod, so this is also an option (although again I don't know how general this is, and it has been disabled for cases where KISSME_LINUX_USER is not defined). Thanks, -- Andrew :-) Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments. See http://www.fsf.org/philosophy/no-word-attachments.html No software patents in Europe -- http://nosoftwarepatents.com Value your freedom, or you will lose it, teaches history. `Don't bother us with politics' respond those who don't want to learn. -- Richard Stallman Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... } signature.asc Description: This is a digitally signed message part ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] RFC: New JCL helper functions for RawData handling
Guilhem == Guilhem Lavaux [EMAIL PROTECTED] writes: Guilhem + rawDataClass = (*env)-FindClass (env, gnu/classpath/RawData64); At FOSDEM we talked about renaming these ... want to take it on? :-) Guilhem Could you be more specific ? A link to the discussion ? I may Guilhem take it on but I need to know what was decided. ;-) Maybe the discussion never got written down. Or maybe I just made it all up :-) libgcj had a class named RawData before Classpath, but with different semantics. libgcj's RawData is not a wrapper for a pointer but is instead a pointer itself, and it is specially treated by the compiler and the garbage collector. I've always thought it was confusing that Classpath had a class with the same name but different semantics. My suggestion would be to rename this class to Pointer, by analogy with the other boxed types like Integer and Long. Tom ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] Re: Serialization: readResolve and writeReplace in parent class
Mark == Mark Wielaard [EMAIL PROTECTED] writes: You compile all of these. Then you go back and add 'private ... readResolve()' to B. Mark How precisely would you go back? Yeah, ignore that example. I was thinking about binary compatibility, but that is too complicated. Should C now really be using A's readResolve()? Mark No, it should use B's readResolve(). Doesn't it seem weird to use a method that is not inherited? It does to me. But, I don't know what is correct in this situation -- I'm just asking. Tom ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] RFC: New JCL helper functions for RawData handling
Tom Tromey wrote: Guilhem + rawDataClass = (*env)-FindClass (env, gnu/classpath/RawData64); At FOSDEM we talked about renaming these ... want to take it on? :-) Guilhem Could you be more specific ? A link to the discussion ? I may Guilhem take it on but I need to know what was decided. ;-) Maybe the discussion never got written down. Or maybe I just made it all up :-) libgcj had a class named RawData before Classpath, but with different semantics. libgcj's RawData is not a wrapper for a pointer but is instead a pointer itself, and it is specially treated by the compiler and the garbage collector. I've always thought it was confusing that Classpath had a class with the same name but different semantics. Yes; it was my fault, I introduced this as part of porting libxmlj to 64-bit architectures - not that I have any experience in this at all but it was the only thing I tried that worked. I did say at FOSDEM that it was a bad name choice. If the libgcj way is better we should use that instead since as I understand it it would save a layer of indirection, but perhaps it needs VM-specific support to work? Failing that, just renaming the class Pointer or PointerWrapper would also be better than the current state of affairs. -- Chris Burdess ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] [patch] make darwin 'work' with classpath
Hi all, the attached patch changes link behavior of darwin ppc and makes it work in reality. For detailed explanation please search the apple developer pages. In short, when building against a .so we have a module which is like an extension an not like a shared library as known on ppc linux. It is not possible to link against an extension/module/bundle. It's a longer story and I do not have the breath to expalin every detail right now. I'm certainly open to expalin it. With this test I can run the mauve tests and co quite successfully. I even can run some simple (sometimes bigger) gui apps with it. Regards, Andreas 2005-07-24 Andreas Tobler [EMAIL PROTECTED] * configure.ac (LIBVERSION): Check against darwin to set module 'no' for it. Modules under darwin are not linkable. See Apple docs. * configure: Regenerate Index: classpath/configure.ac === RCS file: /cvs/gcc/gcc/libjava/classpath/configure.ac,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 configure.ac --- classpath/configure.ac 16 Jul 2005 00:30:31 - 1.1.1.1 +++ classpath/configure.ac 24 Jul 2005 20:51:26 - @@ -21,7 +21,16 @@ dnl at which time we'll have to be more anal about such things dnl --- AC_SUBST(LIBVERSION, 0:0:0) -CLASSPATH_MODULE=-module -version-info ${LIBVERSION} -no-undefined +case $host_os in + darwin*) + cp_module= + ;; + *) + cp_module=-module + ;; +esac + +CLASSPATH_MODULE=${cp_module} -version-info ${LIBVERSION} -no-undefined AC_SUBST(CLASSPATH_MODULE) AC_PREREQ(2.59) ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: Implementation details of VMStackWalker
Mark Wielaard writes: On Fri, 2005-07-22 at 18:01 +0100, Andrew Haley wrote: Ingo Prötel writes: I just implemented VMStackWalker for our VM and have some questions. The reference implementation of 'getCallingClass()' and 'getCallingClassLoader()' just look at the third entry in the class context. Would it not be better to return the first class that is not assignable to the class in context[0] ? That way we could cope with classes that first call some private or protected classes an then ends up calling the stack walker. In gcj, we have a method called GetCallingClass(Class c). It searches firstly for a method declared in class c, then for a method not declared in c. We have found, after a certain amount of trouble, that this is the right way to do things; it means that an arbitrary number of stack frames can be between the direct caller of GetCallingClass and the user code, and it also means that you don't have to check for assignability, but for an exact match. I proposed something similar a while ago: http://lists.gnu.org/archive/html/classpath-patches/2005-01/msg00138.html Jeroen did object strongly to this approach though since he felt that having (and constructing) an extra argument for this function was too much overhead for runtimes that didn't need it to begin with. Well, that's up to the VM implementer. IMO trying to unify low-level stack walker code is unnecessary and leads to too many compromises; it's a merge too far. However, as for overhead -- I don't believe it. I doubt that not having this parameter saves anything much on any VM. Andrew. ___ Classpath mailing list Classpath@gnu.org http://lists.gnu.org/mailman/listinfo/classpath
Re: JNI assertion failure
Dalibor Topic wrote: Doesn't GetObjectClass change the state of env? If that's the case, it maybe shouldn't be an assert. Not sure what you mean.. but there is a bug: we need to delete the local native reference obtained by calling GetObjectClass. Attached is a better patch. Thanks, -Archie __ Archie Cobbs *CTO, Awarix* http://www.awarix.com Index: native/jni/classpath/native_state.c === RCS file: /cvsroot/classpath/classpath/native/jni/classpath/native_state.c,v retrieving revision 1.11 diff -u -r1.11 native_state.c --- native/jni/classpath/native_state.c 14 Jul 2005 22:07:02 - 1.11 +++ native/jni/classpath/native_state.c 24 Jul 2005 22:38:39 - @@ -36,6 +36,7 @@ exception statement from your version. */ #include stdlib.h +#include assert.h #include jni.h #include native_state.h @@ -165,6 +166,18 @@ *head = new_node; } +#ifndef NDEBUG +static void +cp_gtk_check_compat (JNIEnv * env, jobject obj, struct state_table *table) +{ + jclass objclazz; + + objclazz = (*env)-GetObjectClass(env, obj); + assert ((*env)-IsAssignableFrom(env, objclazz, table-clazz)); + (*env)-DeleteLocalRef(env, objclazz); +} +#endif + void cp_gtk_set_state_oid (JNIEnv * env, jobject lock, struct state_table *table, jint obj_id, void *state) @@ -214,6 +227,11 @@ cp_gtk_set_state (JNIEnv * env, jobject obj, struct state_table *table, void *state) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)-GetIntField (env, obj, table-hash); if ((*env)-ExceptionOccurred (env) != NULL) @@ -227,6 +245,11 @@ cp_gtk_get_state (JNIEnv * env, jobject obj, struct state_table *table) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)-GetIntField (env, obj, table-hash); if ((*env)-ExceptionOccurred (env) != NULL) @@ -239,6 +262,11 @@ cp_gtk_remove_state_slot (JNIEnv * env, jobject obj, struct state_table *table) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)-GetIntField (env, obj, table-hash); if ((*env)-ExceptionOccurred (env) != NULL) ___ Classpath mailing list Classpath@gnu.org http://lists.gnu.org/mailman/listinfo/classpath