[cp-patches] [generics] RFC: fix generics branch compilation on Darwin

2005-12-04 Thread Casey Marshall
java_lang_VMSystem.c references 'extern char **environ,' which isn't  
defined on Darwin. java_lang_VMProcess.c has a little #if that  
defines this to a special function (_NSGetEnviron) for Darwin; the  
attached patch does the same for VMSystem.


Does this look OK? I haven't tested this yet (I'm not entirely sure  
how to do so; I've heard that jamvm can run this branch, so I'm going  
to try that).


Index: native/jni/java-lang/java_lang_VMSystem.c
===
RCS file: 
/cvsroot/classpath/classpath/native/jni/java-lang/java_lang_VMSystem.c,v
retrieving revision 1.6.2.6
diff -u -b -B -r1.6.2.6 java_lang_VMSystem.c
--- native/jni/java-lang/java_lang_VMSystem.c   2 Aug 2005 20:12:40 -   
1.6.2.6
+++ native/jni/java-lang/java_lang_VMSystem.c   5 Dec 2005 05:52:44 -
@@ -42,6 +42,15 @@
 #include 
 #include 
 
+/* Some O/S's don't declare 'environ' */
+#if HAVE_CRT_EXTERNS_H
+/* Darwin does not have a variable named environ
+   but has a function which you can get the environ
+   variable with.  */
+#include 
+#define environ (*_NSGetEnviron())
+#endif /* HAVE_CRT_EXTERNS_H */
+
 /*
  * Class: java_lang_VMSystem
  * Method:setIn0
@@ -159,7 +168,9 @@
 Java_java_lang_VMSystem_environ (JNIEnv *env,
jclass klass __attribute__((__unused__)))
 {
+#if !HAVE_CRT_EXTERNS_H
   extern char** environ;
+#endif /* HAVE_CRT_EXTERNS_H */
   char **env_pointer;
   jobject variables;
   jclass list_class;
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: URL must accept null context

2005-12-04 Thread Guilhem Lavaux

Hi,

With some last patch URLs was not accepting anymore null contexts. I've 
inserted a new mauve test for that in URLTest.


ChangeLog entry:

2005-12-04  Guilhem Lavaux  <[EMAIL PROTECTED]>

* java/net/URL.java (URL): Check whether context is null before
accessing ph.

Index: java/net/URL.java
===
RCS file: /cvsroot/classpath/classpath/java/net/URL.java,v
retrieving revision 1.50
diff -u -r1.50 URL.java
--- java/net/URL.java   29 Nov 2005 18:17:46 -  1.50
+++ java/net/URL.java   4 Dec 2005 20:49:43 -
@@ -342,7 +342,7 @@
*/
   public URL(URL context, String spec) throws MalformedURLException
   {
-this(context, spec, context.ph);
+this(context, spec, (context == null) ? (URLStreamHandler)null : 
context.ph);
   }
 
   /**
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI : Instrumentation in the vm integration guide

2005-12-04 Thread Nicolas Geoffray

Hi Mark


Maybe explicitly say "for calling the
@code{InstrumentationImpl.callTransformers} when a class byte code is
defined with @code{ClassLoader.defineClass}"
So the vm implementer knows this is their job at the moment.

 


Allright added. I'm committing this in the main branch.


2005-12-04  Nicolas Geoffray  <[EMAIL PROTECTED]>

   * doc/vmintegration.texinfo: Added subsection in the classpath
   hooks for the VMInstrumentationImpl class.


Index: doc/vmintegration.texinfo
===
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.19
diff -u -r1.19 vmintegration.texinfo
--- doc/vmintegration.texinfo	15 Jul 2005 09:04:46 -	1.19
+++ doc/vmintegration.texinfo	4 Dec 2005 20:45:03 -
@@ -226,6 +226,7 @@
 * java.lang.VMRuntime::
 * java.lang.VMString::
 * java.lang.VMThread::
+* java.lang.VMInstrumentationImpl::
 @end menu
 
 @node java.lang.VMClass, java.lang.VMObject ,java.lang,java.lang
@@ -607,7 +608,7 @@
 A VM may implement this differently by implementing this method,
 which is @code{static} and the only one in @code{VMString}.
 
[EMAIL PROTECTED] java.lang.VMThread,, java.lang.VMString, java.lang
[EMAIL PROTECTED] java.lang.VMThread,java.lang.VMInstrumentationImpl, java.lang.VMString, java.lang
 @subsection @code{java.lang.VMThread}
 
 @code{VMThread} provides the link between Java's threads and the platform
@@ -682,6 +683,45 @@
 having returned true, and is thus deprecated as a result.
 @end itemize
 @end itemize
+
[EMAIL PROTECTED] java.lang.VMInstrumentationImpl,, java.lang.VMThread, java.lang
[EMAIL PROTECTED] @code{java.lang.VMInstrumentationImpl}
+
+The @code{java.lang.VMInstrumentationImpl} and
[EMAIL PROTECTED] provides an implementation of the
[EMAIL PROTECTED] interface. This interface is for java
+1.5 and is only in the generics branch.
+A @code{InstrumentationImpl} object should be given to any agent
+given in the command line (see the @code{java.lang.instrument} package
+documentation). A VM has to implement the static native methods of the
[EMAIL PROTECTED] class.
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{isRedefineClassesSupported()} -- Returns true if the JVM supports
+class redefinition.
[EMAIL PROTECTED] @code{redefineClasses()} -- Gives a set of classes with new bytecodes.
+The VM must redefine the classes by reading the new bytecodes.
[EMAIL PROTECTED] @code{getAllLoadedClass()} -- Returns an array of all loaded classes.
[EMAIL PROTECTED] @code{getInitiatedClass()} -- Returns an array of all classes loaded
+by a specific class loader.
[EMAIL PROTECTED] @code{getObjectSize()} -- Gives the size of an object.
[EMAIL PROTECTED] itemize
+
+When agents are defined, the VM has to call transformers of the
[EMAIL PROTECTED] object each time a class is loaded, eg a call to
[EMAIL PROTECTED] The @code{InstrumentationImpl} class defines
+a method that has to be called before reading a class file in the VM.
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{callTransformers} -- Calls each transformer registered to
+the @code{InstrumentationImpl} object and returns a new bytecode file.
[EMAIL PROTECTED] itemize
+
+No default implementation is provided in gnu classpath for the
[EMAIL PROTECTED] methods. A default implementation will perhaps
+be written, but it might break the @code{ClassLoader/VMClassLoader} interface
+for calling the @code{InstrumentationImpl.callTransformers} when a class byte
+code is defined with @code{ClassLoader.defineClass}.
 
 @node gnu.classpath, java.util, java.lang, Classpath Hooks
 @section @code{gnu.classpath}
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: Disallow unsecure copy/paste exchange

2005-12-04 Thread Meskauskas Audrius

Maybe yes.  The recent insecure approach comes from the historcal past.

Mark Wielaard wrote:


Hi,

After the last discussion about TransferHandler and security issues it
seemed safer to me to just disallow any copy/paste between untrusted
code paths as was suggested earlier.

2005-12-04  Mark Wielaard  <[EMAIL PROTECTED]>

   * javax/swing/TransferHandler
   (TransferAction.actionPerformed): Beep and return when clipboard
   is null.
   (getClipboard): Return null when access denied.
   (clipboard): Removed static field.

Committed,

Mark
 




Index: javax/swing/TransferHandler.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/TransferHandler.java,v
retrieving revision 1.12
diff -u -r1.12 TransferHandler.java
--- javax/swing/TransferHandler.java22 Nov 2005 16:07:57 -  1.12
+++ javax/swing/TransferHandler.java4 Dec 2005 19:50:34 -
@@ -1,5 +1,5 @@
/* TransferHandler.java --
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.

This file is part of GNU Classpath.

@@ -43,6 +43,7 @@
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
+import java.awt.Toolkit;
import java.io.Serializable;

public class TransferHandler implements Serializable
@@ -62,6 +63,13 @@
  TransferHandler transferHandler = component.getTransferHandler();
  Clipboard clipboard = getClipboard(component);

+  if (clipboard == null)
+   {
+ // Access denied!
+ Toolkit.getDefaultToolkit().beep();
+ return;
+   }
+
  if (command.equals(COMMAND_COPY))
transferHandler.exportToClipboard(component, clipboard, COPY);
  else if (command.equals(COMMAND_CUT))
@@ -76,8 +84,8 @@
}
  
/**

- * Get the system cliboard. If not available, create and return the 
VM-local
- * clipboard.
+ * Get the system cliboard or null if the caller isn't allowed to
+ * access the system clipboard.
 * 
 * @param component a component, used to get the toolkit.

 * @return the clipboard
@@ -85,22 +93,13 @@
private static Clipboard getClipboard(JComponent component)
{
  try
-{
-  SecurityManager sm = System.getSecurityManager();
-  if (sm != null)
-sm.checkSystemClipboardAccess();
-
-  // We may access the system clipboard.
-  return component.getToolkit().getSystemClipboard();
-}
-  catch (Exception e)
-{
-  // We may not access system clipboard.
-  // Create VM-local clipboard if none exists yet.
-  if (clipboard == null)
-clipboard = new Clipboard("Clipboard");
-  return clipboard;
-}
+   {
+ return component.getToolkit().getSystemClipboard();
+   }
+  catch (SecurityException se)
+   {
+ return null;
+   }
}
  }
  
@@ -118,12 +117,6 @@

  private static Action copyAction = new TransferAction(COMMAND_COPY);
  private static Action cutAction = new TransferAction(COMMAND_CUT);
  private static Action pasteAction = new TransferAction(COMMAND_PASTE);
-  
-  /**

-   * Clipboard if system clipboard may not be used.
-   * Package-private to avoid an accessor method.
-   */
-  static Clipboard clipboard;
  
  private int sourceActions;

  private Icon visualRepresentation;
 




___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches
 





___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: Disallow unsecure copy/paste exchange

2005-12-04 Thread Mark Wielaard
Hi,

After the last discussion about TransferHandler and security issues it
seemed safer to me to just disallow any copy/paste between untrusted
code paths as was suggested earlier.

2005-12-04  Mark Wielaard  <[EMAIL PROTECTED]>

* javax/swing/TransferHandler
(TransferAction.actionPerformed): Beep and return when clipboard
is null.
(getClipboard): Return null when access denied.
(clipboard): Removed static field.

Committed,

Mark
Index: javax/swing/TransferHandler.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/TransferHandler.java,v
retrieving revision 1.12
diff -u -r1.12 TransferHandler.java
--- javax/swing/TransferHandler.java	22 Nov 2005 16:07:57 -	1.12
+++ javax/swing/TransferHandler.java	4 Dec 2005 19:50:34 -
@@ -1,5 +1,5 @@
 /* TransferHandler.java --
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -43,6 +43,7 @@
 import java.awt.datatransfer.Transferable;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
+import java.awt.Toolkit;
 import java.io.Serializable;
 
 public class TransferHandler implements Serializable
@@ -62,6 +63,13 @@
   TransferHandler transferHandler = component.getTransferHandler();
   Clipboard clipboard = getClipboard(component);
 
+  if (clipboard == null)
+	{
+	  // Access denied!
+	  Toolkit.getDefaultToolkit().beep();
+	  return;
+	}
+
   if (command.equals(COMMAND_COPY))
 	transferHandler.exportToClipboard(component, clipboard, COPY);
   else if (command.equals(COMMAND_CUT))
@@ -76,8 +84,8 @@
 }
   
 /**
- * Get the system cliboard. If not available, create and return the VM-local
- * clipboard.
+ * Get the system cliboard or null if the caller isn't allowed to
+ * access the system clipboard.
  * 
  * @param component a component, used to get the toolkit.
  * @return the clipboard
@@ -85,22 +93,13 @@
 private static Clipboard getClipboard(JComponent component)
 {
   try
-{
-  SecurityManager sm = System.getSecurityManager();
-  if (sm != null)
-sm.checkSystemClipboardAccess();
-
-  // We may access the system clipboard.
-  return component.getToolkit().getSystemClipboard();
-}
-  catch (Exception e)
-{
-  // We may not access system clipboard.
-  // Create VM-local clipboard if none exists yet.
-  if (clipboard == null)
-clipboard = new Clipboard("Clipboard");
-  return clipboard;
-}
+	{
+	  return component.getToolkit().getSystemClipboard();
+	}
+  catch (SecurityException se)
+	{
+	  return null;
+	}
 }
   }
   
@@ -118,12 +117,6 @@
   private static Action copyAction = new TransferAction(COMMAND_COPY);
   private static Action cutAction = new TransferAction(COMMAND_CUT);
   private static Action pasteAction = new TransferAction(COMMAND_PASTE);
-  
-  /**
-   * Clipboard if system clipboard may not be used.
-   * Package-private to avoid an accessor method.
-   */
-  static Clipboard clipboard;
   
   private int sourceActions;
   private Icon visualRepresentation;


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 : Instrumentation in the vm integration guide

2005-12-04 Thread Mark Wielaard
Hi Nicolas,

On Sun, 2005-12-04 at 16:20 +0100, Nicolas Geoffray wrote:
> 2005-12-04  Nicolas Geoffray  <[EMAIL PROTECTED]>
>
> * doc/vmintegration.texinfo: Added subsection in the classpath
> hooks for the VMInstrumentationImpl class.

Thanks for writing this.

Two small comments:

> @@ -681,7 +682,43 @@
>  frames in the thread.  This depends on the deprecated method @code{suspend()}
>  having returned true, and is thus deprecated as a result.
>  @end itemize
> [EMAIL PROTECTED] itemize
> +
> [EMAIL PROTECTED] java.lang.VMInstrumentationImpl,, java.lang.VMThread, 
> java.lang
> [EMAIL PROTECTED] @code{java.lang.VMInstrumentationImpl}

You accidentally removed a @end itemize.

> +No default implementation is provided in gnu classpath for the
> [EMAIL PROTECTED] method. A default implementation will perhaps
> +be written, but it might break the @code{ClassLoader/VMClassLoader} 
> interface.

Maybe explicitly say "for calling the
@code{InstrumentationImpl.callTransformers} when a class byte code is
defined with @code{ClassLoader.defineClass}"
So the vm implementer knows this is their job at the moment.

Please do check this in on the main cvs branch (trunk) so it is not just
in the generics branch documentation.

Thanks,

Mark


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


[cp-patches] RFC : Instrumentation in the vm integration guide

2005-12-04 Thread Nicolas Geoffray

Hi,

Here's a small documentation on how to use the instrumentation
functionnality in gnu classpath generics for vm implementers.
I added at the end that default implementation might break the
ClassLoader/VMClassLoader interface.

2005-12-04  Nicolas Geoffray  <[EMAIL PROTECTED]>
  
   * doc/vmintegration.texinfo: Added subsection in the 
classpath

   hooks for the VMInstrumentationImpl class.
Index: doc/vmintegration.texinfo
===
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.19
diff -u -r1.19 vmintegration.texinfo
--- doc/vmintegration.texinfo	15 Jul 2005 09:04:46 -	1.19
+++ doc/vmintegration.texinfo	4 Dec 2005 15:15:52 -
@@ -226,6 +226,7 @@
 * java.lang.VMRuntime::
 * java.lang.VMString::
 * java.lang.VMThread::
+* java.lang.VMInstrumentationImpl::
 @end menu
 
 @node java.lang.VMClass, java.lang.VMObject ,java.lang,java.lang
@@ -607,7 +608,7 @@
 A VM may implement this differently by implementing this method,
 which is @code{static} and the only one in @code{VMString}.
 
[EMAIL PROTECTED] java.lang.VMThread,, java.lang.VMString, java.lang
[EMAIL PROTECTED] java.lang.VMThread,java.lang.VMInstrumentationImpl, java.lang.VMString, java.lang
 @subsection @code{java.lang.VMThread}
 
 @code{VMThread} provides the link between Java's threads and the platform
@@ -681,7 +682,43 @@
 frames in the thread.  This depends on the deprecated method @code{suspend()}
 having returned true, and is thus deprecated as a result.
 @end itemize
[EMAIL PROTECTED] itemize
+
[EMAIL PROTECTED] java.lang.VMInstrumentationImpl,, java.lang.VMThread, java.lang
[EMAIL PROTECTED] @code{java.lang.VMInstrumentationImpl}
+
+The @code{java.lang.VMInstrumentationImpl} and
[EMAIL PROTECTED] provides an implementation of the
[EMAIL PROTECTED] interface. This interface is for java
+1.5 and is only in the generics branch.
+A @code{InstrumentationImpl} object should be given to any agent
+given in the command line (see the @code{java.lang.instrument} package
+documentation). A VM has to implement the static native methods of the
[EMAIL PROTECTED] class.
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{isRedefineClassesSupported()} -- Returns if the JVM supports
+class redefinition.
[EMAIL PROTECTED] @code{redefineClasses()} -- Gives a set of classes with new bytecodes.
+The VM must redefine the classes by reading the new bytecodes.
[EMAIL PROTECTED] @code{getAllLoadedClass()} -- Returns an array of all loaded classes.
[EMAIL PROTECTED] @code{getInitiatedClass()} -- Returns an array of all classes loaded
+by a specific class loader.
[EMAIL PROTECTED] @code{getObjectSize()} -- Gives the size of an object.
[EMAIL PROTECTED] itemize
+
+When agents are defined, the VM has to call transformers of the
[EMAIL PROTECTED] object each time a class is loaded, eg a call to
[EMAIL PROTECTED] The @code{InstrumentationImpl} class defines
+a method that has to be called before reading a class file in the VM.
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{callTransformers} -- Calls each transformer registered to
+the @code{InstrumentationImpl} object and returns a new bytecode file.
[EMAIL PROTECTED] itemize
+
+No default implementation is provided in gnu classpath for the
[EMAIL PROTECTED] method. A default implementation will perhaps
+be written, but it might break the @code{ClassLoader/VMClassLoader} interface.
 
 @node gnu.classpath, java.util, java.lang, Classpath Hooks
 @section @code{gnu.classpath}
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] [generics] FYI: New Instrumentation parameter to VMInstrumentationImpl.redefineClasses

2005-12-04 Thread Nicolas Geoffray
Here's a fix that eases implementation of the 
VMInstrumentationImpl.redefineClasses
method. The VM might not want to keep the Instrument object, therefore 
it must

be given explicitely to the VMInstrumentationImpl.redefineClasses method

2005-12-04  Nicolas Geoffray  <[EMAIL PROTECTED]>

* vm/reference/java/lang/VMInstrumentationImpl.java
(redefineClasses): Added an extra parameter of type
java.lang.instrument.Instrument.
*java/lang/InstrumentationImpl.java
(redefineClasses): Added the Instrumentation object
to the arguments of VMInstrumentationImpl.redefineClasses
call.


Index: java/lang/InstrumentationImpl.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/Attic/InstrumentationImpl.java,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 InstrumentationImpl.java
--- java/lang/InstrumentationImpl.java	3 Dec 2005 15:26:35 -	1.1.2.1
+++ java/lang/InstrumentationImpl.java	4 Dec 2005 13:01:02 -
@@ -154,7 +154,7 @@
 if (!isRedefineClassesSupported())
   throw new UnsupportedOperationException();
 
-VMInstrumentationImpl.redefineClasses(definitions);
+VMInstrumentationImpl.redefineClasses(this, definitions);
   }
 
 
Index: vm/reference/java/lang/VMInstrumentationImpl.java
===
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/Attic/VMInstrumentationImpl.java,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 VMInstrumentationImpl.java
--- vm/reference/java/lang/VMInstrumentationImpl.java	3 Dec 2005 15:26:35 -	1.1.2.1
+++ vm/reference/java/lang/VMInstrumentationImpl.java	4 Dec 2005 13:01:20 -
@@ -40,6 +40,7 @@
 package java.lang;
 
 import java.lang.instrument.ClassDefinition;
+import java.lang.instrument.Instrumentation;
 
 /**
  * @author Nicolas Geoffray ([EMAIL PROTECTED])
@@ -59,6 +60,7 @@
* Redefines classes given as parameters. The method has to call
* the callTransformers from InstrumentationImpl
*
+   * @param inst an instrumentation object
* @param definitions an array of bytecode<->class correspondance
*
* @throws ClassNotFoundException if a class cannot be found 
@@ -74,7 +76,8 @@
* classes
* @throws LinkageError if a linkage error occurs 
*/
-  static native void redefineClasses(ClassDefinition[] definitions);
+  static native void redefineClasses(Instrumentation inst,
+  ClassDefinition[] definitions);
  
   /**
* Get all the classes loaded by the JVM.
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] [generics] RFC : implementation of jjava.lang.instrument package

2005-12-04 Thread Nicolas Geoffray

Hi Christian,

Christian Thalinger wrote:


On Fri, 2005-12-02 at 12:22 +0100, Nicolas Geoffray wrote:
 


gnu/java/lang/instrument. Would you like InstrumentationImpl
to be in vm/reference/java/lang/InsutrumentationImpl? This sounds
weird. We could also make the callTransformers method public.
   



I think it's very helpful for vm implementors that all vm interface
stuff is _only_ located in vm/reference.  Just my 2 cents...

 


I couldn't agree more. What surprised me is not the vm/reference/*
emplacement Mark suggested, but that VMInstrumentationImpl
and Instrumentation had to go in the java.lang package, whereas
I was more thinking to gnu.java.lang package. But Mark is right
when he says it will be easier with security and package private
method issues to have the files in the java.lang package.

Cheers,
Nicolas



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches