From: <ls...@us...> - 2008-07-17 10:45:57
|
Revision: 4306 http://jnode.svn.sourceforge.net/jnode/?rev=4306&view=rev Author: lsantha Date: 2008-07-17 10:45:28 +0000 (Thu, 17 Jul 2008) Log Message: ----------- Integrated java.awt.Toolkit from OpenJDK. Added Paths: ----------- trunk/core/src/openjdk/java/java/awt/Toolkit.java Removed Paths: ------------- trunk/core/src/classpath/java/java/awt/Toolkit.java Deleted: trunk/core/src/classpath/java/java/awt/Toolkit.java =================================================================== --- trunk/core/src/classpath/java/java/awt/Toolkit.java 2008-07-17 10:15:31 UTC (rev 4305) +++ trunk/core/src/classpath/java/java/awt/Toolkit.java 2008-07-17 10:45:28 UTC (rev 4306) @@ -1,1535 +0,0 @@ -/* Toolkit.java -- AWT Toolkit superclass - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 - 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 java.awt; - -import gnu.classpath.SystemProperties; -import gnu.java.awt.AWTUtilities; -import gnu.java.awt.peer.GLightweightPeer; -import gnu.java.awt.peer.headless.HeadlessToolkit; - -import java.awt.datatransfer.Clipboard; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragGestureRecognizer; -import java.awt.dnd.DragSource; -import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.event.AWTEventListener; -import java.awt.event.AWTEventListenerProxy; -import java.awt.event.KeyEvent; -import java.awt.font.TextAttribute; -import java.awt.im.InputMethodHighlight; -import java.awt.image.ColorModel; -import java.awt.image.ImageObserver; -import java.awt.image.ImageProducer; -import java.awt.peer.ButtonPeer; -import java.awt.peer.CanvasPeer; -import java.awt.peer.CheckboxMenuItemPeer; -import java.awt.peer.CheckboxPeer; -import java.awt.peer.ChoicePeer; -import java.awt.peer.DialogPeer; -import java.awt.peer.FileDialogPeer; -import java.awt.peer.FontPeer; -import java.awt.peer.FramePeer; -import java.awt.peer.LabelPeer; -import java.awt.peer.LightweightPeer; -import java.awt.peer.ListPeer; -import java.awt.peer.MenuBarPeer; -import java.awt.peer.MenuItemPeer; -import java.awt.peer.MenuPeer; -import java.awt.peer.MouseInfoPeer; -import java.awt.peer.PanelPeer; -import java.awt.peer.PopupMenuPeer; -import java.awt.peer.ScrollPanePeer; -import java.awt.peer.ScrollbarPeer; -import java.awt.peer.TextAreaPeer; -import java.awt.peer.TextFieldPeer; -import java.awt.peer.WindowPeer; -import java.awt.peer.DesktopPeer; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.File; -import java.io.FileInputStream; -import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Map; -import java.util.Properties; -import java.util.StringTokenizer; -import org.jnode.vm.annotation.SharedStatics; - -/** - * The AWT system uses a set of native peer objects to implement its - * widgets. These peers are provided by a peer toolkit, that is accessed - * via a subclass of this superclass. The system toolkit is retrieved - * by the static methods <code>getDefaultToolkit</code>. This method - * determines the system toolkit by examining the system property - * <code>awt.toolkit</code>. That property is set to the name of the - * <code>Toolkit</code> subclass for the specified peer set. If the - * <code>awt.toolkit</code> property is not set, then the default - * toolkit <code>gnu.java.awt.peer.gtk.GtkToolkit</code> is used. This - * toolkit creates its peers using the GTK+ toolkit. - * - * @author Aaron M. Renn (ar...@ur...) - */ -@SharedStatics -public abstract class Toolkit -{ - /** The default toolkit name. */ - private static String default_toolkit_name - = gnu.classpath.Configuration.default_awt_peer_toolkit; - - /** - * The toolkit in use. Once we load it, we don't ever change it - * if the awt.toolkit property is set. - */ - private static Toolkit toolkit; - - /** The toolkit properties. */ - private static Properties props = new Properties(); - - protected final Map<String,Object> desktopProperties = - new Hashtable<String,Object>(); - - protected final PropertyChangeSupport desktopPropsSupport - = new PropertyChangeSupport(this); - - /** - * All registered AWTEventListener objects. This is package private, so the - * event queue can efficiently access this list. - */ - AWTEventListenerProxy[] awtEventListeners; - - /** - * The shared peer for all lightweight components. - */ - private GLightweightPeer lightweightPeer; - - /** - * Default constructor for subclasses. - */ - public Toolkit() - { - awtEventListeners = new AWTEventListenerProxy[0]; - } - - /** - * Creates a peer object for the specified <code>Button</code>. - * - * @param target The <code>Button</code> to create the peer for. - * - * @return The peer for the specified <code>Button</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract ButtonPeer createButton(Button target); - - /** - * Creates a peer object for the specified <code>TextField</code>. - * - * @param target The <code>TextField</code> to create the peer for. - * - * @return The peer for the specified <code>TextField</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract TextFieldPeer createTextField(TextField target); - - /** - * Creates a peer object for the specified <code>Label</code>. - * - * @param target The <code>Label</code> to create the peer for. - * - * @return The peer for the specified <code>Label</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract LabelPeer createLabel(Label target); - - /** - * Creates a peer object for the specified <code>List</code>. - * - * @param target The <code>List</code> to create the peer for. - * - * @return The peer for the specified <code>List</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract ListPeer createList(List target); - - /** - * Creates a peer object for the specified <code>Checkbox</code>. - * - * @param target The <code>Checkbox</code> to create the peer for. - * - * @return The peer for the specified <code>Checkbox</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract CheckboxPeer createCheckbox(Checkbox target); - - /** - * Creates a peer object for the specified <code>Scrollbar</code>. - * - * @param target The <code>Scrollbar</code> to create the peer for. - * - * @return The peer for the specified <code>Scrollbar</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract ScrollbarPeer createScrollbar(Scrollbar target); - - /** - * Creates a peer object for the specified <code>ScrollPane</code>. - * - * @param target The <code>ScrollPane</code> to create the peer for. - * - * @return The peer for the specified <code>ScrollPane</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract ScrollPanePeer createScrollPane(ScrollPane target); - - /** - * Creates a peer object for the specified <code>TextArea</code>. - * - * @param target The <code>TextArea</code> to create the peer for. - * - * @return The peer for the specified <code>TextArea</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract TextAreaPeer createTextArea(TextArea target); - - /** - * Creates a peer object for the specified <code>Choice</code>. - * - * @param target The <code>Choice</code> to create the peer for. - * - * @return The peer for the specified <code>Choice</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract ChoicePeer createChoice(Choice target); - - /** - * Creates a peer object for the specified <code>Frame</code>. - * - * @param target The <code>Frame</code> to create the peer for. - * - * @return The peer for the specified <code>Frame</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract FramePeer createFrame(Frame target); - - /** - * Creates a peer object for the specified <code>Canvas</code>. - * - * @param target The <code>Canvas</code> to create the peer for. - * - * @return The peer for the specified <code>Canvas</code> object. - */ - protected abstract CanvasPeer createCanvas(Canvas target); - - /** - * Creates a peer object for the specified <code>Panel</code>. - * - * @param target The <code>Panel</code> to create the peer for. - * - * @return The peer for the specified <code>Panel</code> object. - */ - protected abstract PanelPeer createPanel(Panel target); - - /** - * Creates a peer object for the specified <code>Window</code>. - * - * @param target The <code>Window</code> to create the peer for. - * - * @return The peer for the specified <code>Window</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract WindowPeer createWindow(Window target); - - /** - * Creates a peer object for the specified <code>Dialog</code>. - * - * @param target The dialog to create the peer for - * - * @return The peer for the specified font name. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract DialogPeer createDialog(Dialog target); - - /** - * Creates a peer object for the specified <code>MenuBar</code>. - * - * @param target The <code>MenuBar</code> to create the peer for. - * - * @return The peer for the specified <code>MenuBar</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract MenuBarPeer createMenuBar(MenuBar target); - - /** - * Creates a peer object for the specified <code>Menu</code>. - * - * @param target The <code>Menu</code> to create the peer for. - * - * @return The peer for the specified <code>Menu</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract MenuPeer createMenu(Menu target); - - /** - * Creates a peer object for the specified <code>PopupMenu</code>. - * - * @param target The <code>PopupMenu</code> to create the peer for. - * - * @return The peer for the specified <code>PopupMenu</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract PopupMenuPeer createPopupMenu(PopupMenu target); - - /** - * Creates a peer object for the specified <code>MenuItem</code>. - * - * @param target The <code>MenuItem</code> to create the peer for. - * - * @return The peer for the specified <code>MenuItem</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract MenuItemPeer createMenuItem(MenuItem target); - - /** - * Returns a MouseInfoPeer. - * The default implementation of this method throws - * UnsupportedOperationException. - * - * Toolkit implementations should overload this if possible, however. - */ - protected MouseInfoPeer getMouseInfoPeer() - { - throw new UnsupportedOperationException("No mouse info peer."); - } - - /** - * Creates a peer object for the specified <code>FileDialog</code>. - * - * @param target The <code>FileDialog</code> to create the peer for. - * - * @return The peer for the specified <code>FileDialog</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract FileDialogPeer createFileDialog(FileDialog target); - - /** - * Creates a peer object for the specified <code>CheckboxMenuItem</code>. - * - * @param target The <code>CheckboxMenuItem</code> to create the peer for. - * - * @return The peer for the specified <code>CheckboxMenuItem</code> object. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected abstract CheckboxMenuItemPeer - createCheckboxMenuItem(CheckboxMenuItem target); - - /** - * Creates a peer object for the specified <code>Component</code>. The - * peer returned by this method is not a native windowing system peer - * with its own native window. Instead, this method allows the component - * to draw on its parent window as a "lightweight" widget. - * - * @param target The <code>Component</code> to create the peer for. - * - * @return The peer for the specified <code>Component</code> object. - */ - protected LightweightPeer createComponent(Component target) - { - if (lightweightPeer == null) - lightweightPeer = new GLightweightPeer(); - return lightweightPeer; - } - - /** - * Creates a peer object for the specified font name. - * - * @param name The font to create the peer for. - * @param style The font style to create the peer for. - * - * @return The peer for the specified font name. - * - * @deprecated - */ - protected abstract FontPeer getFontPeer(String name, int style); - - /** - * Copies the current system colors into the specified array. This is - * the interface used by the <code>SystemColor</code> class. Although - * this method fills in the array with some default colors a real Toolkit - * should override this method and provide real system colors for the - * native GUI platform. - * - * @param systemColors The array to copy the system colors into. - * It must be at least 26 elements. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - * - * @see java.awt.SystemColor - */ - protected void loadSystemColors(int systemColors[]) - { - systemColors[SystemColor.DESKTOP] = 0xFF005C5C; - systemColors[SystemColor.ACTIVE_CAPTION] = 0xFF000080; - systemColors[SystemColor.ACTIVE_CAPTION_TEXT] = 0xFFFFFFFF; - systemColors[SystemColor.ACTIVE_CAPTION_BORDER] = 0xFFC0C0C0; - systemColors[SystemColor.INACTIVE_CAPTION] = 0xFF808080; - systemColors[SystemColor.INACTIVE_CAPTION_TEXT] = 0xFFC0C0C0; - systemColors[SystemColor.INACTIVE_CAPTION_BORDER] = 0xFFC0C0C0; - systemColors[SystemColor.WINDOW] = 0xFFFFFFFF; - systemColors[SystemColor.WINDOW_BORDER] = 0xFF000000; - systemColors[SystemColor.WINDOW_TEXT] = 0xFF000000; - systemColors[SystemColor.MENU] = 0xFFC0C0C0; - systemColors[SystemColor.MENU_TEXT] = 0xFF000000; - systemColors[SystemColor.TEXT] = 0xFFC0C0C0; - systemColors[SystemColor.TEXT_TEXT] = 0xFF000000; - systemColors[SystemColor.TEXT_HIGHLIGHT] = 0xFF000090; - systemColors[SystemColor.TEXT_HIGHLIGHT_TEXT] = 0xFFFFFFFF; - systemColors[SystemColor.TEXT_INACTIVE_TEXT] = 0xFF808080; - systemColors[SystemColor.CONTROL] = 0xFFC0C0C0; - systemColors[SystemColor.CONTROL_TEXT] = 0xFF000000; - systemColors[SystemColor.CONTROL_HIGHLIGHT] = 0xFFFFFFFF; - systemColors[SystemColor.CONTROL_LT_HIGHLIGHT] = 0xFFE0E0E0; - systemColors[SystemColor.CONTROL_SHADOW] = 0xFF808080; - systemColors[SystemColor.CONTROL_DK_SHADOW] = 0xFF000000; - systemColors[SystemColor.SCROLLBAR] = 0xFFE0E0E0; - systemColors[SystemColor.INFO] = 0xFFE0E000; - systemColors[SystemColor.INFO_TEXT] = 0xFF000000; - } - - /** - * @since 1.4 - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public void setDynamicLayout(boolean dynamic) - { - } - - /** - * @since 1.4 - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - protected boolean isDynamicLayoutSet() - { - return false; - } - - /** - * @since 1.4 - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public boolean isDynamicLayoutActive() - { - return false; - } - - /** - * Returns the dimensions of the screen in pixels. - * - * @return The dimensions of the screen in pixels. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public abstract Dimension getScreenSize(); - - /** - * Returns the screen resolution in dots per square inch. - * - * @return The screen resolution in dots per square inch. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public abstract int getScreenResolution(); - - /** - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - * - * @since 1.4 - */ - public Insets getScreenInsets(GraphicsConfiguration gc) - { - return new Insets(0, 0, 0, 0); - } - - /** - * Returns the color model of the screen. - * - * @return The color model of the screen. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public abstract ColorModel getColorModel(); - - /** - * Returns the names of the available fonts. - * - * @return The names of the available fonts. - * - * @deprecated - */ - public abstract String[] getFontList(); - - /** - * Return the font metrics for the specified font - * - * @param name The name of the font to return metrics for. - * - * @return The requested font metrics. - * - * @deprecated - */ - public abstract FontMetrics getFontMetrics(Font name); - - /** - * Flushes any buffered data to the screen so that it is in sync with - * what the AWT system has drawn to it. - */ - public abstract void sync(); - - /** - * Returns an instance of the default toolkit. The default toolkit is - * the subclass of <code>Toolkit</code> specified in the system property - * <code>awt.toolkit</code>, or <code>gnu.java.awt.peer.gtk.GtkToolkit</code> - * if the property is not set. - * - * @return An instance of the system default toolkit. - * - * @throws AWTError If the toolkit cannot be loaded. - */ - public static synchronized Toolkit getDefaultToolkit() - { - if (toolkit != null) - return toolkit; - - String toolkit_name = SystemProperties.getProperty("awt.toolkit", - default_toolkit_name); - try - { - // @classpath-bugfix-22969 Replace Class.forName - //Class cls = Class.forName(toolkit_name); - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Class cls = cl.loadClass(toolkit_name); - // @classpath-bugfix-end - Object obj = cls.newInstance(); - if (!(obj instanceof Toolkit)) - throw new AWTError(toolkit_name + " is not a subclass of " + - "java.awt.Toolkit"); - toolkit = (Toolkit) obj; - - initAccessibility(); - return toolkit; - } - catch (ThreadDeath death) - { - throw death; - } - catch (Throwable t) - { - // Check for the headless property. - if (GraphicsEnvironment.isHeadless()) - { - toolkit = new HeadlessToolkit(); - return toolkit; - } - else - { - AWTError e = new AWTError("Cannot load AWT toolkit: " - + toolkit_name); - throw (AWTError) e.initCause(t); - } - } - } - - // @classpath-bugfix - /** - * Flush a previously instantiate toolkit. - */ - protected static void clearDefaultToolkit() { - toolkit = null; - } - // @classpath-bugfix-end - - /** - * Returns an image from the specified file, which must be in a - * recognized format. Supported formats vary from toolkit to toolkit. - * - * @return name The name of the file to read the image from. - */ - public abstract Image getImage(String name); - - /** - * Returns an image from the specified URL, which must be in a - * recognized format. Supported formats vary from toolkit to toolkit. - * - * @return url The URl to read the image from. - */ - public abstract Image getImage(URL url); - - public abstract Image createImage(String filename); - - public abstract Image createImage(URL url); - - /** - * Readies an image to be rendered on the screen. The width and height - * values can be set to the default sizes for the image by passing -1 - * in those parameters. - * - * @param image The image to prepare for rendering. - * @param width The width of the image. - * @param height The height of the image. - * @param observer The observer to receive events about the preparation - * process. - * - * @return <code>true</code> if the image is already prepared for rendering, - * <code>false</code> otherwise. - */ - public abstract boolean prepareImage(Image image, int width, int height, - ImageObserver observer); - - /** - * Checks the status of specified image as it is being readied for - * rendering. - * - * @param image The image to prepare for rendering. - * @param width The width of the image. - * @param height The height of the image. - * @param observer The observer to receive events about the preparation - * process. - * - * @return A union of the bitmasks from - * <code>java.awt.image.ImageObserver</code> that indicates the current - * state of the imaging readying process. - */ - public abstract int checkImage(Image image, int width, int height, - ImageObserver observer); - - /** - * Creates an image using the specified <code>ImageProducer</code> - * - * @param producer The <code>ImageProducer</code> to create the image from. - * - * @return The created image. - */ - public abstract Image createImage(ImageProducer producer); - - /** - * Creates an image from the specified byte array. The array must be in - * a recognized format. Supported formats vary from toolkit to toolkit. - * - * @param data The raw image data. - * - * @return The created image. - */ - public Image createImage(byte[] data) - { - return createImage(data, 0, data.length); - } - - /** - * Creates an image from the specified portion of the byte array passed. - * The array must be in a recognized format. Supported formats vary from - * toolkit to toolkit. - * - * @param data The raw image data. - * @param offset The offset into the data where the image data starts. - * @param len The length of the image data. - * - * @return The created image. - */ - public abstract Image createImage(byte[] data, int offset, int len); - - /** - * Returns a instance of <code>PrintJob</code> for the specified - * arguments. - * - * @param frame The window initiating the print job. - * @param title The print job title. - * @param props The print job properties. - * - * @return The requested print job, or <code>null</code> if the job - * was cancelled. - * - * @exception NullPointerException If frame is null, - * or GraphicsEnvironment.isHeadless() returns true. - * @exception SecurityException If this thread is not allowed to initiate - * a print job request. - */ - public abstract PrintJob getPrintJob(Frame frame, String title, - Properties props); - - /** - * Returns a instance of <code>PrintJob</code> for the specified - * arguments. - * - * @param frame The window initiating the print job. - * @param title The print job title. - * @param jobAttr A set of job attributes which will control the print job. - * @param pageAttr A set of page attributes which will control the print job. - * - * @exception NullPointerException If frame is null, and either jobAttr is null - * or jobAttr.getDialog() returns JobAttributes.DialogType.NATIVE. - * @exception IllegalArgumentException If pageAttrspecifies differing cross - * feed and feed resolutions, or when GraphicsEnvironment.isHeadless() returns - * true. - * @exception SecurityException If this thread is not allowed to initiate - * a print job request. - * - * @since 1.3 - */ - public PrintJob getPrintJob(Frame frame, String title, - JobAttributes jobAttr, PageAttributes pageAttr) - { - // FIXME: it is possible this check may be removed - // if this method, when written, always delegates to - // getPrintJob(Frame, String, Properties). - SecurityManager sm; - sm = System.getSecurityManager(); - if (sm != null) - sm.checkPrintJobAccess(); - - return null; - } - - /** - * Causes a "beep" tone to be generated. - */ - public abstract void beep(); - - /** - * Returns the system clipboard. - * - * @return THe system clipboard. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public abstract Clipboard getSystemClipboard(); - - /** - * Gets the singleton instance of the system selection as a - * Clipboard object. The system selection contains the selected text - * of the last component/widget that had focus and a text selection. - * The default implementation returns null. - * - * @return The Clipboard holding the system (text) selection or null - * if the Toolkit or system doesn't support a selection clipboard. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() - * is true. - * @exception SecurityException If the current security manager - * checkSystemClipboardAccess() doesn't allow access. - * - * @since 1.4 - */ - public Clipboard getSystemSelection() - { - return null; - } - - /** - * Returns the accelerator key mask for menu shortcuts. The default is - * <code>Event.CTRL_MASK</code>. A toolkit must override this method - * to change the default. - * - * @return The key mask for the menu accelerator key. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public int getMenuShortcutKeyMask() - { - return Event.CTRL_MASK; - } - - /** - * Returns whether the given locking key on the keyboard is currently in its - * "on" state. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - * @exception IllegalArgumentException If keyCode is not one of the valid keys. - * @exception UnsupportedOperationException If the host system doesn't allow - * getting the state of this key programmatically, or if the keyboard doesn't - * have this key. - */ - public boolean getLockingKeyState(int keyCode) - { - if (AWTUtilities.isValidKey(keyCode)) - throw new UnsupportedOperationException - ("cannot get locking state of key code " + keyCode); - - throw new IllegalArgumentException("invalid key code " + keyCode); - } - - /** - * Sets the state of the given locking key on the keyboard. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - * @exception IllegalArgumentException If keyCode is not one of the valid keys. - * @exception UnsupportedOperationException If the host system doesn't allow - * getting the state of this key programmatically, or if the keyboard doesn't - * have this key. - */ - public void setLockingKeyState(int keyCode, boolean on) - { - if (keyCode != KeyEvent.VK_CAPS_LOCK - && keyCode != KeyEvent.VK_NUM_LOCK - && keyCode != KeyEvent.VK_SCROLL_LOCK) - throw new IllegalArgumentException(); - - throw new UnsupportedOperationException(); - } - - /** - * Returns the native container object of the specified component. This - * method is necessary because the parent component might be a lightweight - * component. - * - * @param component The component to fetch the native container for. - * - * @return The native container object for this component. - */ - protected static Container getNativeContainer(Component component) - { - component = component.getParent(); - while (true) - { - if (component == null) - return null; - if (! (component instanceof Container)) - { - component = component.getParent(); - continue; - } - if (component.getPeer() instanceof LightweightPeer) - { - component = component.getParent(); - continue; - } - return (Container) component; - } - } - - /** - * Creates a new custom cursor object. - * - * @exception IndexOutOfBoundsException If the hotSpot values are outside - * the bounds of the cursor. - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) - { - // Presumably the only reason this isn't abstract is for backwards - // compatibility? FIXME? - if (GraphicsEnvironment.isHeadless()) - throw new HeadlessException("No custom cursor in an headless graphics " - + "environment."); - return null; - } - - /** - * Returns the supported cursor dimension which is closest to the - * desired sizes. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) - { - if (GraphicsEnvironment.isHeadless()) - throw new HeadlessException("No best cursor size in an headless " - + "graphics environment."); - return new Dimension (0,0); - } - - /** - * Returns the maximum number of colors the Toolkit supports in a custom - * cursor palette. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - */ - public int getMaximumCursorColors() - { - return 0; - } - - /** - * Returns whether Toolkit supports this state for Frames. - * - * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. - * - * @since 1.4 - */ - public boolean isFrameStateSupported(int state) - { - return state == Frame.NORMAL || - state == Frame.ICONIFIED || - state == Frame.MAXIMIZED_BOTH; - } - - /** - * Returns the value of the property with the specified name, or the - * default value if the property does not exist. - * - * @param key The name of the property to retrieve. - * @param def The default value of the property. - */ - public static String getProperty(String key, String def) - { - return props.getProperty(key, def); - } - - - /** - * Returns the event queue that is suitable for the calling context. - * - * <p>Despite the word “System” in the name of this - * method, a toolkit may provide different event queues for each - * applet. There is no guarantee that the same queue is shared - * system-wide. - * - * <p>The implementation first checks whether a - * SecurityManager has been installed. If so, its {@link - * java.lang.SecurityManager#checkAwtEventQueueAccess()} method gets - * called. The security manager will throw a SecurityException if it - * does not grant the permission to access the event queue. - * - * <p>Next, the call is delegated to {@link - * #getSystemEventQueueImpl()}. - * - * @return The event queue for this applet (or application). - * - * @throws SecurityException if a security manager has been - * installed, and it does not grant the permission to access the - * event queue. - */ - public final EventQueue getSystemEventQueue() - { - SecurityManager sm; - - sm = System.getSecurityManager(); - if (sm != null) - sm.checkAwtEventQueueAccess(); - - return getSystemEventQueueImpl(); - } - - - /** - * Returns the event queue that is suitable for the calling context. - * - * <p>Despite the word “System” in the name of this - * method, a toolkit may provide different event queues for each - * applet. There is no guarantee that the same queue is shared - * system-wide. - * - * <p>No security checks are performed, which is why this method - * may only be called by Toolkits. - * - * @see #getSystemEventQueue() - */ - protected abstract EventQueue getSystemEventQueueImpl(); - - - /** - * @since 1.3 - */ - public abstract DragSourceContextPeer - createDragSourceContextPeer(DragGestureEvent e); - - /** - * @since 1.3 - */ - public <T extends DragGestureRecognizer> T - createDragGestureRecognizer(Class<T> recognizer, DragSource ds, - Component comp, int actions, - DragGestureListener l) - { - return null; - } - - public final Object getDesktopProperty(String propertyName) - { - return desktopProperties.get(propertyName); - } - - protected final void setDesktopProperty(String name, Object newValue) - { - Object oldValue = getDesktopProperty(name); - desktopProperties.put(name, newValue); - desktopPropsSupport.firePropertyChange(name, oldValue, newValue); - } - - protected Object lazilyLoadDesktopProperty(String name) - { - // FIXME - what is this?? - return null; - } - - protected void initializeDesktopProperties() - { - // Overridden by toolkit implementation? - } - - public void addPropertyChangeListener(String name, - PropertyChangeListener pcl) - { - desktopPropsSupport.addPropertyChangeListener(name, pcl); - } - - public void removePropertyChangeListener(String name, - PropertyChangeListener pcl) - { - desktopPropsSupport.removePropertyChangeListener(name, pcl); - } - - /** - * @since 1.4 - */ - public PropertyChangeListener[] getPropertyChangeListeners() - { - return desktopPropsSupport.getPropertyChangeListeners(); - } - - /** - * @since 1.4 - */ - public PropertyChangeListener[] getPropertyChangeListeners(String name) - { - return desktopPropsSupport.getPropertyChangeListeners(name); - } - - /** - * Adds an AWTEventListener to this toolkit. This listener is informed about - * all events that pass the eventqueue that match the specified - * <code>evenMask</code>. The <code>eventMask</code> is an ORed combination - * of event masks as defined in {@link AWTEvent}. - * - * If a security manager is installed, it is asked first if an - * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. - * This may result in a <code>SecurityException</code> beeing thrown. - * - * It is not recommended to use this kind of notification for normal - * applications. It is intended solely for the purpose of debugging and to - * support special facilities. - * - * @param listener the listener to add - * @param eventMask the event mask of event types which the listener is - * interested in - * - * @since 1.2 - * - * @throws SecurityException if there is a <code>SecurityManager</code> that - * doesn't grant - * <code>AWTPermission("listenToAllAWTEvents")</code> - * - * @see #getAWTEventListeners() - * @see #getAWTEventListeners(long) - * @see #removeAWTEventListener(AWTEventListener) - */ - public void addAWTEventListener(AWTEventListener listener, long eventMask) - { - // First we must check the security permissions. - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkPermission(new AWTPermission("listenToAllAWTEvents")); - - // Go through the list and check if the requested listener is already - // registered. - boolean found = false; - for (int i = 0; i < awtEventListeners.length; ++i) - { - AWTEventListenerProxy proxy = awtEventListeners[i]; - if (proxy.getListener() == listener) - { - found = true; - // Modify the proxies event mask to include the new event mask. - AWTEventListenerProxy newProxy = - new AWTEventListenerProxy(proxy.getEventMask() | eventMask, - listener); - awtEventListeners[i] = newProxy; - break; - } - } - - // If that listener was not found, then add it. - if (! found) - { - AWTEventListenerProxy proxy = - new AWTEventListenerProxy(eventMask, listener); - AWTEventListenerProxy[] newArray = - new AWTEventListenerProxy[awtEventListeners.length + 1]; - System.arraycopy(awtEventListeners, 0, newArray, 0, - awtEventListeners.length); - newArray[newArray.length - 1] = proxy; - awtEventListeners = newArray; - } - } - - /** - * Removes an AWT event listener from this toolkit. This listener is no - * longer informed of any event types it was registered in. - * - * If a security manager is installed, it is asked first if an - * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. - * This may result in a <code>SecurityException</code> beeing thrown. - * - * It is not recommended to use this kind of notification for normal - * applications. It is intended solely for the purpose of debugging and to - * support special facilities. - * - * @param listener the listener to remove - * - * @throws SecurityException if there is a <code>SecurityManager</code> that - * doesn't grant - * <code>AWTPermission("listenToAllAWTEvents")</code> - * - * @since 1.2 - * - * @see #addAWTEventListener(AWTEventListener, long) - * @see #getAWTEventListeners() - * @see #getAWTEventListeners(long) - */ - public void removeAWTEventListener(AWTEventListener listener) - { - // First we must check the security permissions. - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkPermission(new AWTPermission("listenToAllAWTEvents")); - - - // Find the index of the listener. - int index = -1; - for (int i = 0; i < awtEventListeners.length; ++i) - { - AWTEventListenerProxy proxy = awtEventListeners[i]; - if (proxy.getListener() == listener) - { - index = i; - break; - } - } - - // Copy over the arrays and leave out the removed element. - if (index != -1) - { - AWTEventListenerProxy[] newArray = - new AWTEventListenerProxy[awtEventListeners.length - 1]; - if (index > 0) - System.arraycopy(awtEventListeners, 0, newArray, 0, index); - if (index < awtEventListeners.length - 1) - System.arraycopy(awtEventListeners, index + 1, newArray, index, - awtEventListeners.length - index - 1); - awtEventListeners = newArray; - } - } - - /** - * Returns all registered AWT event listeners. This method returns a copy of - * the listener array, so that application cannot trash the listener list. - * - * If a security manager is installed, it is asked first if an - * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. - * This may result in a <code>SecurityException</code> beeing thrown. - * - * It is not recommended to use this kind of notification for normal - * applications. It is intended solely for the purpose of debugging and to - * support special facilities. - * - * @return all registered AWT event listeners - * - * @throws SecurityException if there is a <code>SecurityManager</code> that - * doesn't grant - * <code>AWTPermission("listenToAllAWTEvents")</code> - * - * @since 1.4 - * - * @see #addAWTEventListener(AWTEventListener, long) - * @see #removeAWTEventListener(AWTEventListener) - * @see #getAWTEventListeners(long) - */ - public AWTEventListener[] getAWTEventListeners() - { - // First we must check the security permissions. - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkPermission(new AWTPermission("listenToAllAWTEvents")); - - // Create a copy of the array. - AWTEventListener[] copy = new AWTEventListener[awtEventListeners.length]; - System.arraycopy(awtEventListeners, 0, copy, 0, awtEventListeners.length); - return copy; - } - - /** - * Returns all registered AWT event listeners that listen for events with - * the specified <code>eventMask</code>. This method returns a copy of - * the listener array, so that application cannot trash the listener list. - * - * If a security manager is installed, it is asked first if an - * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. - * This may result in a <code>SecurityException</code> beeing thrown. - * - * It is not recommended to use this kind of notification for normal - * applications. It is intended solely for the purpose of debugging and to - * support special facilities. - * - * @param mask the event mask - * - * @throws SecurityException if there is a <code>SecurityManager</code> that - * doesn't grant - * <code>AWTPermission("listenToAllAWTEvents")</code> - * - * - * @since 1.4 - * - * @see #addAWTEventListener(AWTEventListener, long) - * @see #removeAWTEventListener(AWTEventListener) - * @see #getAWTEventListeners() - */ - public AWTEventListener[] getAWTEventListeners(long mask) - { - // First we must check the security permissions. - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkPermission(new AWTPermission("listenToAllAWTEvents")); - - // Create a copy of the array with only the requested listeners in it. - ArrayList l = new ArrayList(awtEventListeners.length); - for (int i = 0; i < awtEventListeners.length; ++i) - { - if ((awtEventListeners[i].getEventMask() & mask) != 0) - l.add(awtEventListeners[i]); - } - - return (AWTEventListener[] ) l.toArray(new AWTEventListener[l.size()]); - } - - - /** - * Dispatches events to listeners registered to this Toolkit. This is called - * by {@link Component#dispatchEventImpl(AWTEvent)} in order to dispatch - * events globally. - * - * @param ev the event to dispatch - */ - void globalDispatchEvent(AWTEvent ev) - { - // We do not use the accessor methods here because they create new - // arrays each time. We must be very efficient, so we access this directly. - for (int i = 0; i < awtEventListeners.length; ++i) - { - AWTEventListenerProxy proxy = awtEventListeners[i]; - if ((proxy.getEventMask() & ev.getID()) != 0) - proxy.eventDispatched(ev); - } - } - - /** - * @since 1.3 - */ - public abstract Map<TextAttribute,?> - mapInputMethodHighlight(InputMethodHighlight highlight); - - /** - * Initializes the accessibility framework. In particular, this loads the - * properties javax.accessibility.screen_magnifier_present and - * javax.accessibility.screen_reader_present and loads - * the classes specified in javax.accessibility.assistive_technologies. - */ - private static void initAccessibility() - { - AccessController.doPrivileged - (new PrivilegedAction() - { - public Object run() - { - Properties props = new Properties(); - String sep = File.separator; - - // Try the user configuration. - try - { - File propsFile = new File(System.getProperty("user.home") + sep - + ".accessibility.properties"); - FileInputStream in = new FileInputStream(propsFile); - props.load(in); - in.close(); - } - catch (Exception ex) - { - // User configuration not present, ignore. - } - - // Try the system configuration if there was no user configuration. - if (props.size() == 0) - { - try - { - File propsFile = - new File(System.getProperty("gnu.classpath.home.url") - + sep + "accessibility.properties"); - FileInputStream in = new FileInputStream(propsFile); - props.load(in); - in.close(); - } - catch (Exception ex) - { - // System configuration not present, ignore. - } - } - - // Fetch the screen_magnifier_present property. Check systen properties - // first, then fallback to the configuration file. - String magPresent = SystemProperties.getProperty - ("javax.accessibility.screen_magnifier_present"); - if (magPresent == null) - { - magPresent = props.getProperty("screen_magnifier_present"); - if (magPresent != null) - { - SystemProperties.setProperty - ("javax.accessibility.screen_magnifier_present", magPresent); - } - } - - // Fetch the screen_reader_present property. Check systen properties - // first, then fallback to the configuration file. - String readerPresent = SystemProperties.getProperty - ("javax.accessibility.screen_reader_present"); - if (readerPresent == null) - { - readerPresent = props.getProperty("screen_reader_present"); - if (readerPresent != null) - { - SystemProperties.setProperty - ("javax.accessibility.screen_reader_present", readerPresent); - } - } - - // Fetch the list of classes to be loaded. - String classes = SystemProperties.getProperty - ("javax.accessibility.assistive_technologies"); - if (classes == null) - { - classes = props.getProperty("assistive_technologies"); - if (classes != null) - { - SystemProperties.setProperty - ("javax.accessibility.assistive_technologies", classes); - } - } - - // Try to load the assisitive_technologies classes. - if (classes != null) - { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - StringTokenizer tokenizer = new StringTokenizer(classes, ","); - while (tokenizer.hasMoreTokens()) - { - String className = tokenizer.nextToken(); - try - { - Class atClass = cl.loadClass(className); - atClass.newInstance(); - } - catch (ClassNotFoundException ex) - { - AWTError err = new AWTError("Assistive Technology class not" - + " found: " + className); - err.initCause(ex); - throw err; - } - catch (InstantiationException ex) - { - AWTError err = - new AWTError("Assistive Technology class cannot be " - + "instantiated: " + className); - err.initCause(ex); - throw err; - } - catch (IllegalAccessException ex) - { - AWTError err = - new AWTError("Assistive Technology class cannot be " - + "accessed: " + className); - err.initCause(err); - throw err; - } - } - } - return null; - } - }); - - } - - //jnode openjdk - private static boolean loaded = false; - static void loadLibraries() { - /* - if (!loaded) { - java.security.AccessController.doPrivileged( - new sun.security.action.LoadLibraryAction("awt")); - loaded = true; - } - */ - } - - /* Accessor method for use by AWT package routines. */ - static EventQueue getEventQueue() { - return getDefaultToolkit().getSystemEventQueueImpl(); - } - - /* - * This method notifies any AWTEventListeners that an event - * is about to be dispatched. - * - * @param theEvent the event which will be dispatched. - */ - void notifyAWTEventListeners(AWTEvent theEvent) { - // This is a workaround for headless toolkits. It would be - // better to override this method but it is declared package private. - // "this instanceof" syntax defeats polymorphism. - // --mm, 03/03/00 - if (this instanceof sun.awt.HeadlessToolkit) { - ((sun.awt.HeadlessToolkit)this).getUnderlyingToolkit() - .notifyAWTEventListeners(theEvent); - return; - } - - AWTEventListener eventListener = this.eventListener; - if (eventListener != null) { - eventListener.eventDispatched(theEvent); - } - } - private AWTEventListener eventListener = null; - - /** - * Returns whether the given modal exclusion type is supported by this - * toolkit. If an unsupported modal exclusion type property is set on a window, - * then <code>Dialog.ModalExclusionType.NO_EXCLUDE</code> is used instead. - * - * @param modalExclusionType modal exclusion type to be checked for support by this toolkit - * - * @return <code>true</code>, if current toolkit supports given modal exclusion - * type, <code>false</code> otherwise - * - * @see java.awt.Dialog.ModalExclusionType - * @see java.awt.Window#getModalExclusionType - * @see java.awt.Window#setModalExclusionType - * - * @since 1.6 - */ - public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType); - - /** - * Creates this toolkit's implementation of the <code>Desktop</code> - * using the specified peer interface. - * @param target the desktop to be implemented - * @return this toolkit's implementation of the <code>Desktop</code> - * @exception HeadlessException if GraphicsEnvironment.isHeadless() - * returns true - * @see java.awt.GraphicsEnvironment#isHeadless - * @see java.awt.Desktop - * @see java.awt.peer.DesktopPeer - * @since 1.6 - */ - protected abstract DesktopPeer createDesktopPeer(Desktop target) - throws HeadlessException; - - /** - * Returns whether the always-on-top mode is supported by this toolkit. - * To detect whether the always-on-top mode is supported for a - * particular Window, use {@link Window#isAlwaysOnTopSupported}. - * @return <code>true</code>, if current toolkit supports the always-on-top mode, - * otherwise returns <code>false</code> - * @see Window#isAlwaysOnTopSupported - * @see Window#setAlwaysOnTop(boolean) - * @since 1.6 - */ - public boolean isAlwaysOnTopSupported() { - //todo review it - return false; - } - - /** - * Returns whether the given modality type is supported by this toolkit. If - * a dialog with unsupported modality type is created, then - * <code>Dialog.ModalityType.MODELESS</code> is used instead. - * - * @param modalityType modality type to be checked for support by this toolkit - * - * @return <code>true</code>, if current toolkit supports given modality - * type, <code>false</code> otherwise - * - * @see java.awt.Dialog.ModalityType - * @see java.awt.Dialog#getModalityType - * @see java.awt.Dialog#setModalityType - * - * @since 1.6 - */ - public abstract boolean isModalityTypeSupported(Dialog.ModalityType modalityType); - - //jnode + openjdk - private static volatile long enabledOnToolkitMask; - static boolean enabledOnToolkit(long eventMask) { - return (enabledOnToolkitMask & eventMask) != 0; - } - -} // class Toolkit Added: trunk/core/src/openjdk/java/java/awt/Toolkit.java =================================================================== --- trunk/core/src/openjdk/java/java/awt/Toolkit.java (rev 0) +++ trunk/core/src/openjdk/java/java/awt/Toolkit.java 2008-07-17 10:45:28 UTC (rev 4306) @@ -0,0 +1,2428 @@ +/* + * Copyright 1995-2006 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.awt; + +import java.util.MissingResourceException; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.StringTokenizer; +import java.awt.event.*; +import java.awt.peer.*; +import java.awt.*; +import java.awt.im.InputMethodHighlight; +import java.awt.image.ImageObserver; +import java.awt.image.ImageProducer; +import java.awt.image.ColorModel; +import java.awt.datatransfer.Clipboard; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; +import java.net.URL; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import java.util.EventListener; +import java.util.Map; +import java.util.HashMap; +import java.util.WeakHashMap; +import java.util.List; +import java.util.ArrayList; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +import sun.awt.DebugHelper; +import sun.awt.HeadlessToolkit; +import sun.awt.NullComponentPeer; +import sun.security.util.SecurityConstants; + +import sun.util.CoreResourceBundleControl; + +/** + * This class is the abstract superclass of all actual + * implementations of the Abstract Window Toolkit. Subclasses of + * <code>Toolkit</code> are used to bind the various components + * to particular native toolkit implementations. + * <p> + * Many GUI operations may be performed asynchronously. This + * means that if you set the state of a component, and then + * immediately query the state, the returned value may not yet + * reflect the requested change. This includes, but is not + * limited to: + * <ul> + * <li>Scrolling to a specified position. + * <br>For example, calling <code>ScrollPane.setScrollPosition</code> + * and then <code>getScrollPosition</code> may return an incorrect + * value if the original request has not yet been processed. + * <p> + * <li>Moving the focus from one component to another. + * <br>For more information, see + * <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#transferTiming">Timing + * Focus Transfers</a>, a section in + * <a href="http://java.sun.com/docs/books/tutorial/uiswing/">The Swing + * Tutorial</a>. + * <p> + * <li>Making a top-level container visible. + * <br>Calling <code>setVisible(true)</code> on a <code>Window</code>, + * <code>Frame</code> or <code>Dialog</code> may occur + * asynchronously. + * <p> + * <li>Setting the size or location of a top-level container. + * <br>Calls to <code>setSize</code>, <code>setBounds</code> or + * <code>setLocation</code> on a <code>Window</code>, + * <code>Frame</code> or <code>Dialog</code> are forwarded + * to the underlying window management system and may be + * ignored or modified. See {@link java.awt.Window} for + * more information. + * </ul> + * <p> + * Most applications should not call any of the methods in this + * class directly. The methods defined by <code>Toolkit</code> are + * the "glue" that joins the platform-independent classes in the + * <code>java.awt</code> package with their counterparts in + * <code>java.awt.peer</code>. Some methods defined by + * <code>Toolkit</code> query the native operating system directly. + * + * @version 1.203, 12/19/03 + * @author Sami Shaio + * @author Arthur van Hoff + * @author Fred Ecks + * @since JDK1.0 + */ +public abstract class Toolkit { + + /** + * Creates this toolkit's implementation of the <code>Desktop</code> + * using the specified peer interface. + * @param target the desktop to be implemented + * @return this toolkit's implementation of the <code>Desktop</code> + * @exception HeadlessException if GraphicsEnvironment.isHeadless() + * returns true + * @see java.awt.GraphicsEnvironment#isHeadless + * @see java.awt.Desktop + * @see java.awt.peer.DesktopPeer + * @since 1.6 + */ + protected abstract DesktopPeer createDesktopPeer(Desktop target) + throws HeadlessException; + + + /** + * Creates this toolkit's implementation of <code>Button</code> using + * the specified peer interface. + * @param target the button to be implemented. + * @return this toolkit's implementation of <code>Button</code>. + * @exception HeadlessException if GraphicsEnvironment.isHeadless() + * returns true + * @see java.awt.GraphicsEnvironment#isHeadless + * @see java.awt.Button + * @see java.awt.peer.ButtonPeer + */ + protected abstract ButtonPeer createButton(Button target) + throws HeadlessException; + + /** + * Creates this toolkit's implementation of <code>TextField</code> using + * the specified peer interface. + * @param target the text field to be implemented. + * @return this toolkit's implementation of <code>TextField</code>. + * @exception HeadlessException if... [truncated message content] |
From: <ls...@us...> - 2008-07-29 18:38:44
|
Revision: 4369 http://jnode.svn.sourceforge.net/jnode/?rev=4369&view=rev Author: lsantha Date: 2008-07-29 18:38:38 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Improved boot messages. Modified Paths: -------------- trunk/core/src/core/org/jnode/plugin/Plugin.java trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java trunk/core/src/core/org/jnode/work/WorkPlugin.java trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java Modified: trunk/core/src/core/org/jnode/plugin/Plugin.java =================================================================== --- trunk/core/src/core/org/jnode/plugin/Plugin.java 2008-07-29 17:04:56 UTC (rev 4368) +++ trunk/core/src/core/org/jnode/plugin/Plugin.java 2008-07-29 18:38:38 UTC (rev 4369) @@ -102,7 +102,7 @@ } if (!started) { if (descriptor.hasCustomPluginClass()) { - BootLog.debug("__Starting " + descriptor.getId()); + BootLog.debug("Starting plugin: " + descriptor.getId()); } started = true; try { Modified: trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java =================================================================== --- trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java 2008-07-29 17:04:56 UTC (rev 4368) +++ trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java 2008-07-29 18:38:38 UTC (rev 4369) @@ -162,7 +162,6 @@ while (!isStartPluginsFinished() && (now - start < START_TIMEOUT)) { try { if (++loop == 10) { - System.out.print('.'); loop = 0; } Thread.sleep(100); Modified: trunk/core/src/core/org/jnode/work/WorkPlugin.java =================================================================== --- trunk/core/src/core/org/jnode/work/WorkPlugin.java 2008-07-29 17:04:56 UTC (rev 4368) +++ trunk/core/src/core/org/jnode/work/WorkPlugin.java 2008-07-29 18:38:38 UTC (rev 4369) @@ -124,7 +124,6 @@ * @see org.jnode.work.WorkManager#add(org.jnode.work.Work) */ public final synchronized void add(Work work) { - log.debug("#free workers: " + getFreeProcessors()); workCounter++; queue.add(work); } Modified: trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java 2008-07-29 17:04:56 UTC (rev 4368) +++ trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java 2008-07-29 18:38:38 UTC (rev 4369) @@ -41,8 +41,7 @@ * * @author epr */ -public final class DefaultDeviceManager extends AbstractDeviceManager - implements ExtensionPointListener { +public final class DefaultDeviceManager extends AbstractDeviceManager implements ExtensionPointListener { /** * finder extension-point @@ -162,8 +161,6 @@ * @param element */ private void configureFinder(List<DeviceFinder> finders, ConfigurationElement element) { - BootLog.debug("Configure finder: " + element); - final String elementName = element.getName(); if (!elementName.equals("finder")) { BootLog.warn("Ignoring unrecognised descriptor element: " + elementName); @@ -173,8 +170,8 @@ final String className = element.getAttribute("class"); if (className != null) { try { - final Class cls = Thread.currentThread() - .getContextClassLoader().loadClass(className); + BootLog.debug("Configuring finder: " + className); + final Class cls = Thread.currentThread().getContextClassLoader().loadClass(className); final DeviceFinder finder = (DeviceFinder) cls.newInstance(); finders.add(finder); } catch (ClassNotFoundException ex) { @@ -184,8 +181,7 @@ } catch (InstantiationException ex) { BootLog.error("Cannot instantiate finder class " + className); } catch (ClassCastException ex) { - BootLog.error("Finder class " + className - + " does not implement the DeviceFinder interface"); + BootLog.error("Finder class " + className + " does not implement the DeviceFinder interface"); } } } @@ -198,8 +194,6 @@ * @param element */ private void configureMapper(List<DeviceToDriverMapper> mappers, ConfigurationElement element) { - BootLog.debug("Configure mapper: " + element); - final String elementName = element.getName(); if (!elementName.equals("mapper")) { BootLog.warn("Ignoring unrecognised descriptor element: " + elementName); @@ -209,8 +203,8 @@ final String className = element.getAttribute("class"); if (className != null) { try { - final Class cls = Thread.currentThread() - .getContextClassLoader().loadClass(className); + BootLog.debug("Configuring mapper: " + className); + final Class cls = Thread.currentThread().getContextClassLoader().loadClass(className); final DeviceToDriverMapper mapper = newMapperInstance(cls, element); mappers.add(mapper); } catch (ClassNotFoundException ex) { @@ -220,10 +214,7 @@ } catch (InstantiationException ex) { BootLog.error("Cannot instantiate mapper class " + className, ex); } catch (ClassCastException ex) { - BootLog - .error("Mapper class " - + className - + " does not implement the DeviceToDriverMapper interface"); + BootLog.error("Mapper class " + className + " does not implement the DeviceToDriverMapper interface"); } } else { BootLog.error("class attribute required in mapper"); Modified: trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java 2008-07-29 17:04:56 UTC (rev 4368) +++ trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java 2008-07-29 18:38:38 UTC (rev 4369) @@ -207,14 +207,11 @@ * @param console */ public synchronized void focus(Console console) { - log.debug("focus(" + console.getConsoleName() + ")"); if (this.current != null && this.current != console) { - log.debug("Sending focusLost to " + current.getConsoleName()); this.current.focusLost(new FocusEvent(FocusEvent.FOCUS_LOST)); } this.current = console; if (this.current != null) { - log.debug("Sending focusGained to " + current.getConsoleName()); current.focusGained(new FocusEvent(FocusEvent.FOCUS_GAINED)); } } @@ -338,7 +335,6 @@ } public void registerConsole(Console console) { - log.debug("registerConsole(" + console.getConsoleName() + ")"); consoles.put(console.getConsoleName(), console); if (current == null) { current = console; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2008-08-03 07:55:42
|
Revision: 4387 http://jnode.svn.sourceforge.net/jnode/?rev=4387&view=rev Author: fduminy Date: 2008-08-03 07:55:38 +0000 (Sun, 03 Aug 2008) Log Message: ----------- fix for bugs happening while halting JNode : - log4j complaining about not being properly configured - AbstractInputDriver's queue still trying to get events from the closed queue Modified Paths: -------------- trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java trunk/core/src/core/org/jnode/util/Queue.java trunk/core/src/driver/org/jnode/driver/input/AbstractInputDriver.java Modified: trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java =================================================================== --- trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java 2008-08-02 19:25:44 UTC (rev 4386) +++ trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java 2008-08-03 07:55:38 UTC (rev 4387) @@ -24,11 +24,12 @@ import java.awt.event.KeyEvent; import java.io.PrintStream; import java.util.Enumeration; + import javax.naming.NameNotFoundException; + import org.apache.log4j.Appender; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; -import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jnode.driver.console.ConsoleManager; @@ -98,7 +99,9 @@ * @see org.jnode.plugin.Plugin#stopPlugin() */ protected void stopPlugin() throws PluginException { - LogManager.resetConfiguration(); + // Using LogManager.resetConfiguration() or LogManager.shutdown() + // can't avoid log4j WARN message about log4j not being properly configured. + // So, simply do nothing } } Modified: trunk/core/src/core/org/jnode/util/Queue.java =================================================================== --- trunk/core/src/core/org/jnode/util/Queue.java 2008-08-02 19:25:44 UTC (rev 4386) +++ trunk/core/src/core/org/jnode/util/Queue.java 2008-08-03 07:55:38 UTC (rev 4387) @@ -170,5 +170,13 @@ this.closed = true; notifyAll(); } + + /** + * Is this queue closed. + * @return + */ + public boolean isClosed() { + return closed; + } } Modified: trunk/core/src/driver/org/jnode/driver/input/AbstractInputDriver.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/input/AbstractInputDriver.java 2008-08-02 19:25:44 UTC (rev 4386) +++ trunk/core/src/driver/org/jnode/driver/input/AbstractInputDriver.java 2008-08-03 07:55:38 UTC (rev 4387) @@ -148,6 +148,12 @@ final byte scancode = buf.get(0); E event = handleScancode(scancode); if ((event != null) && !event.isConsumed()) { + if (eventQueue.isClosed()) { + // the queue is closed : it usually happen while JNode is halting + // simply stop processing the events + break; + } + eventQueue.add(event); } } catch (Throwable ex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2008-08-03 21:50:43
|
Revision: 4396 http://jnode.svn.sourceforge.net/jnode/?rev=4396&view=rev Author: fduminy Date: 2008-08-03 21:50:40 +0000 (Sun, 03 Aug 2008) Log Message: ----------- kernel cleanup : - removed unneeded native method Unsafe.getVbeInfos() (using multiboot_vbe kernel data) - removed unneeded multiboot_vbe kernel data (+its copying code, which contained a bug) - improved comments in assembly code Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/x86/UnsafeX86.java trunk/core/src/native/x86/i386.h trunk/core/src/native/x86/kernel.asm trunk/core/src/native/x86/unsafex86.asm Modified: trunk/core/src/core/org/jnode/vm/x86/UnsafeX86.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/UnsafeX86.java 2008-08-03 16:26:28 UTC (rev 4395) +++ trunk/core/src/core/org/jnode/vm/x86/UnsafeX86.java 2008-08-03 21:50:40 UTC (rev 4396) @@ -83,8 +83,6 @@ */ static final native int getMultibootMMapLength(); - public static final native Address getVbeInfos(); - public static final native Address getVbeControlInfos(); public static final native Address getVbeModeInfos(); Modified: trunk/core/src/native/x86/kernel.asm =================================================================== --- trunk/core/src/native/x86/kernel.asm 2008-08-03 16:26:28 UTC (rev 4395) +++ trunk/core/src/native/x86/kernel.asm 2008-08-03 21:50:40 UTC (rev 4396) @@ -100,29 +100,16 @@ test dword [multiboot_info+MBI_FLAGS],MBF_VBE jz vbe_info_done ; no vbe info, jump to end - ; Copy vbe infos - ; Get start address - mov esi,[multiboot_info+MBI_VBECTRLINFO] - ; Get destination address - mov edi,multiboot_vbe - ; Copy the VBE_ESIZE bytes - mov ecx,VBE_ESIZE + ; Copy VBE control informations + mov esi,[multiboot_info+MBI_VBECTRLINFO] ; Get start address + mov edi,vbe_control_info ; Get destination address + mov ecx,VBECTRLINFO_SIZE ; Copy the VBECTRLINFO_SIZE bytes rep movsb - - ; Get start address - mov esi,[multiboot_info+MBI_VBECTRLINFO] - ; Get destination address - mov edi,vbe_control_info - ; Copy the VBECTRLINFO_SIZE bytes - mov ecx,VBECTRLINFO_SIZE - rep movsb - ; Get start address - mov esi,[multiboot_info+MBI_VBEMODEINFO] - ; Get destination address - mov edi,vbe_mode_info - ; Copy the VBEMODEINFO_SIZE bytes - mov ecx,VBEMODEINFO_SIZE + ; Copy VBE mode informations + mov esi,[multiboot_info+MBI_VBEMODEINFO] ; Get start address + mov edi,vbe_mode_info ; Get destination address + mov ecx,VBEMODEINFO_SIZE ; Copy the VBEMODEINFO_SIZE bytes rep movsb vbe_info_done: @@ -314,10 +301,7 @@ dd 0 ; Entries times (MBI_MMAP_MAX * MBMMAP_ESIZE) db 0 -; vbe informations -multiboot_vbe: - times (VBE_ESIZE) db 0 - +; vbe informations in multiboot header vbe_control_info: times (VBECTRLINFO_SIZE) db 0 Modified: trunk/core/src/native/x86/unsafex86.asm =================================================================== --- trunk/core/src/native/x86/unsafex86.asm 2008-08-03 16:26:28 UTC (rev 4395) +++ trunk/core/src/native/x86/unsafex86.asm 2008-08-03 21:50:40 UTC (rev 4396) @@ -82,11 +82,6 @@ mov eax,[multiboot_mmap] ret -; Address getVbeInfos(); -GLABEL Q53org5jnode2vm3x869UnsafeX8623getVbeInfos2e2829Lorg2fvmmagic2funboxed2fAddress3b - mov AAX,multiboot_vbe - ret - ; Address getVbeControlInfos(); GLABEL Q53org5jnode2vm3x869UnsafeX8623getVbeControlInfos2e2829Lorg2fvmmagic2funboxed2fAddress3b mov AAX,vbe_control_info This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-08-23 09:33:55
|
Revision: 4484 http://jnode.svn.sourceforge.net/jnode/?rev=4484&view=rev Author: lsantha Date: 2008-08-23 09:33:49 +0000 (Sat, 23 Aug 2008) Log Message: ----------- Moved time2millis from RTC to TimeUtils for wider reusability. Modified Paths: -------------- trunk/core/src/core/org/jnode/util/TimeUtils.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/RTC.java Modified: trunk/core/src/core/org/jnode/util/TimeUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/TimeUtils.java 2008-08-22 20:12:44 UTC (rev 4483) +++ trunk/core/src/core/org/jnode/util/TimeUtils.java 2008-08-23 09:33:49 UTC (rev 4484) @@ -57,4 +57,29 @@ } } } + + /** + * Converts Gregorian date to milliseconds since 1970-01-01 00:00:00 . + * + * @param year the year + * @param mon the month 1..12 + * @param day the day of month 1..31 + * @param hours hours of day 0..23 + * @param mins minutes 0..59 + * @param secs seconds 0..59 + * @return the milliseconds since 1970-01-01 00:00:00 + */ + public static long time2millis(int year, int mon, int day, int hours, int mins, int secs) { + if (0 >= (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ + mon += 12; /* Puts Feb last since it has leap day */ + year -= 1; + } + + return (((( + ((long) (year / 4 - year / 100 + year / 400 + 367 * mon / 12 + day) + year * 365 - 719499)) /* days */ + * 24l + hours) /* hours */ + * 60l + mins) /* minutes */ + * 60l + secs) /* seconds */ + * 1000l; /* milliseconds */ + } } Modified: trunk/core/src/driver/org/jnode/driver/system/cmos/def/RTC.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/system/cmos/def/RTC.java 2008-08-22 20:12:44 UTC (rev 4483) +++ trunk/core/src/driver/org/jnode/driver/system/cmos/def/RTC.java 2008-08-23 09:33:49 UTC (rev 4484) @@ -24,6 +24,7 @@ import org.jnode.driver.system.cmos.CMOSConstants; import org.jnode.driver.system.cmos.CMOSService; import org.jnode.util.BCDUtils; +import org.jnode.util.TimeUtils; import org.jnode.vm.RTCService; /** @@ -146,31 +147,6 @@ * @see java.util.Calendar#setTimeInMillis(long) */ public long getTime() { - return time2millis(getYear(), getMonth(), getDay(), getHours(), getMinutes(), getSeconds()); + return TimeUtils.time2millis(getYear(), getMonth(), getDay(), getHours(), getMinutes(), getSeconds()); } - - /** - * Converts Gregorian date to milliseconds since 1970-01-01 00:00:00 . - * - * @param year the year - * @param mon the month 1..12 - * @param day the day of month 1..31 - * @param hours hours of day 0..23 - * @param mins minutes 0..59 - * @param secs seconds 0..59 - * @return the milliseconds since 1970-01-01 00:00:00 - */ - static long time2millis(int year, int mon, int day, int hours, int mins, int secs) { - if (0 >= (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - - return (((( - ((long) (year / 4 - year / 100 + year / 400 + 367 * mon / 12 + day) + year * 365 - 719499)) /* days */ - * 24l + hours) /* hours */ - * 60l + mins) /* minutes */ - * 60l + secs) /* seconds */ - * 1000l; /* milliseconds */ - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-09-30 12:00:29
|
Revision: 4592 http://jnode.svn.sourceforge.net/jnode/?rev=4592&view=rev Author: crawley Date: 2008-09-30 12:00:11 +0000 (Tue, 30 Sep 2008) Log Message: ----------- This checkin adds some infrastructure for 'status links' and corrects a mis-named public method in the Isolate class. I've renamed VmDataLink / DataLinkImpl to VmLink / LinkImpl because they also need to support status links. Modified Paths: -------------- trunk/core/src/classpath/ext/javax/isolate/Isolate.java trunk/core/src/classpath/ext/javax/isolate/Link.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/isolate/link/LinkLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/link/LinkMessageFactory.java Added Paths: ----------- trunk/core/src/core/org/jnode/vm/isolate/link/LinkImpl.java trunk/core/src/core/org/jnode/vm/isolate/link/VmLink.java Removed Paths: ------------- trunk/core/src/core/org/jnode/vm/isolate/link/DataLinkImpl.java trunk/core/src/core/org/jnode/vm/isolate/link/VmDataLink.java Modified: trunk/core/src/classpath/ext/javax/isolate/Isolate.java =================================================================== --- trunk/core/src/classpath/ext/javax/isolate/Isolate.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/classpath/ext/javax/isolate/Isolate.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -147,14 +147,13 @@ /** * Gets a new Link associated with this Isolate from which the current - * isolate can receive events. + * isolate can receive status link messages. * * @return * @throws ClosedLinkException */ - public Link newEventLink() throws ClosedLinkException { - // TODO implement me - return null; + public Link newStatusLink() throws ClosedLinkException { + return impl.newStatusLink(currentIsolate().impl); } /** Modified: trunk/core/src/classpath/ext/javax/isolate/Link.java =================================================================== --- trunk/core/src/classpath/ext/javax/isolate/Link.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/classpath/ext/javax/isolate/Link.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -24,7 +24,7 @@ import java.io.IOException; import java.io.InterruptedIOException; -import org.jnode.vm.isolate.link.VmDataLink; +import org.jnode.vm.isolate.link.VmLink; /** * @author Ewout Prangsma (ep...@us...) @@ -228,6 +228,6 @@ */ public static Link newLink(Isolate sender, Isolate receiver) throws ClosedLinkException { - return VmDataLink.newLink(sender.getImpl(), receiver.getImpl()); + return VmLink.newLink(sender.getImpl(), receiver.getImpl()); } } Modified: trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -54,7 +54,7 @@ import org.jnode.vm.annotation.SharedStatics; import org.jnode.vm.classmgr.VmIsolatedStatics; import org.jnode.vm.classmgr.VmType; -import org.jnode.vm.isolate.link.VmDataLink; +import org.jnode.vm.isolate.link.VmLink; /** * VM specific implementation of the Isolate class. @@ -122,9 +122,14 @@ /** * Links passed to the start of this isolate */ - private VmDataLink[] dataLinks; + private VmLink[] dataLinks; /** + * Status links created by newStatusLink() + */ + private LinkedList<VmLink> statusLinks = new LinkedList<VmLink>(); + + /** * The isolate-specific default IO context */ private final IOContext vmIoContext = new VmIOContext(); @@ -344,7 +349,7 @@ public final void exit(Isolate isolate, int status) { testIsolate(isolate); //todo handle demon threads - if(threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) + if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) return; try { @@ -352,7 +357,7 @@ } catch (Throwable t) { t.printStackTrace(); } - state = State.EXITED; + changeState(State.EXITED); StaticData.isolates.remove(this); } @@ -375,7 +380,7 @@ } catch (Throwable t) { t.printStackTrace(); } - this.state = State.TERMINATED; + changeState(State.TERMINATED); StaticData.isolates.remove(this); } @@ -428,14 +433,14 @@ * Gets the links passed to the start of the current isolate. */ public static Link[] getLinks() { - final VmDataLink[] vmLinks = currentIsolate().dataLinks; + final VmLink[] vmLinks = currentIsolate().dataLinks; if ((vmLinks == null) || (vmLinks.length == 0)) { return new Link[0]; } else { Link[] links = new Link[vmLinks.length]; int i = 0; - for (VmDataLink vmLink : vmLinks) { + for (VmLink vmLink : vmLinks) { links[i++] = vmLink.asLink(); } return links; @@ -449,7 +454,7 @@ * @throws IsolateStartupException */ @PrivilegedActionPragma - public final void start(Isolate isolate, Link[] links) + public synchronized final void start(Isolate isolate, Link[] links) throws IsolateStartupException { testIsolate(isolate); // The creator of this isolate must be the same as the current isolate @@ -461,10 +466,9 @@ synchronized (this) { // The state must be CREATED if (state != State.CREATED) { - throw new IllegalStateException( - "Isolate has already been started"); + throw new IllegalStateException("Isolate has already been started"); } - this.state = State.STARTING; + changeState(State.STARTING); } // Save starter @@ -473,13 +477,13 @@ // Save links this.dataLinks = null; if (links != null) { - VmDataLink[] vmLinks = new VmDataLink[links.length]; + VmLink[] vmLinks = new VmLink[links.length]; int i = 0; for (Link link : links) { if (!link.isOpen()) { throw new IsolateStartupException("Link is closed"); } - vmLinks[i] = VmDataLink.fromLink(link); + vmLinks[i] = VmLink.fromLink(link); } this.dataLinks = vmLinks; } @@ -514,7 +518,7 @@ piManager, stdout, stderr, stdin); // Update the state of this isolate. - this.state = State.STARTED; + changeState(State.STARTED); // Start the main thread. mainThread.start(); @@ -750,4 +754,35 @@ BootableHashMap getIsolateLocalMap() { return isolateLocalMap; } + + /** + * Create and return a new status link for this isolate and the supplied + * receiver isolate. + * @param receiver the receiver for the link. + * @return the link. + */ + public synchronized Link newStatusLink(VmIsolate receiver) { + Link link = VmLink.newLink(this, receiver); + VmLink vmLink = VmLink.fromLink(link); + statusLinks.add(vmLink); + if (state == State.TERMINATED) { + // The spec says that we should immediately send a link message + // if the isolate is already 'EXITED'. + sendStatus(vmLink, state); + } + return link; + } + + private synchronized void changeState(State newState) { + if (state != newState) { + this.state = newState; + for (VmLink link : statusLinks) { + sendStatus(link, this.state); + } + } + } + + private void sendStatus(VmLink link, State state) { + // TODO implement. + } } Deleted: trunk/core/src/core/org/jnode/vm/isolate/link/DataLinkImpl.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/link/DataLinkImpl.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/core/org/jnode/vm/isolate/link/DataLinkImpl.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -1,98 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.vm.isolate.link; - -import java.io.IOException; -import java.io.InterruptedIOException; - -import javax.isolate.ClosedLinkException; -import javax.isolate.Isolate; -import javax.isolate.Link; -import javax.isolate.LinkMessage; - -final class DataLinkImpl extends Link { - - private final VmDataLink vmLink; - - /** - * Constructor - * - * @param vmLink - */ - DataLinkImpl(VmDataLink vmLink) { - this.vmLink = vmLink; - } - - final VmDataLink getImpl() { - return vmLink; - } - - /** - * @see javax.isolate.Link#close() - */ - @Override - public void close() { - vmLink.close(); - } - - /** - * @see javax.isolate.Link#Equals(java.lang.Object) - */ - @Override - public boolean equals(Object other) { - if (other instanceof DataLinkImpl) { - return (((DataLinkImpl) other).vmLink == this.vmLink); - } - return false; - } - - /** - * @see javax.isolate.Link#getReceiver() - */ - @Override - public Isolate getReceiver() { - return vmLink.getReceiver().getIsolate(); - } - - /** - * @see javax.isolate.Link#getSender() - */ - @Override - public Isolate getSender() { - return vmLink.getSender().getIsolate(); - } - - /** - * @see javax.isolate.Link#isOpen() - */ - @Override - public boolean isOpen() { - return vmLink.isOpen(); - } - - /** - * @see javax.isolate.Link#receive() - */ - @Override - public LinkMessage receive() - throws ClosedLinkException, IllegalStateException, InterruptedIOException, IOException { - return vmLink.receive(); - } - - /** - * @see javax.isolate.Link#send(javax.isolate.LinkMessage) - */ - @Override - public void send(LinkMessage message) throws ClosedLinkException, InterruptedIOException, IOException { - vmLink.send(message); - } - - /** - * @see javax.isolate.Link#toString() - */ - @Override - public String toString() { - return vmLink.toString(); - } -} Added: trunk/core/src/core/org/jnode/vm/isolate/link/LinkImpl.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/link/LinkImpl.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/isolate/link/LinkImpl.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -0,0 +1,98 @@ +/* + * $Id: DataLinkImpl.java 4552 2008-09-11 11:38:42Z crawley $ + */ +package org.jnode.vm.isolate.link; + +import java.io.IOException; +import java.io.InterruptedIOException; + +import javax.isolate.ClosedLinkException; +import javax.isolate.Isolate; +import javax.isolate.Link; +import javax.isolate.LinkMessage; + +final class LinkImpl extends Link { + + private final VmLink vmLink; + + /** + * Constructor + * + * @param vmLink + */ + LinkImpl(VmLink vmLink) { + this.vmLink = vmLink; + } + + final VmLink getImpl() { + return vmLink; + } + + /** + * @see javax.isolate.Link#close() + */ + @Override + public void close() { + vmLink.close(); + } + + /** + * @see javax.isolate.Link#Equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (other instanceof LinkImpl) { + return (((LinkImpl) other).vmLink == this.vmLink); + } + return false; + } + + /** + * @see javax.isolate.Link#getReceiver() + */ + @Override + public Isolate getReceiver() { + return vmLink.getReceiver().getIsolate(); + } + + /** + * @see javax.isolate.Link#getSender() + */ + @Override + public Isolate getSender() { + return vmLink.getSender().getIsolate(); + } + + /** + * @see javax.isolate.Link#isOpen() + */ + @Override + public boolean isOpen() { + return vmLink.isOpen(); + } + + /** + * @see javax.isolate.Link#receive() + */ + @Override + public LinkMessage receive() + throws ClosedLinkException, IllegalStateException, InterruptedIOException, IOException { + return vmLink.receive(); + } + + /** + * @see javax.isolate.Link#send(javax.isolate.LinkMessage) + */ + @Override + public void send(LinkMessage message) throws ClosedLinkException, InterruptedIOException, IOException { + vmLink.send(message); + } + + /** + * @see javax.isolate.Link#toString() + */ + @Override + public String toString() { + return vmLink.toString(); + } +} Modified: trunk/core/src/core/org/jnode/vm/isolate/link/LinkLinkMessage.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/link/LinkLinkMessage.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/core/org/jnode/vm/isolate/link/LinkLinkMessage.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -8,14 +8,14 @@ final class LinkLinkMessage extends LinkMessageImpl { - private final VmDataLink value; + private final VmLink value; /** * Message constructor * * @param value */ - LinkLinkMessage(VmDataLink link) { + LinkLinkMessage(VmLink link) { this.value = link; } Modified: trunk/core/src/core/org/jnode/vm/isolate/link/LinkMessageFactory.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/link/LinkMessageFactory.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/core/org/jnode/vm/isolate/link/LinkMessageFactory.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -51,7 +51,7 @@ * @return */ public static LinkMessage newLinkMessage(Link link) { - return new LinkLinkMessage(((DataLinkImpl) link).getImpl()); + return new LinkLinkMessage(((LinkImpl) link).getImpl()); } /** Deleted: trunk/core/src/core/org/jnode/vm/isolate/link/VmDataLink.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/link/VmDataLink.java 2008-09-30 11:54:14 UTC (rev 4591) +++ trunk/core/src/core/org/jnode/vm/isolate/link/VmDataLink.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -1,272 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.vm.isolate.link; - -import java.io.IOException; -import java.io.InterruptedIOException; -import java.util.LinkedList; -import java.util.Queue; - -import javax.isolate.ClosedLinkException; -import javax.isolate.Link; -import javax.isolate.LinkMessage; - -import org.jnode.vm.isolate.VmIsolate; -import org.jnode.vm.isolate.VmIsolateLocal; - -/** - * Shared implementation of javax.isolate.Link - * - * @author Ewout Prangsma (ep...@us...) - */ -public final class VmDataLink { - - private final VmIsolateLocal<DataLinkImpl> linkHolder = new VmIsolateLocal<DataLinkImpl>(); - - private final Queue<LinkMessageImpl> messages = new LinkedList<LinkMessageImpl>(); - - private boolean closed = false; - - private VmIsolate sender; - - private VmIsolate receiver; - - /** - * Create a new data link between the given isolates. - * - * @param sender - * @param receiver - * @return - */ - public static Link newLink(VmIsolate sender, VmIsolate receiver) { - if (sender == receiver) { - throw new IllegalArgumentException("sender == receiver"); - } - VmDataLink vmLink = new VmDataLink(sender, receiver); - return vmLink.asLink(); - } - - public static VmDataLink fromLink(Link link) { - return ((DataLinkImpl) link).getImpl(); - } - - /** - * @param sender - * @param receiver - */ - VmDataLink(VmIsolate sender, VmIsolate receiver) { - this.sender = sender; - this.receiver = receiver; - } - - /** - * Gets this shared link as Link instance. - * - * @return - */ - public final Link asLink() { - final DataLinkImpl link = linkHolder.get(); - if (link == null) { - linkHolder.set(new DataLinkImpl(this)); - return linkHolder.get(); - } else { - return link; - } - } - - /** - * Close this link. - */ - final void close() { - if (!this.closed) { - final VmIsolate current = VmIsolate.currentIsolate(); - if ((current != receiver) && (current != sender)) { - throw new IllegalStateException( - "Only sender or receiver can close this link"); - } - this.closed = true; - synchronized (this) { - notifyAll(); - } - } - } - - /** - * Is this link currently open. - * - * @return - */ - final boolean isOpen() { - return !closed; - } - - /** - * @return the receiver - */ - final VmIsolate getReceiver() { - return receiver; - } - - /** - * @return the sender - */ - final VmIsolate getSender() { - return sender; - } - - /** - * Receives a copy of a message sent on this Link. - * <p/> - * The current thread will block in this method until a sender is available. - * When the sender and receiver rendezvous, the message will then be - * transferred. If multiple threads invoke this method on the same object, - * only one thread will receive any message at rendezvous and the other - * threads will contend for subsequent access to the rendezvous point. A - * normal return indicates that the message was received successfully. If an - * exception occured on the sender side, no rendezvous will occur, and no - * object will be transferred; the receiver will wait for the next - * successful send. If an exception occurs on the receive, the sender will - * see a successful transfer. - * <p/> - * This method never returns null. - * <p/> - * If the sending isolate becomes terminated after this method is invoked - * but before it returns, the link will be closed, a ClosedLinkException - * will be thrown, any subsequent attempts to use receive() will result in a - * ClosedLinkException, and any Isolate objects corresponding to the receive - * side of the link will reflect a terminated state. - * <p/> - * If invoked on a closed Link, this method will throw a - * ClosedLinkException. - * <p/> - * If close() is invoked on the link while a thread is blocked in receive(), - * receive() will throw a ClosedLinkException. No message will have been - * transferred in that case. - * <p/> - * If Thread.interrupt() is invoked on a thread that has not yet completed - * an invocation of this method, the results are undefined. An - * InterruptedIOException may or may not be thrown; if not, control will - * return from the method with a valid LinkMessage object. However, even if - * InterruptedIOException is thrown, rendezvous and data transfer from the - * sending isolate may have occurred. In particular, undetected message loss - * between sender and receiver may occur. - * <p/> - * If a failure occurs due to the object being transferred between isolates - * an IOException may be thrown in the receiver. For example, if a message - * containing a large buffer is sent and the receiver has insufficient heap - * memory for the buffer or if construction of a link in the receiver - * isolate fails, an IOException will be thrown. The sender will see a - * successful transfer in these cases. - * <p/> - * If the current isolate is not a receiver on this Link an - * IllegalStateException will be thrown. The receiver will not rendezvous - * with a sender in this case. - * - * @return - */ - final LinkMessage receive() throws ClosedLinkException, - IllegalStateException, InterruptedIOException, IOException { - if (VmIsolate.currentIsolate() != receiver) { - // Current isolate is not the receiver - throw new IllegalStateException(); - } - if (this.closed) { - throw new ClosedLinkException(); - } - final LinkMessageImpl message; - synchronized (this) { - while (messages.isEmpty()) { - if (this.closed) { - throw new ClosedLinkException(); - } - try { - wait(); - } catch (InterruptedException ex) { - throw new InterruptedIOException(); - } - } - message = messages.poll(); - } - message.notifyReceived(); - return message.CloneMessage(); - } - - /** - * Sends the given message on this Link. - * <p/> - * The current thread will block in this method until a receiver is - * available. When the sender and receiver rendezvous, the message will then - * be transferred. A normal return indicates that the message was - * transferred. If an exception occurs on the sender side, no rendezvous - * will occur and no object will be transferred. But if an exception occurs - * on the receive(), the sender will see a successful transfer. - * <p/> - * If the receiving isolate becomes terminated after this method is invoked - * but before it returns, the link will be closed, a ClosedLinkException - * will be thrown, any subsequent attempts to use send() will result in a - * ClosedLinkException, and any Isolate objects corresponding to the receive - * side of the link will reflect a terminated state. - * <p/> - * If invoked on a closed link, this method will throw a - * ClosedLinkException. - * <p/> - * If close() is invoked on this Link while a thread is blocked in send(), - * send() will throw a ClosedLinkException. No message will have been - * transferred in that case. - * <p/> - * If Thread.interrupt() is invoked on a thread that has not yet completed - * an invocation of this method, the results are undefined. An - * InterruptedIOException may or may not be thrown; however, even if not, - * control will return from the method. Rendezvous and data transfer to the - * receiving isolate may or may not have occurred. In particular, undetected - * message loss between sender and receiver may occur. - * <p/> - * If a failure occurs during the transfer an IOException may be thrown in - * the sender and the object will not be sent. A transfer may succeed from - * the sender's point of view, but cause an independent IOException in the - * receiver. For example, if a message containing a large buffer is sent and - * the receiver has insufficient heap memory for the buffer or if - * construction of a link in the receiver isolate fails, an IOException will - * be thrown in the receiver after the transfer completes. - * <p/> - * A ClosedLinkException will be thrown if the given LinkMessage contains a - * closed Link, Socket, or ServerSocket. No object will be transferred in - * this case. - * <p/> - * If the current isolate is not a sender on this Link, an - * UnsupportedOperationException will be thrown. No object will be sent in - * this case. - * - * @param message - * @throws ClosedLinkException - * @throws InterruptedIOException - * @throws IOException - */ - final void send(LinkMessage message) throws ClosedLinkException, - InterruptedIOException, IOException { - if (VmIsolate.currentIsolate() != sender) { - // Current isolate is not a sender - throw new UnsupportedOperationException(); - } - if (this.closed) { - throw new ClosedLinkException(); - } - final LinkMessageImpl messageImpl = (LinkMessageImpl) message; - synchronized (this) { - if (this.closed) { - throw new ClosedLinkException(); - } - // Send message - messages.add(messageImpl); - notifyAll(); - } - - // Wait for the message to be picked up by the receiver - try { - messageImpl.waitUntilReceived(); - } catch (InterruptedException ex) { - throw new InterruptedIOException(); - } - } -} Added: trunk/core/src/core/org/jnode/vm/isolate/link/VmLink.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/link/VmLink.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/isolate/link/VmLink.java 2008-09-30 12:00:11 UTC (rev 4592) @@ -0,0 +1,295 @@ +/* + * $Id: VmDataLink.java 4552 2008-09-11 11:38:42Z crawley $ + */ +package org.jnode.vm.isolate.link; + +import java.io.IOException; +import java.io.InterruptedIOException; +import java.util.LinkedList; +import java.util.Queue; + +import javax.isolate.ClosedLinkException; +import javax.isolate.Link; +import javax.isolate.LinkMessage; + +import org.jnode.vm.isolate.VmIsolate; +import org.jnode.vm.isolate.VmIsolateLocal; + +/** + * Shared implementation of javax.isolate.Link + * + * @author Ewout Prangsma (ep...@us...) + */ +public final class VmLink { + + private final VmIsolateLocal<LinkImpl> linkHolder = new VmIsolateLocal<LinkImpl>(); + + private final Queue<LinkMessageImpl> messages = new LinkedList<LinkMessageImpl>(); + + private boolean closed = false; + + private VmIsolate sender; + + private VmIsolate receiver; + + /** + * Create a new data link between the given isolates. + * + * @param sender + * @param receiver + * @return + */ + public static Link newLink(VmIsolate sender, VmIsolate receiver) { + if (sender == receiver) { + throw new IllegalArgumentException("sender == receiver"); + } + VmLink vmLink = new VmLink(sender, receiver); + return vmLink.asLink(); + } + + public static VmLink fromLink(Link link) { + return ((LinkImpl) link).getImpl(); + } + + /** + * @param sender + * @param receiver + */ + VmLink(VmIsolate sender, VmIsolate receiver) { + this.sender = sender; + this.receiver = receiver; + } + + /** + * Gets this shared link as Link instance. + * + * @return + */ + public final Link asLink() { + final LinkImpl link = linkHolder.get(); + if (link == null) { + linkHolder.set(new LinkImpl(this)); + return linkHolder.get(); + } else { + return link; + } + } + + /** + * Close this link. + */ + final void close() { + if (!this.closed) { + final VmIsolate current = VmIsolate.currentIsolate(); + if ((current != receiver) && (current != sender)) { + throw new IllegalStateException( + "Only sender or receiver can close this link"); + } + this.closed = true; + synchronized (this) { + notifyAll(); + } + } + } + + /** + * Is this link currently open. + * + * @return + */ + final boolean isOpen() { + return !closed; + } + + /** + * @return the receiver + */ + final VmIsolate getReceiver() { + return receiver; + } + + /** + * @return the sender + */ + final VmIsolate getSender() { + return sender; + } + + /** + * Receives a copy of a message sent on this Link. + * <p/> + * The current thread will block in this method until a sender is available. + * When the sender and receiver rendezvous, the message will then be + * transferred. If multiple threads invoke this method on the same object, + * only one thread will receive any message at rendezvous and the other + * threads will contend for subsequent access to the rendezvous point. A + * normal return indicates that the message was received successfully. If an + * exception occured on the sender side, no rendezvous will occur, and no + * object will be transferred; the receiver will wait for the next + * successful send. If an exception occurs on the receive, the sender will + * see a successful transfer. + * <p/> + * This method never returns null. + * <p/> + * If the sending isolate becomes terminated after this method is invoked + * but before it returns, the link will be closed, a ClosedLinkException + * will be thrown, any subsequent attempts to use receive() will result in a + * ClosedLinkException, and any Isolate objects corresponding to the receive + * side of the link will reflect a terminated state. + * <p/> + * If invoked on a closed Link, this method will throw a + * ClosedLinkException. + * <p/> + * If close() is invoked on the link while a thread is blocked in receive(), + * receive() will throw a ClosedLinkException. No message will have been + * transferred in that case. + * <p/> + * If Thread.interrupt() is invoked on a thread that has not yet completed + * an invocation of this method, the results are undefined. An + * InterruptedIOException may or may not be thrown; if not, control will + * return from the method with a valid LinkMessage object. However, even if + * InterruptedIOException is thrown, rendezvous and data transfer from the + * sending isolate may have occurred. In particular, undetected message loss + * between sender and receiver may occur. + * <p/> + * If a failure occurs due to the object being transferred between isolates + * an IOException may be thrown in the receiver. For example, if a message + * containing a large buffer is sent and the receiver has insufficient heap + * memory for the buffer or if construction of a link in the receiver + * isolate fails, an IOException will be thrown. The sender will see a + * successful transfer in these cases. + * <p/> + * If the current isolate is not a receiver on this Link an + * IllegalStateException will be thrown. The receiver will not rendezvous + * with a sender in this case. + * + * @return + */ + final LinkMessage receive() throws ClosedLinkException, + IllegalStateException, InterruptedIOException, IOException { + if (VmIsolate.currentIsolate() != receiver) { + // Current isolate is not the receiver + throw new IllegalStateException(); + } + if (this.closed) { + throw new ClosedLinkException(); + } + final LinkMessageImpl message; + synchronized (this) { + while (messages.isEmpty()) { + if (this.closed) { + throw new ClosedLinkException(); + } + try { + wait(); + } catch (InterruptedException ex) { + throw new InterruptedIOException(); + } + } + message = messages.poll(); + } + message.notifyReceived(); + return message.CloneMessage(); + } + + /** + * Sends the given message on this Link. + * <p/> + * The current thread will block in this method until a receiver is + * available. When the sender and receiver rendezvous, the message will then + * be transferred. A normal return indicates that the message was + * transferred. If an exception occurs on the sender side, no rendezvous + * will occur and no object will be transferred. But if an exception occurs + * on the receive(), the sender will see a successful transfer. + * <p/> + * If the receiving isolate becomes terminated after this method is invoked + * but before it returns, the link will be closed, a ClosedLinkException + * will be thrown, any subsequent attempts to use send() will result in a + * ClosedLinkException, and any Isolate objects corresponding to the receive + * side of the link will reflect a terminated state. + * <p/> + * If invoked on a closed link, this method will throw a + * ClosedLinkException. + * <p/> + * If close() is invoked on this Link while a thread is blocked in send(), + * send() will throw a ClosedLinkException. No message will have been + * transferred in that case. + * <p/> + * If Thread.interrupt() is invoked on a thread that has not yet completed + * an invocation of this method, the results are undefined. An + * InterruptedIOException may or may not be thrown; however, even if not, + * control will return from the method. Rendezvous and data transfer to the + * receiving isolate may or may not have occurred. In particular, undetected + * message loss between sender and receiver may occur. + * <p/> + * If a failure occurs during the transfer an IOException may be thrown in + * the sender and the object will not be sent. A transfer may succeed from + * the sender's point of view, but cause an independent IOException in the + * receiver. For example, if a message containing a large buffer is sent and + * the receiver has insufficient heap memory for the buffer or if + * construction of a link in the receiver isolate fails, an IOException will + * be thrown in the receiver after the transfer completes. + * <p/> + * A ClosedLinkException will be thrown if the given LinkMessage contains a + * closed Link, Socket, or ServerSocket. No object will be transferred in + * this case. + * <p/> + * If the current isolate is not a sender on this Link, an + * UnsupportedOperationException will be thrown. No object will be sent in + * this case. + * + * @param message + * @throws ClosedLinkException + * @throws InterruptedIOException + * @throws IOException + */ + final void send(LinkMessage message) throws ClosedLinkException, + InterruptedIOException, IOException { + if (VmIsolate.currentIsolate() != sender) { + // Current isolate is not the sender for this message + throw new UnsupportedOperationException(); + } + if (this.closed) { + throw new ClosedLinkException(); + } + final LinkMessageImpl messageImpl = (LinkMessageImpl) message; + synchronized (this) { + if (this.closed) { + throw new ClosedLinkException(); + } + // Send message + messages.add(messageImpl); + notifyAll(); + } + + // Wait for the message to be picked up by the receiver + try { + messageImpl.waitUntilReceived(); + } catch (InterruptedException ex) { + throw new InterruptedIOException(); + } + } + + /** + * This method is used to send status messages. These are sent + * without blocking and are queued in the link for the receiver + * to read at its leisure. If the link is closed when this + * method is called, the message is quietly dropped. + * + * @param message the status message to be sent. + */ + public final void sendStatus(LinkMessage message) { + if (VmIsolate.currentIsolate() != sender) { + // Current isolate is not the sender for this message + throw new UnsupportedOperationException(); + } + final LinkMessageImpl messageImpl = (LinkMessageImpl) message; + synchronized (this) { + if (!this.closed) { + // Send message + messages.add(messageImpl); + notifyAll(); + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-10-12 20:00:56
|
Revision: 4626 http://jnode.svn.sourceforge.net/jnode/?rev=4626&view=rev Author: lsantha Date: 2008-10-12 20:00:40 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Prorgess with isolates: clarification of exit reason, initial system exit support, child isolates. Modified Paths: -------------- trunk/core/src/classpath/ext/javax/isolate/Isolate.java trunk/core/src/classpath/ext/javax/isolate/IsolateStatus.java trunk/core/src/classpath/vm/java/lang/VMRuntime.java trunk/core/src/core/org/jnode/vm/isolate/IsolateStatusImpl.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java Modified: trunk/core/src/classpath/ext/javax/isolate/Isolate.java =================================================================== --- trunk/core/src/classpath/ext/javax/isolate/Isolate.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/classpath/ext/javax/isolate/Isolate.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -21,24 +21,25 @@ package javax.isolate; +import gnu.java.security.action.GetPropertiesAction; +import java.security.AccessController; import java.util.Properties; -import java.security.AccessController; - import org.jnode.vm.isolate.VmIsolate; -import gnu.java.security.action.GetPropertiesAction; /** * @author Ewout Prangsma (ep...@us...) */ public final class Isolate { - /** The actual isolate implementation */ + /** + * The actual isolate implementation + */ private final VmIsolate impl; //todo hide this constructor /** * Constructor for the root isolate. - * + * * @param impl the JNode speciffic isolate implementation */ public Isolate(VmIsolate impl) { @@ -47,7 +48,7 @@ /** * Initialize this instance. - * + * * @param mainClass * @param args */ @@ -57,7 +58,7 @@ /** * Initialize this instance. - * + * * @param mainClass * @param args * @param properties @@ -80,7 +81,7 @@ /** * Gets the isolate that is running the current thread. - * + * * @return */ public static Isolate currentIsolate() { @@ -89,7 +90,7 @@ /** * If this object equal to the given object. - * + * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object other) { @@ -98,7 +99,7 @@ /** * Request normal termination of this isolate. - * + * * @param status */ public void exit(int status) { @@ -107,17 +108,17 @@ /** * Force termination of this isolate. - * + * * @param status */ public void halt(int status) { - impl.halt(this, status); + impl.halt(status); } /** * Gets a new Link associated with this Isolate from which the current * isolate can receive status link messages. - * + * * @return * @throws ClosedLinkException */ @@ -127,7 +128,7 @@ /** * Start this isolate. - * + * * @param links * @throws IsolateStartupException */ @@ -141,43 +142,46 @@ * terminated. New isolates may have been constructed or existing ones terminated by the time method returns. * * @return the active Isolate objects present at the time of the call - * * @throws SecurityException if a security manager is present and permission to query isolates is denied */ public static Isolate[] getIsolates() { - //todo implement it - throw new UnsupportedOperationException(); + VmIsolate[] children = currentIsolate().impl.getChildren(); + int c_nr = children.length; + Isolate[] ret = new Isolate[c_nr]; + for (int i = 0; i < c_nr; i++) + ret[i] = children[i].getIsolate(); + + return ret; } /** * Returns the name of the main class of this isolate. - * + * * @return the name of the main class of this isolate */ public String getMainClassName() { - return impl.getMainClassName(); + return impl.getMainClassName(); } /** * Returns the current state of the isolate. * * @return the current state of an isolate - * * @throws IllegalStateException if called before the isolate is started - * @throws SecurityException if a security manager is present and permission to query isolates is denied + * @throws SecurityException if a security manager is present and permission to query isolates is denied */ - public IsolateStatus.State getState() { + public IsolateStatus.State getState() { return impl.getIsolateState(); } - + /** * Retrieves a copy of the Link array passed to start() by the current * isolate's creator. Modification of this array will have no effect on * subsequent invocation of this method. - * + * <p/> * This method never returns null: it will return a zero-length array if * this isolate's creator passed null to start(). - * + * * @return */ public static Link[] getLinks() { @@ -187,7 +191,7 @@ //todo hide this method /** * Gets the implementation instance. - * + * * @return */ final VmIsolate getImpl() { Modified: trunk/core/src/classpath/ext/javax/isolate/IsolateStatus.java =================================================================== --- trunk/core/src/classpath/ext/javax/isolate/IsolateStatus.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/classpath/ext/javax/isolate/IsolateStatus.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -18,49 +18,75 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package javax.isolate; +import org.jnode.vm.annotation.SharedStatics; + /** + * Represents isolate status, capturing such information as isolate state, exit code, and exit reason. + * State transitions in the isolate life cycle generate LinkMessages containing instances of this class + * which are sent over status links (but can be then forwarded over any link). If the isolate state is EXITED, + * the corresponding exit code and exit reason are contained in IsolateStatus. + * * @author Ewout Prangsma (ep...@us...) + * @author Levente S\u00e1ntha */ public class IsolateStatus { /** * Defines the state of an Isolate. - * + * * @author Ewout Prangsma (ep...@us...) */ + @SharedStatics public static enum State { - /** Isolate is starting */ + /** + * Isolate is starting + */ STARTING, - /** Isolate is started */ + /** + * Isolate is started + */ STARTED, - /** Isolate is exiting */ + /** + * Isolate is exiting + */ EXITING, - /** Isolate has exited */ + /** + * Isolate has exited + */ EXITED, - /** State is not known */ - UNKNOWN; + /** + * State is not known + */ + UNKNOWN } /** * Provides the reason for the termination of an isolate. - * + * * @author Ewout Prangsma (ep...@us...) */ + @SharedStatics public static enum ExitReason { - /** The last non-deamon thread exited */ + /** + * The last non-deamon thread exited + */ IMPLICIT_EXIT, - /** Another isolate invoked Isolate.exit */ + /** + * Another isolate invoked Isolate.exit + */ OTHER_EXIT, - /** Another isolate invoed Isolated.halt */ + /** + * Another isolate invoed Isolated.halt + */ OTHER_HALT, /** @@ -74,55 +100,91 @@ */ SELF_HALT, - /** The last non-deamon thread exited due to an uncaught exception */ - UNCAUGHT_EXCEPTION; + /** + * The last non-deamon thread exited due to an uncaught exception + */ + UNCAUGHT_EXCEPTION } - + private final ExitReason exitReason; private final State state; private final int exitCode; - + /** * Initialize this instance. + * * @param state * @param exitReason * @param exitCode */ protected IsolateStatus(State state, ExitReason exitReason, int exitCode) { + if (state == null) + throw new IllegalArgumentException(); + + if (state.equals(State.EXITED) && exitReason == null) + throw new IllegalArgumentException(); + this.state = state; this.exitReason = exitReason; this.exitCode = exitCode; } - + /** - * Are this and the given object equal. - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - return super.equals(other); - } - - /** * Gets the exit reason. + * * @return */ public ExitReason getExitReason() { return exitReason; } - + /** * Gets the exit code. + * * @return */ public int getExitCode() { return exitCode; } - + /** * Gets the state of the isolate. + * * @return */ public State getState() { return state; } + + /** + * @param o + * @return + */ + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof IsolateStatus)) return false; + + IsolateStatus that = (IsolateStatus) o; + + if (!state.equals(that.state)) return false; + + if (state.equals(State.EXITED)) { + if (exitCode != that.exitCode) return false; + if (exitReason != that.exitReason) return false; + } + + return true; + } + + /** + * @return + */ + public int hashCode() { + int result = state.hashCode(); + if (state.equals(State.EXITED)) { + result = 31 * result + exitReason.hashCode(); + result = 31 * result + exitCode; + } + return result; + } } Modified: trunk/core/src/classpath/vm/java/lang/VMRuntime.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMRuntime.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/classpath/vm/java/lang/VMRuntime.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -28,6 +28,8 @@ import org.jnode.vm.VmProcess; import org.jnode.vm.VmSystem; import org.jnode.vm.VmExit; +import org.jnode.vm.isolate.VmIsolate; +import javax.isolate.Isolate; /** * VMRuntime represents the interface to the Virtual Machine. @@ -153,7 +155,11 @@ * @param status the status to end the process with */ static void exit(int status) { - throw new VmExit(status); + if(VmIsolate.getRoot() == VmIsolate.currentIsolate()){ + throw new VmExit(status); + } else { + VmIsolate.currentIsolate().systemExit(Isolate.currentIsolate(), status); + } } /** Modified: trunk/core/src/core/org/jnode/vm/isolate/IsolateStatusImpl.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/IsolateStatusImpl.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/core/org/jnode/vm/isolate/IsolateStatusImpl.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -9,10 +9,15 @@ * @author Levente S\u00e1ntha */ public class IsolateStatusImpl extends IsolateStatus implements Cloneable { - public IsolateStatusImpl(State state, ExitReason exitReason, int exitCode) { - super(state, exitReason, exitCode); + + public IsolateStatusImpl(State state) { + super(state, null, 0); } + public IsolateStatusImpl(ExitReason exitReason, int exitCode) { + super(State.EXITED, exitReason, exitCode); + } + @Override protected Object clone() throws CloneNotSupportedException { return super.clone(); @@ -30,7 +35,7 @@ public String toString() { State s = getState(); if (s.equals(State.EXITED)) { - return getState() + "(" + getExitReason() + "," + getExitCode(); + return getState() + "(" + getExitReason() + "," + getExitCode() + ")"; } else { return getState().toString(); } Modified: trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -153,6 +153,8 @@ */ private BootableHashMap<VmIsolateLocal<?>, ?> isolateLocalMap = new BootableHashMap<VmIsolateLocal<?>, Object>(); + private List<VmIsolate> children = new LinkedList<VmIsolate>(); + /** * Isolate states. * @@ -369,23 +371,49 @@ return isolate; } + public final void exit(Isolate isolate, int status) { + exit0(isolate, status); + } + + public final void systemExit(Isolate isolate, int status) { + //only this isolate may call this method + testIsolate(isolate); + + this.exitReason = IsolateStatus.ExitReason.SELF_EXIT; + this.exitCode = status; + + int ac = threadGroup.activeCount(); + if (ac > 0) { + Thread[] ta = new Thread[ac]; + int rc = threadGroup.enumerate(ta); + Thread current = Thread.currentThread(); + boolean found = false; + for (int i = 0; i < rc; i++) { + Thread thread = ta[i]; + if (current != thread) { + thread.getVmThread().stopForced(null); + } else { + found = true; + } + } + if (found) { + current.getVmThread().stop(null); + } + } + } + /** * Request normal termination of this isolate. * * @param status */ - public final void exit(Isolate isolate, int status) { - testIsolate(isolate); + public final void exit0(Isolate isolate, int status) { + //testIsolate(isolate); //todo handle demon threads if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) return; changeState(State.EXITING); - try { - threadGroup.destroy(); - } catch (Throwable t) { - t.printStackTrace(); - } this.exitCode = status; if (currentIsolate() == this) { @@ -395,18 +423,60 @@ this.exitReason = IsolateStatus.ExitReason.OTHER_EXIT; } - changeState(State.EXITED); - StaticData.isolates.remove(this); + doExit(); } /** + * Request normal termination of this isolate. + * + * @param status + */ + public final void implicitExit(int status) { + //on this isolate may call this method + testIsolate(currentIsolate().isolate); + + //todo handle demon threads + if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) + return; + + changeState(State.EXITING); + + if (exitReason == null) { + exitReason = IsolateStatus.ExitReason.IMPLICIT_EXIT; + this.exitCode = status; + } + + doExit(); + } + + /** + * Request normal termination of this isolate. + * + * @param status + */ + public final void uncaughtExceptionExit() { + //on this isolate may call this method + testIsolate(currentIsolate().isolate); + + //todo handle demon threads + if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) + return; + + changeState(State.EXITING); + + exitReason = IsolateStatus.ExitReason.UNCAUGHT_EXCEPTION; + this.exitCode = -1; + + doExit(); + } + + /** * Force termination of this isolate. * * @param status */ @SuppressWarnings("deprecation") - public final void halt(Isolate isolate, int status) { - testIsolate(isolate); + public final void halt(int status) { changeState(State.EXITING); switch (state) { case EXITING: @@ -414,19 +484,28 @@ break; } + if (currentIsolate() == this) { + this.exitReason = IsolateStatus.ExitReason.SELF_HALT; + } else { + this.exitReason = IsolateStatus.ExitReason.OTHER_HALT; + } + + this.exitCode = status; + + doExit(); + } + + private void doExit() { try { threadGroup.destroy(); } catch (Throwable t) { t.printStackTrace(); } - this.exitCode = status; - if (currentIsolate() == this) { - this.exitReason = IsolateStatus.ExitReason.SELF_HALT; - } else { - this.exitReason = IsolateStatus.ExitReason.OTHER_HALT; - } + + this.creator.removeChild(this); + StaticData.isolates.remove(this); + changeState(State.EXITED); - StaticData.isolates.remove(this); } /** @@ -677,6 +756,8 @@ // Update the state of this isolate. changeState(State.STARTED); + //add to parent + this.creator.addChild(this); // Run main method. mainMethod.invoke(null, new Object[]{args}); @@ -842,10 +923,21 @@ private void sendStatus(VmLink link, IsolateStatus.State state) { if (state.equals(IsolateStatus.State.EXITED)) { - org.jnode.vm.Unsafe.debugStackTrace(); - link.sendStatus(new StatusLinkMessage(new IsolateStatusImpl(state, exitReason, exitCode))); + link.sendStatus(new StatusLinkMessage(new IsolateStatusImpl(exitReason, exitCode))); } else { - link.sendStatus(new StatusLinkMessage(new IsolateStatusImpl(state, null, -1))); + link.sendStatus(new StatusLinkMessage(new IsolateStatusImpl(state))); } } + + private synchronized void addChild(VmIsolate child) { + this.children.add(child); + } + + private synchronized void removeChild(VmIsolate child) { + this.children.remove(child); + } + + public synchronized VmIsolate[] getChildren() { + return this.children.toArray(new VmIsolate[children.size()]); + } } Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -32,6 +32,7 @@ import org.jnode.vm.VmStackReader; import org.jnode.vm.VmSystem; import org.jnode.vm.VmSystemObject; +import org.jnode.vm.isolate.VmIsolate; import org.jnode.vm.annotation.Inline; import org.jnode.vm.annotation.Internal; import org.jnode.vm.annotation.KernelSpace; @@ -47,7 +48,6 @@ import org.jnode.vm.memmgr.VmHeapManager; import org.vmmagic.pragma.UninterruptiblePragma; import org.vmmagic.unboxed.Address; -import javax.isolate.Isolate; /** * VM thread implementation @@ -390,7 +390,10 @@ if (javaThread != null) { javaThread.onExit(); //exit the current isolate if needed - Isolate.currentIsolate().exit(0); + if (ex instanceof ThreadDeath) + VmIsolate.currentIsolate().implicitExit(0); + else + VmIsolate.currentIsolate().uncaughtExceptionExit(); // Notify joining threads synchronized (javaThread) { javaThread.notifyAll(); @@ -407,6 +410,26 @@ * @param ex * @throws UninterruptiblePragma */ + public final void stopForced(Throwable ex) throws UninterruptiblePragma { + this.stopping = true; + if (javaThread != null) { + javaThread.onExit(); + // Notify joining threads + synchronized (javaThread) { + javaThread.notifyAll(); + } + } + + // Do the low level stop uninterrupted + doStop(); + } + + /** + * Stop the thread permanently. + * + * @param ex + * @throws UninterruptiblePragma + */ @Uninterruptible private final void doStop() { final VmProcessor proc = VmMagic.currentProcessor(); @@ -722,17 +745,22 @@ */ @LoadStatics protected static final void runThread(VmThread thread) { + Throwable t = null; try { thread.asThread().run(); } catch (Throwable ex) { try { + t = ex; ex.printStackTrace(); } catch (Throwable ex2) { /* Ignore */ } } finally { try { - thread.stop(new ThreadDeath()); + if (t == null) + thread.stop(new ThreadDeath()); + else + thread.stop(t); } catch (Throwable ex) { /* Ignore */ while (true) { Modified: trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java =================================================================== --- trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-10-12 10:33:26 UTC (rev 4625) +++ trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-10-12 20:00:40 UTC (rev 4626) @@ -4,7 +4,6 @@ package org.jnode.test.core; import java.io.IOException; -import java.io.InterruptedIOException; import javax.isolate.Isolate; import javax.isolate.IsolateStartupException; import javax.isolate.IsolateStatus; @@ -13,7 +12,7 @@ public class StatusLinkTest { - public static void main(String[] args) throws IsolateStartupException, InterruptedIOException, IOException { + public static void main(String[] args) throws IsolateStartupException, IOException { String clsName = ChildClass.class.getName(); Isolate child = new Isolate(clsName); Link link = child.newStatusLink(); @@ -34,6 +33,7 @@ LinkMessage msg = link.receive(); if (msg.containsStatus()) { IsolateStatus is = msg.extractStatus(); + System.out.println("Isolate status: " + is); if (is.getState().equals(IsolateStatus.State.EXITED)) { System.out.println("Message: state=" + is.getState() + " code=" + is.getExitCode() + " reason=" + is.getExitReason()); @@ -57,6 +57,23 @@ System.out.println("Child: started"); System.out.println("Child: sleeping 3 seconds"); Thread.sleep(3000); + //if(true) + // throw new RuntimeException(); + new Thread(new Runnable() { + public void run() { + try { + System.out.println("Child thread: started"); + System.out.println("Child thread: sleeping 3 seconds"); + Thread.sleep(3000); + if (true) + throw new RuntimeException(); + System.out.println("Child thread: exiting"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + }).start(); + System.out.println("Child: exiting"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-10-15 20:18:47
|
Revision: 4637 http://jnode.svn.sourceforge.net/jnode/?rev=4637&view=rev Author: lsantha Date: 2008-10-15 20:18:40 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Imroved external isolate stopping and extended StatusLinkTest. Modified Paths: -------------- trunk/core/src/classpath/ext/javax/isolate/Isolate.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java Modified: trunk/core/src/classpath/ext/javax/isolate/Isolate.java =================================================================== --- trunk/core/src/classpath/ext/javax/isolate/Isolate.java 2008-10-15 18:57:18 UTC (rev 4636) +++ trunk/core/src/classpath/ext/javax/isolate/Isolate.java 2008-10-15 20:18:40 UTC (rev 4637) @@ -103,7 +103,7 @@ * @param status */ public void exit(int status) { - impl.exit(this, status); + impl.isolateExit(status); } /** Modified: trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-10-15 18:57:18 UTC (rev 4636) +++ trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-10-15 20:18:40 UTC (rev 4637) @@ -371,17 +371,32 @@ return isolate; } - public final void exit(Isolate isolate, int status) { - exit0(isolate, status); + public final void isolateExit(int status) { + changeState(State.EXITING); + + this.exitCode = status; + if (currentIsolate() == this) { + this.exitReason = IsolateStatus.ExitReason.SELF_EXIT; + } else { + this.exitReason = IsolateStatus.ExitReason.OTHER_EXIT; + } + + stopAllThreads(); } public final void systemExit(Isolate isolate, int status) { //only this isolate may call this method testIsolate(isolate); + changeState(State.EXITING); + this.exitReason = IsolateStatus.ExitReason.SELF_EXIT; this.exitCode = status; + stopAllThreads(); + } + + private void stopAllThreads() { int ac = threadGroup.activeCount(); if (ac > 0) { Thread[] ta = new Thread[ac]; @@ -397,33 +412,13 @@ } } if (found) { - current.getVmThread().stop(null); + current.getVmThread().stop(new ThreadDeath()); + } else { + doExit(); } - } - } - - /** - * Request normal termination of this isolate. - * - * @param status - */ - public final void exit0(Isolate isolate, int status) { - //testIsolate(isolate); - //todo handle demon threads - if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) - return; - - changeState(State.EXITING); - - this.exitCode = status; - if (currentIsolate() == this) { - //todo implement: IMPLICIT_EXIT, UNCAUGHT_EXCEPTION - this.exitReason = IsolateStatus.ExitReason.SELF_EXIT; } else { - this.exitReason = IsolateStatus.ExitReason.OTHER_EXIT; + //todo analyze this case } - - doExit(); } /** @@ -439,9 +434,8 @@ if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) return; - changeState(State.EXITING); - if (exitReason == null) { + changeState(State.EXITING); exitReason = IsolateStatus.ExitReason.IMPLICIT_EXIT; this.exitCode = status; } @@ -451,8 +445,6 @@ /** * Request normal termination of this isolate. - * - * @param status */ public final void uncaughtExceptionExit() { //on this isolate may call this method Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java 2008-10-15 18:57:18 UTC (rev 4636) +++ trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java 2008-10-15 20:18:40 UTC (rev 4637) @@ -124,6 +124,10 @@ allThreadsLock.lock(); try { allThreadsQueue.remove(thread); + //todo recent change, more testing needed + //remove the thread from readyQueue and sleepQueue too + readyQueue.remove(thread); + sleepQueue.remove(thread); } finally { allThreadsLock.unlock(); } Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-10-15 18:57:18 UTC (rev 4636) +++ trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-10-15 20:18:40 UTC (rev 4637) @@ -390,10 +390,11 @@ if (javaThread != null) { javaThread.onExit(); //exit the current isolate if needed - if (ex instanceof ThreadDeath) + if (ex instanceof ThreadDeath) { VmIsolate.currentIsolate().implicitExit(0); - else + } else { VmIsolate.currentIsolate().uncaughtExceptionExit(); + } // Notify joining threads synchronized (javaThread) { javaThread.notifyAll(); Modified: trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java =================================================================== --- trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-10-15 18:57:18 UTC (rev 4636) +++ trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-10-15 20:18:40 UTC (rev 4637) @@ -3,23 +3,51 @@ */ package org.jnode.test.core; -import java.io.IOException; import javax.isolate.Isolate; -import javax.isolate.IsolateStartupException; import javax.isolate.IsolateStatus; import javax.isolate.Link; import javax.isolate.LinkMessage; +import javax.isolate.ClosedLinkException; +import javax.isolate.IsolateStartupException; public class StatusLinkTest { - public static void main(String[] args) throws IsolateStartupException, IOException { - String clsName = ChildClass.class.getName(); - Isolate child = new Isolate(clsName); - Link link = child.newStatusLink(); - new Thread(new StatusMonitor(link)).start(); + public static void main(String[] args) throws Exception { + + runChild(ChildClass1.class); + + runChild(ChildClass2.class); + + runChild(ChildClass3.class); + + runChild(ChildClass4.class); + + runChild(ChildClass5.class); + + runChild(ChildClass6.class); + + Isolate child = new Isolate(ChildClass7.class.getName()); + new Thread(new StatusMonitor(child.newStatusLink()), "status-monitor").start(); child.start(); + + try { + Thread.sleep(100); + } finally { + child.exit(0); + } } + private static void runChild(Class<?> clazz) + throws ClosedLinkException, IsolateStartupException, InterruptedException { + Isolate child; + Thread moni; + child = new Isolate(clazz.getName()); + moni = new Thread(new StatusMonitor(child.newStatusLink()), "status-monitor"); + moni.start(); + child.start(); + moni.join(); + } + public static class StatusMonitor implements Runnable { private final Link link; @@ -33,13 +61,10 @@ LinkMessage msg = link.receive(); if (msg.containsStatus()) { IsolateStatus is = msg.extractStatus(); - System.out.println("Isolate status: " + is); + System.out.println("Got status message: " + is); + //org.jnode.vm.Unsafe.debug("Got status message: " + is + "\n"); if (is.getState().equals(IsolateStatus.State.EXITED)) { - System.out.println("Message: state=" + is.getState() + " code=" + is.getExitCode() + - " reason=" + is.getExitReason()); break; - } else { - System.out.println("Message: state=" + is.getState()); } } else { System.out.println("Unknown message: " + msg); @@ -51,30 +76,140 @@ } } - public static class ChildClass { + public static class ChildClass1 { + public static void main(String[] args) throws InterruptedException { + System.out.println("Child: started"); + System.out.println("Child: sleeping 2 seconds"); + Thread.sleep(2000); + System.out.println("Child: exiting"); + } + } + public static class ChildClass2 { public static void main(String[] args) throws InterruptedException { System.out.println("Child: started"); - System.out.println("Child: sleeping 3 seconds"); - Thread.sleep(3000); - //if(true) - // throw new RuntimeException(); new Thread(new Runnable() { public void run() { try { System.out.println("Child thread: started"); - System.out.println("Child thread: sleeping 3 seconds"); - Thread.sleep(3000); - if (true) - throw new RuntimeException(); + System.out.println("Child thread: sleeping 2 seconds"); + Thread.sleep(2000); System.out.println("Child thread: exiting"); } catch (InterruptedException ie) { ie.printStackTrace(); } } - }).start(); + }, "child-thread2").start(); + System.out.println("Child: exiting"); + } + } + public static class ChildClass3 { + public static void main(String[] args) throws InterruptedException { + System.out.println("Child: started"); + new Thread(new Runnable() { + public void run() { + try { + System.out.println("Child thread: started"); + System.out.println("Child thread: sleeping 2 seconds"); + Thread.sleep(2000); + System.out.println("Child thread: throwing an exception"); + throw new RuntimeException(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + }, "child-thread3").start(); + System.out.println("Child: exiting"); } } + + public static class ChildClass4 { + public static void main(String[] args) throws InterruptedException { + System.out.println("Child: started"); + new Thread(new Runnable() { + public void run() { + try { + System.out.println("Child thread: started"); + System.out.println("Child thread: sleeping 2 seconds"); + Thread.sleep(2000); + System.out.println("Child thread: calling System.exit()"); + System.exit(0); + System.out.println("Child thread: exiting"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + }, "child-thread4").start(); + + System.out.println("Child: exiting"); + } + } + + public static class ChildClass5 { + public static void main(String[] args) throws InterruptedException { + System.out.println("Child: started"); + new Thread(new Runnable() { + public void run() { + try { + System.out.println("Child thread: started"); + System.out.println("Child thread: sleeping 2 seconds"); + Thread.sleep(2000); + System.out.println("Child thread: callng Runtime.halt()"); + Runtime.getRuntime().halt(0); + System.out.println("Child thread: exiting"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + }, "child-thread5").start(); + + System.out.println("Child: exiting"); + } + } + + public static class ChildClass6 { + public static void main(String[] args) throws InterruptedException { + System.out.println("Child: started"); + new Thread(new Runnable() { + public void run() { + try { + System.out.println("Child thread: started"); + System.out.println("Child thread: sleeping 2 seconds"); + Thread.sleep(2000); + System.out.println("Child thread: calling Isolate.exit()"); + Isolate.currentIsolate().exit(0); + System.out.println("Child thread: exiting"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + }, "child-thread6").start(); + + System.out.println("Child: exiting"); + } + } + + public static class ChildClass7 { + public static void main(String[] args) throws InterruptedException { + System.out.println("Child: started"); + new Thread(new Runnable() { + public void run() { + System.out.println("Child thread: started"); + System.out.println("Child thread: working ..."); + for(int i = 0; i < 100000; i ++) { + // System.out.println("Child thread: " + i); + Math.sin(i); + if(i % 100 == 0) { + //org.jnode.vm.Unsafe.debug("i=" + i + "\n"); + System.out.println("i=" + i); + } + } + System.out.println("Child thread: exiting"); + } + }, "child-thread7").start(); + System.out.println("Child: exiting"); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-10-26 21:52:37
|
Revision: 4654 http://jnode.svn.sourceforge.net/jnode/?rev=4654&view=rev Author: lsantha Date: 2008-10-26 21:52:06 +0000 (Sun, 26 Oct 2008) Log Message: ----------- Clarified isolate exit reason. Modified Paths: -------------- trunk/core/src/classpath/vm/java/lang/VMRuntime.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java Modified: trunk/core/src/classpath/vm/java/lang/VMRuntime.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMRuntime.java 2008-10-26 21:38:26 UTC (rev 4653) +++ trunk/core/src/classpath/vm/java/lang/VMRuntime.java 2008-10-26 21:52:06 UTC (rev 4654) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package java.lang; import java.io.File; @@ -162,6 +162,19 @@ } } + /** + * Native method that actually shuts down the virtual machine. + * + * @param status the status to end the process with + */ + static void halt(int status) { + if(VmIsolate.getRoot() == VmIsolate.currentIsolate()){ + throw new VmExit(status); + } else { + VmIsolate.currentIsolate().systemHalt(Isolate.currentIsolate(), status); + } + } + /** * Load a file. If it has already been loaded, do nothing. The name has * already been mapped to a true filename. @@ -181,7 +194,7 @@ * it to the path. * XXX This method is being replaced by System.mapLibraryName. * - * @param pathname the path + * @param libname the path * @param libname the short version of the library name * @return the full filename */ Modified: trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-10-26 21:38:26 UTC (rev 4653) +++ trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-10-26 21:52:06 UTC (rev 4654) @@ -384,6 +384,19 @@ stopAllThreads(); } + public final void isolateHalt(int status) { + changeState(State.EXITING); + + this.exitCode = status; + if (currentIsolate() == this) { + this.exitReason = IsolateStatus.ExitReason.SELF_HALT; + } else { + this.exitReason = IsolateStatus.ExitReason.OTHER_HALT; + } + + stopAllThreads(); + } + public final void systemExit(Isolate isolate, int status) { //only this isolate may call this method testIsolate(isolate); @@ -396,6 +409,18 @@ stopAllThreads(); } + public final void systemHalt(Isolate isolate, int status) { + //only this isolate may call this method + testIsolate(isolate); + + changeState(State.EXITING); + + this.exitReason = IsolateStatus.ExitReason.SELF_HALT; + this.exitCode = status; + + stopAllThreads(); + } + private void stopAllThreads() { int ac = threadGroup.activeCount(); if (ac > 0) { @@ -407,7 +432,7 @@ Thread thread = ta[i]; if (current != thread) { thread.getVmThread().stopForced(null); - } else { + } else { found = true; } } @@ -417,7 +442,8 @@ doExit(); } } else { - //todo analyze this case + //todo analyze this case + doExit(); } } @@ -746,6 +772,10 @@ } }); + //create the appcontext for this isolate + //todo improve this + Class.forName("sun.awt.SunToolkit").getMethod("createNewAppContext").invoke(null); + // Update the state of this isolate. changeState(State.STARTED); //add to parent Modified: trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java =================================================================== --- trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-10-26 21:38:26 UTC (rev 4653) +++ trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-10-26 21:52:06 UTC (rev 4654) @@ -35,17 +35,27 @@ } finally { child.exit(0); } + + child = new Isolate(ChildClass7.class.getName()); + new Thread(new StatusMonitor(child.newStatusLink()), "status-monitor").start(); + child.start(); + + try { + Thread.sleep(100); + } finally { + child.halt(0); + } + } - private static void runChild(Class<?> clazz) + private static Isolate runChild(Class<?> clazz) throws ClosedLinkException, IsolateStartupException, InterruptedException { - Isolate child; - Thread moni; - child = new Isolate(clazz.getName()); - moni = new Thread(new StatusMonitor(child.newStatusLink()), "status-monitor"); + Isolate child = new Isolate(clazz.getName()); + Thread moni = new Thread(new StatusMonitor(child.newStatusLink()), "status-monitor"); moni.start(); child.start(); moni.join(); + return child; } public static class StatusMonitor implements Runnable { @@ -198,12 +208,12 @@ public void run() { System.out.println("Child thread: started"); System.out.println("Child thread: working ..."); - for(int i = 0; i < 100000; i ++) { + for (int i = 0; i < 100000; i++) { // System.out.println("Child thread: " + i); Math.sin(i); - if(i % 100 == 0) { - //org.jnode.vm.Unsafe.debug("i=" + i + "\n"); - System.out.println("i=" + i); + if (i % 100 == 0) { + org.jnode.vm.Unsafe.debug("i=" + i + "\n"); + //System.out.println("i=" + i); } } System.out.println("Child thread: exiting"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-11-09 12:24:56
|
Revision: 4691 http://jnode.svn.sourceforge.net/jnode/?rev=4691&view=rev Author: lsantha Date: 2008-11-09 12:24:49 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Support for releasing owned monitors on thread stop. Internal execution methods on behalf of an isolate. Improved isolate termination. Modified Paths: -------------- trunk/core/src/classpath/vm/java/lang/Thread.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java Added Paths: ----------- trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java Modified: trunk/core/src/classpath/vm/java/lang/Thread.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/Thread.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/classpath/vm/java/lang/Thread.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -408,9 +408,14 @@ * @param name */ protected Thread(ThreadGroup group, Runnable target, String name, VmIsolatedStatics isolatedStatics) { + /* if (!(this instanceof IsolateThread)) { throw new SecurityException("Constructor can only be called from IsolateThread"); } + */ + if (!(this.getClass().getName().startsWith("org.jnode.vm.isolate"))) { + throw new SecurityException("Constructor can only be called from IsolateThread"); + } if (group == null) { throw new InternalError("Isolate thread has invalid group: " + name); } Added: trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -0,0 +1,212 @@ +package org.jnode.vm.isolate; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; +import org.jnode.vm.classmgr.VmIsolatedStatics; +import org.jnode.vm.Vm; +import org.jnode.vm.VmSystem; +import org.jnode.plugin.PluginManager; +import org.jnode.naming.InitialNaming; +import javax.naming.NameNotFoundException; +import javax.isolate.IsolateStartupException; + +class IsolateThreadFactory implements ThreadFactory { + final ThreadGroup group; + final AtomicInteger threadNumber = new AtomicInteger(1); + final VmIsolatedStatics isolatedStatics; + final String namePrefix; + + IsolateThreadFactory(final VmIsolate isolate) { + group = isolate.getThreadGroup(); + namePrefix = "isolate-" + isolate.getId() + "-executor-"; + isolatedStatics = isolate.getIsolatedStaticsTable(); + } + + public Thread newThread(final Runnable r) { + class IsolateFactoryThread extends Thread { + IsolateFactoryThread(ThreadGroup group, String name, VmIsolatedStatics isolatedStatics) { + super(group, r, name, isolatedStatics); + } + } + + Thread t = new IsolateFactoryThread(group, namePrefix + threadNumber.getAndIncrement(), isolatedStatics){ + public void start() { + org.jnode.vm.Unsafe.debug("factory 1 thread start() " + this.getName() +"\n"); +// getVmThread().switchToIsolate(isolatedStatics); + super.start(); + } + }; + /* + PluginManager piManager; + try { + piManager = InitialNaming.lookup(PluginManager.NAME); + } catch (NameNotFoundException ex) { + throw new RuntimeException("Cannot find PluginManager", ex); + } + */ + //t.setContextClassLoader(piManager.getRegistry().getPluginsClassLoader()); +// if (t.isDaemon()) + // t.setDaemon(false); + // if (t.getPriority() != Thread.NORM_PRIORITY) + // t.setPriority(Thread.NORM_PRIORITY + 2); + return t; + } +} + + + + +class IsolateThreadFactory2 implements ThreadFactory { + final ThreadGroup group; + final AtomicInteger threadNumber = new AtomicInteger(1); + final VmIsolatedStatics isolatedStatics; + final String namePrefix; + private final Thread factoryThread; + private Thread newThread; + private final Object lock = new Object(); + private Runnable runnable; + + IsolateThreadFactory2(final VmIsolate isolate) { + group = isolate.getThreadGroup(); + namePrefix = "isolate-" + isolate.getId() + "-executor-"; + isolatedStatics = isolate.getIsolatedStaticsTable(); + factoryThread = new Thread(group, new Runnable(){ + public void run() { + while(true) { + synchronized (lock) { + try { + while(runnable == null) { + lock.wait(); + } + + newThread = new Thread(group, runnable, namePrefix + threadNumber.getAndIncrement()){ + public void start() { + org.jnode.vm.Unsafe.debug("factory thread start() " + this.getName() +"\n"); + super.start(); + } + }; + runnable = null; + lock.notifyAll(); + } catch (InterruptedException x) { + break; + } + } + } + } + },"isolate-" + isolate.getId() + "-thread-factory-"); + factoryThread.start(); + } + + public synchronized Thread newThread(final Runnable r) { + Thread ret; + org.jnode.vm.Unsafe.debug("IsolateThreadFactory2.newThread() called\n"); + org.jnode.vm.Unsafe.debugStackTrace(); + synchronized (lock) { + newThread = null; + runnable = r; + lock.notifyAll(); + while(newThread == null) { + try { + lock.wait(); + } catch (InterruptedException x) { + break; + } + } + ret = newThread; + newThread = null; + lock.notifyAll(); + } + org.jnode.vm.Unsafe.debug("IsolateThreadFactory2.newThread() returned\n"); + + return ret; + } +} + +/* ` +package org.jnode.vm.isolate; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; +import org.jnode.vm.classmgr.VmIsolatedStatics; + +class IsolateThreadFactory implements ThreadFactory { + final ThreadGroup group; + final AtomicInteger threadNumber = new AtomicInteger(1); + final VmIsolatedStatics isolatedStatics; + final String namePrefix; + + IsolateThreadFactory(final VmIsolate isolate) { + group = isolate.getThreadGroup(); + namePrefix = "isolate-" + isolate.getId() + "-executor-"; + isolatedStatics = isolate.getIsolatedStaticsTable(); + } + + public Thread newThread(final Runnable r) { + + org.jnode.vm.Unsafe.debug("newThread Called - 0\n"); + Thread t = new IsolateFactoryThread(group, r, namePrefix + threadNumber.getAndIncrement(), null); + org.jnode.vm.Unsafe.debug("newThread thread created - 0\n"); +// if (t.isDaemon()) + // t.setDaemon(false); + // if (t.getPriority() != Thread.NORM_PRIORITY) + // t.setPriority(Thread.NORM_PRIORITY + 2); + return t; + } +} + +class IsolateThreadFactory2 implements ThreadFactory { + final ThreadGroup group; + final AtomicInteger threadNumber = new AtomicInteger(1); + final VmIsolatedStatics isolatedStatics; + final String namePrefix; + private final Thread factoryThread; + private Thread newThread; + private final Object lock = new Object(); + private boolean flag = false; + + IsolateThreadFactory2(final VmIsolate isolate) { + group = isolate.getThreadGroup(); + namePrefix = "isolate-" + isolate.getId() + "-executor-"; + isolatedStatics = isolate.getIsolatedStaticsTable(); + factoryThread = new Thread(new Runnable(){ + public void run() { + while(true) { + synchronized (lock) { + try { + while(!flag) { + lock.wait(); + + } + + newThread = new IsolateFactoryThread(group, null, namePrefix + threadNumber.getAndIncrement(), null); + } catch (Exception x) { + x.printStackTrace(); + } + } + } + } + },"isolate-" + isolate.getId() + "-thread-factory-"); + factoryThread.start(); + } + + public Thread newThread(final Runnable r) { + + org.jnode.vm.Unsafe.debug("newThread Called - 0\n"); + Thread t = new IsolateFactoryThread(group, r, namePrefix + threadNumber.getAndIncrement(), null); + org.jnode.vm.Unsafe.debug("newThread thread created - 0\n"); +// if (t.isDaemon()) + // t.setDaemon(false); + // if (t.getPriority() != Thread.NORM_PRIORITY) + // t.setPriority(Thread.NORM_PRIORITY + 2); + return t; + } +} + + +class IsolateFactoryThread extends Thread { + IsolateFactoryThread(ThreadGroup group, Runnable r, String name, VmIsolatedStatics isolatedStatics) { + super(group, r, name, isolatedStatics); + } + } + +*/ \ No newline at end of file Modified: trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java =================================================================== --- trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -48,6 +48,7 @@ import org.jnode.vm.VmIOContext; import org.jnode.vm.VmMagic; import org.jnode.vm.VmSystem; +import org.jnode.vm.scheduler.VmThread; import org.jnode.vm.annotation.MagicPermission; import org.jnode.vm.annotation.PrivilegedActionPragma; import org.jnode.vm.annotation.SharedStatics; @@ -153,7 +154,7 @@ */ private BootableHashMap<VmIsolateLocal<?>, ?> isolateLocalMap = new BootableHashMap<VmIsolateLocal<?>, Object>(); - private List<VmIsolate> children = new LinkedList<VmIsolate>(); + private final List<VmIsolate> children = new LinkedList<VmIsolate>(); /** * Isolate states. @@ -235,7 +236,9 @@ static final VmIsolate getRoot() { if (rootIsolate == null) { - rootIsolate = new VmIsolate(); + rootIsolate = new VmIsolate(null/*Thread.currentThread().getVmThread().getIsolatedStatics()*/); +// org.jnode.vm.Unsafe.debug("getRoot() istatics: " + rootIsolate.isolatedStaticsTable + "\n"); +// org.jnode.vm.Unsafe.debugStackTrace(); } return rootIsolate; } @@ -265,7 +268,7 @@ /** * Constructor for the root isolate. */ - private VmIsolate() { + private VmIsolate(VmIsolatedStatics isolatedStatics) { this.id = StaticData.nextId(); this.isolate = new Isolate(this); this.mainClass = null; @@ -274,7 +277,7 @@ this.state = State.STARTED; this.threadGroup = getRootThreadGroup(); this.creator = null; - this.isolatedStaticsTable = null; + this.isolatedStaticsTable = isolatedStatics; // Initialize currentHolder IsolatedStaticData.current = this; @@ -301,6 +304,14 @@ this.isolatedStaticsTable = new VmIsolatedStatics(VmMagic.currentProcessor().getIsolatedStatics(), arch, new Unsafe.UnsafeObjectResolver()); this.creator = currentIsolate(); + if(getRoot().executor == null && isRoot()) { + //initialize the root executor on the creation of the first child + getRoot().invokeAndWait(new Runnable(){ + public void run() { + //org.jnode.vm.Unsafe.debug("Root executor ready\n"); + } + }); + } StaticData.isolates.add(this); } @@ -381,7 +392,9 @@ this.exitReason = IsolateStatus.ExitReason.OTHER_EXIT; } - stopAllThreads(); + disposeAppContext(this.exitReason == IsolateStatus.ExitReason.SELF_EXIT); + + //stopAllThreads(); } public final void isolateHalt(int status) { @@ -394,7 +407,9 @@ this.exitReason = IsolateStatus.ExitReason.OTHER_HALT; } - stopAllThreads(); + disposeAppContext(this.exitReason == IsolateStatus.ExitReason.SELF_HALT); + + //stopAllThreads(); } public final void systemExit(Isolate isolate, int status) { @@ -406,7 +421,9 @@ this.exitReason = IsolateStatus.ExitReason.SELF_EXIT; this.exitCode = status; - stopAllThreads(); + disposeAppContext(true); + + //stopAllThreads(); } public final void systemHalt(Isolate isolate, int status) { @@ -418,11 +435,14 @@ this.exitReason = IsolateStatus.ExitReason.SELF_HALT; this.exitCode = status; - stopAllThreads(); + disposeAppContext(true); + + //stopAllThreads(); } private void stopAllThreads() { - // FIXME - this is probably unsafe because any of the threads being killed could + // TODO - investigate it + // TODO - this is probably unsafe because any of the threads being killed could // be in the middle of updating a critical system data structure. I'm also // unsure of the order in which we are killing the threads here. It might be // better to kill the isolate's main thread first to give it the chance to @@ -431,8 +451,6 @@ if (ac > 0) { Thread[] ta = new Thread[ac]; int rc = threadGroup.enumerate(ta); - // FIXME - notwithstanding the above comments, is the 'current' thread the - // same one as the isolate's main thread? (Stephen Crawley - 2008-11-08) Thread current = Thread.currentThread(); boolean found = false; for (int i = 0; i < rc; i++) { @@ -459,11 +477,11 @@ * * @param status */ - public final void implicitExit(int status) { + public final void implicitExit(VmThread vmThread, int status) { //on this isolate may call this method testIsolate(currentIsolate().isolate); - // FIXME - handle demon threads + // TODO - handle demon threads if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) return; @@ -473,7 +491,14 @@ this.exitCode = status; } - doExit(); + if(vmThread.getName().indexOf("-AWT-stopper") > - 1) { + doExit(); + } else { + disposeAppContext(true); + } + + //doExit(); + ///stopAllThreads(); } /** @@ -483,7 +508,7 @@ //on this isolate may call this method testIsolate(currentIsolate().isolate); - // FIXME - handle demon threads + // TODO - handle demon threads if (threadGroup.activeCount() > 0 || threadGroup.activeGroupCount() > 0) return; @@ -492,13 +517,18 @@ exitReason = IsolateStatus.ExitReason.UNCAUGHT_EXCEPTION; this.exitCode = -1; - doExit(); + disposeAppContext(true); + + //doExit(); + + //stopAllThreads(); } /** * Force termination of this isolate. * * @param status + * @deprecated */ @SuppressWarnings("deprecation") public final void halt(int status) { @@ -522,7 +552,8 @@ private void doExit() { try { - threadGroup.destroy(); + if(!threadGroup.isDestroyed()) + threadGroup.destroy(); } catch (Throwable t) { t.printStackTrace(); } @@ -639,8 +670,7 @@ } // Create a new ThreadGroup - this.threadGroup = new ThreadGroup(StaticData.getRoot().threadGroup, - mainClass); + this.threadGroup = new ThreadGroup(StaticData.getRoot().threadGroup, mainClass); // Find plugin manager PluginManager piManager; @@ -677,7 +707,7 @@ private Thread executorThread; */ - public void invokeAndWait(final Runnable task) { +// public void invokeAndWait(final Runnable task) { //TODO implement VmIsolate.invokeAndWait(Runnable) /* if(this == StaticData.rootIsolate){ @@ -700,7 +730,7 @@ } } */ - } +// } /* private class TaskExecutor implements Runnable{ public void run() { @@ -735,7 +765,161 @@ } */ + + private java.util.concurrent.ExecutorService executor; + /** + * Execute a task within this isolate and wait for completion. + * + * @param task the task as a Runnable object + */ + public synchronized void invokeAndWait(final Runnable task) { + if(executor == null) { + executor = java.util.concurrent.Executors.newSingleThreadExecutor(new IsolateThreadFactory2(this)); + } + if(task == null) + return; + + try { + if(executor.submit(task).get() != null) { + throw new RuntimeException("Execution failed!"); + } + } catch (Exception x) { + throw new RuntimeException(x); + } + } + + /** + * Execute a task asynchronously within this isolate. + * + * @param task the task as a Runnable object + */ + public synchronized void invokeLater(final Runnable task) { + org.jnode.vm.Unsafe.debug("invokeLater Called - 0\n"); + if(executor == null) { + executor = java.util.concurrent.Executors.newSingleThreadExecutor(new IsolateThreadFactory(this)); + org.jnode.vm.Unsafe.debug("invokeAndWait executor created - 0\n"); + } + if(task == null) + return; + + try { + org.jnode.vm.Unsafe.debug("invokeAndWait submitting task - 0\n"); + executor.submit(task); + } catch (Exception x) { + throw new RuntimeException(x); + } + } + + boolean isEDT(){ + if(appContext == null) + return false; + + + try { + Object eq = appContext.getClass().getMethod("get", Object.class). + invoke(appContext, appContext.getClass().getField("EVENT_QUEUE_KEY").get(null)); + if(eq == null) + return false; + + org.jnode.vm.Unsafe.debug("isEDT - 1\n"); + + Object t = eq.getClass().getField("dispatchThread").get(eq); + if(t == null) + return false; + + org.jnode.vm.Unsafe.debug("isEDT edt=" + t + "\n"); + org.jnode.vm.Unsafe.debug("isEDT currenThread=" + Thread.currentThread() + "\n"); + + return t == Thread.currentThread(); + }catch (Exception x) { + throw new RuntimeException(x); + } + /* + try { + return (Boolean) Class.forName("java.awt.EventQueue"). + getMethod("isDispatchThread").invoke(null); + } catch (Exception x) { + throw new RuntimeException(x); + + } + */ + // return false; + } + + private Object appContext; + + private void disposeAppContext(boolean intraIsolate) { + if(appSupport != null) { + appSupport.stop(intraIsolate); + } else { + stopAllThreads(); + } + } + + /** + * + * @param intraIsolate + * @deprecated + */ + private void disposeAppContext_old(boolean intraIsolate) { + final Object appContext; + final boolean is_edt; + synchronized (this) { + is_edt = isEDT(); + appContext = this.appContext; + this.appContext = null; + } + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 000\n"); + org.jnode.vm.Unsafe.debugStackTrace(); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 000 " + intraIsolate + "\n"); + if(appContext != null) { + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0001\n"); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0002\n"); + if(intraIsolate && is_edt) { + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0003\n"); + Thread t = new Thread(new Runnable() { + public void run() { + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 00\n"); + getRoot().invokeAndWait(new Runnable() { + public void run() { + try { + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 01\n"); + appContext.getClass().getMethod("dispose").invoke(appContext); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 02\n"); + } catch (Exception x) { + x.printStackTrace(); + } + } + }); + stopAllThreads(); + doExit(); + } + }, "isolate-" + getId() + "-AWT-stopper"); + t.start(); + } else { + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0004\n"); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0\n"); + getRoot().invokeAndWait(new Runnable(){ + public void run() { + try { + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 1\n"); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext: " + appContext + "\n"); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext.getClass(): " + appContext.getClass() + "\n"); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext.getClass().dispose: " + appContext.getClass().getMethod("dispose") + "\n"); + appContext.getClass().getMethod("dispose").invoke(appContext); + org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 2\n"); + }catch (Exception x) { + x.printStackTrace(); + } + } + }); + stopAllThreads(); + } + } + } + + /** * Run this isolate. This method is called from IsolateThread. */ @PrivilegedActionPragma @@ -781,7 +965,9 @@ //create the appcontext for this isolate // TODO - improve this - Class.forName("sun.awt.SunToolkit").getMethod("createNewAppContext").invoke(null); + //appContext = Class.forName("sun.awt.SunToolkit").getMethod("createNewAppContext").invoke(null); + this.appSupport = new AppSupport(this); + this.appSupport.start(); // Update the state of this isolate. changeState(State.STARTED); @@ -812,6 +998,8 @@ } catch (Throwable ex2) { Unsafe.debug("Exception in catch block.. giving up: "); Unsafe.debug(ex2.getMessage()); + } finally { + systemHalt(isolate, -1); } } } @@ -958,15 +1146,158 @@ } } - private synchronized void addChild(VmIsolate child) { - this.children.add(child); + private void addChild(VmIsolate child) { + synchronized (children) { + children.add(child); + } } - private synchronized void removeChild(VmIsolate child) { - this.children.remove(child); + private void removeChild(VmIsolate child) { + synchronized (children) { + children.remove(child); + } } - public synchronized VmIsolate[] getChildren() { - return this.children.toArray(new VmIsolate[children.size()]); + public VmIsolate[] getChildren() { + synchronized (children) { + return children.toArray(new VmIsolate[children.size()]); + } } + + public ThreadGroup getThreadGroup() { + if(threadGroup == null) { + throw new IllegalStateException("Isolate not available"); + } + return threadGroup; + } + + private AppSupport appSupport; + + @SharedStatics + private static class AppSupport { + private static boolean awtSupport; + static { + try { + Class.forName("java.awt.Toolkit"); + awtSupport = true; + } catch (ClassNotFoundException x) { + awtSupport = false; + } + } + + private final VmIsolate vmIsolate; + private Object appContext; + + AppSupport(VmIsolate vmIsolate) { + this.vmIsolate = vmIsolate; + } + + boolean isAWTReady() { + if(!awtSupport) + return false; + + try { + return Class.forName("java.awt.Toolkit").getField("toolkit").get(null) != null; + } catch (Exception x) { + return false; + } + } + + void start() throws Exception { + if(isAWTReady()) { + synchronized (this) { + appContext = Class.forName("sun.awt.SunToolkit").getMethod("createNewAppContext").invoke(null); + } + } + } + + void stop(boolean intraIsolate) { + boolean done = false; + if(awtSupport) { + synchronized (this) { + if(appContext != null) { + disposeAppContext(intraIsolate); + done = true; + } + } + } + + if(!done) { + vmIsolate.stopAllThreads(); + vmIsolate.doExit(); + } + } + + boolean isEDT(){ + if(appContext == null) + return false; + + + try { + Object eq = appContext.getClass().getMethod("get", Object.class). + invoke(appContext, appContext.getClass().getField("EVENT_QUEUE_KEY").get(null)); + if(eq == null) + return false; + + Object t = eq.getClass().getField("dispatchThread").get(eq); + if(t == null) + return false; + + return t == Thread.currentThread(); + }catch (Exception x) { + throw new RuntimeException(x); + } + /* + try { + return (Boolean) Class.forName("java.awt.EventQueue"). + getMethod("isDispatchThread").invoke(null); + } catch (Exception x) { + throw new RuntimeException(x); + + } + */ + // return false; + } + + private void disposeAppContext(boolean intraIsolate) { + final Object appContext; + final boolean is_edt; + synchronized (this) { + is_edt = isEDT(); + appContext = this.appContext; + this.appContext = null; + } + if(appContext != null) { + if(intraIsolate && is_edt) { + Thread t = new Thread(new Runnable() { + public void run() { + getRoot().invokeAndWait(new Runnable() { + public void run() { + try { + appContext.getClass().getMethod("dispose").invoke(appContext); + } catch (Exception x) { + x.printStackTrace(); + } + } + }); + vmIsolate.stopAllThreads(); + vmIsolate.doExit(); + } + }, "isolate-" + vmIsolate.getId() + "-AWT-stopper"); + t.start(); + } else { + getRoot().invokeAndWait(new Runnable(){ + public void run() { + try { + appContext.getClass().getMethod("dispose").invoke(appContext); + }catch (Exception x) { + x.printStackTrace(); + } + } + }); + vmIsolate.stopAllThreads(); + } + } + } + } } Modified: trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -67,6 +67,11 @@ private final VmThreadQueue.ScheduleQueue notifyQueue; /** + * The previous monitor in a thread bound monitor chain + */ + private Monitor previous; + + /** * Create a new instance */ public Monitor() { @@ -86,6 +91,7 @@ Monitor(VmThread owner, int lockCount) { this.monitorLock = 0; this.owner = owner; + addToOwner(); this.lockCount = lockCount; if (lockCount < 1) { throw new IllegalArgumentException("LockCount must be >= 1"); @@ -101,7 +107,9 @@ * @param lockcount */ final void initialize(VmThread owner, int lockcount) { + dropFromOwner(); this.owner = owner; + addToOwner(); this.lockCount = lockcount; } @@ -139,7 +147,9 @@ // Try to claim this monitor if (lcAddr.attempt(0, 1)) { loop = false; + dropFromOwner(); this.owner = current; + addToOwner(); } else { // Claim the lock for this monitor lock(); @@ -178,6 +188,7 @@ lock(); try { wakeupWaitingThreads(enterQueue, true); + dropFromOwner(); owner = null; lockCount = 0; } finally { @@ -191,6 +202,37 @@ } /** + * Giveup this monitor. + * Called from VmThread on thread stop. + * + * @throws org.vmmagic.pragma.UninterruptiblePragma + * + */ + public final void release(VmThread thread) { + if (owner != thread) { + Unsafe.debug("Current thread is not the owner of this monitor\n"); + return; + } + + if (lockCount <= 0) { + Unsafe.debug("Monitor is not locked\n"); + return; + } + + // Monitor is locked by current thread, decrement lockcount + lockCount = 0; + lock(); + try { + wakeupWaitingThreads(enterQueue, true); + dropFromOwner(); + owner = null; + lockCount = 0; + } finally { + unlock(); + } + } + + /** * Causes current thread to wait until another thread invokes the notify() * method or the notifyAll() method for this monitor. In other words, this * method behaves exactly as if it simply performs the call wait(0). The @@ -232,6 +274,7 @@ current.wakeupTime = VmSystem.currentKernelMillis() + timeout; VmMagic.currentProcessor().getScheduler().addToSleepQueue(current); } + dropFromOwner(); owner = null; lockCount = 0; wakeupWaitingThreads(enterQueue, true); @@ -498,4 +541,56 @@ private final void unlock() { monitorLock = 0; } + + //monitor chaining to handle thread stop + + /** + * Returns the monitor previously owned by the owner thread of this monitor. + * + * @return the previous monitor + */ + Monitor getPrevious() { + return previous; + } + + @Inline + private void addToOwner() { + Monitor lom = owner.getLastOwnedMonitor(); + if(lom == null) { + //the first monitor + owner.setLastOwnedMonitor(this); + } else { + if(lom.owner != this.owner) { + //todo error + return; + } else { + if(lom == this) { + //no need to add it + return; + } else { + //add it + this.previous = lom; + owner.setLastOwnedMonitor(this); + } + } + } + } + + @Inline + private void dropFromOwner() { + if(owner == null) { + //error + return; + } + + Monitor lom = owner.getLastOwnedMonitor(); + if(lom == null) + return; + + if(lom != this) + return; + + owner.setLastOwnedMonitor(lom.previous); + lom.previous = null; + } } Modified: trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -26,6 +26,7 @@ import org.jnode.vm.VmMagic; import org.jnode.vm.annotation.Internal; import org.jnode.vm.annotation.MagicPermission; +import org.jnode.vm.annotation.Uninterruptible; import org.jnode.vm.classmgr.ObjectFlags; import org.jnode.vm.classmgr.ObjectLayout; import org.vmmagic.unboxed.Address; @@ -36,6 +37,7 @@ * @author epr */ @MagicPermission +@Uninterruptible public final class MonitorManager { /** @@ -78,7 +80,7 @@ if (counter.EQ(Word.fromIntZeroExtend(ObjectFlags.LOCK_COUNT_MASK))) { // thin lock entry counter == max, so we need to inflate // ourselves. - installInflatedLock(object).enter(); + installInflatedLock(object, null).enter(); return; } else { // not-quite-so-fast path: locked by current thread. @@ -98,8 +100,17 @@ } else { // Another thread owns the lock // thin lock owned by another thread. - // install an inflated lock. - installInflatedLock(object).enter(); + int ownerId = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.THREAD_ID_MASK)).toInt(); + VmThread thread = VmMagic.currentProcessor().getScheduler().getThreadById(ownerId); + if(thread == null) { + //the owner of the lock was destroyed + //aquire the lock in fast fashion + statusPtr.store(statusFlags.or(tid)); + return; + } else { + // install an inflated lock. + installInflatedLock(object, thread).enter(); + } return; } @@ -217,7 +228,7 @@ */ private static Monitor getOwnedInflatedMonitor(Object object) throws IllegalMonitorStateException { - final Monitor m = installInflatedLock(object); + final Monitor m = installInflatedLock(object, null); if (!m.isOwner(VmMagic.currentProcessor().getCurrentThread())) { // lock not owned by us! String exMsg = "Object not locked by current thread"; @@ -233,7 +244,7 @@ * @param k */ static void setupInflatedLock(Object k) { - installInflatedLock(k); + installInflatedLock(k, null); } /** @@ -241,9 +252,10 @@ * until the object is unlocked or inflated. * * @param k the object for which the inflated lock is installed + * @param thread * @return the Monitor object representing the lock */ - private static Monitor installInflatedLock(Object k) { + private static Monitor installInflatedLock(Object k, VmThread thread) { Monitor m = null; Word monAddr = null; @@ -271,7 +283,10 @@ int lockcount = 1 + oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.LOCK_COUNT_MASK)). rshl(ObjectFlags.LOCK_COUNT_SHIFT).toInt(); int ownerId = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.THREAD_ID_MASK)).toInt(); - m.initialize(VmMagic.currentProcessor().getScheduler().getThreadById(ownerId), lockcount); + if(thread == null) { + thread = VmMagic.currentProcessor().getScheduler().getThreadById(ownerId); + } + m.initialize(thread, lockcount); final Word statusFlags = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.STATUS_FLAGS_MASK)); final Word newlockword = monAddr.or(statusFlags).or(Word.fromIntZeroExtend(ObjectFlags.LOCK_EXPANDED)); Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -73,6 +73,7 @@ * * @param visitor */ + @Uninterruptible final VmThread getThreadById(int id) { // final SpinLock lock = vm.allThreadsLock; VmThreadQueueEntry e = this.allThreadsQueue.first; Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -143,6 +143,11 @@ private Monitor waitForMonitor; /** + * The most recently owned monitor. + */ + private Monitor lastOwnedMonitor; + + /** * My priority */ protected int priority = Thread.NORM_PRIORITY; @@ -391,7 +396,7 @@ javaThread.onExit(); //exit the current isolate if needed if (ex instanceof ThreadDeath) { - VmIsolate.currentIsolate().implicitExit(0); + VmIsolate.currentIsolate().implicitExit(this, 0); } else { VmIsolate.currentIsolate().uncaughtExceptionExit(); } @@ -433,6 +438,18 @@ */ @Uninterruptible private final void doStop() { + //release monitors + Monitor lom = lastOwnedMonitor; + while(lom != null) { + Monitor prev = lom.getPrevious(); + lom.release(this); + if (prev == lom) + break; + lom = prev; + } + lastOwnedMonitor = null; + + final VmProcessor proc = VmMagic.currentProcessor(); final VmThread current = proc.getCurrentThread(); proc.getScheduler().unregisterThread(this); @@ -914,6 +931,7 @@ * @see ObjectFlags#THREAD_ID_SHIFT */ @KernelSpace + @Uninterruptible public final int getId() { return id; } @@ -1387,4 +1405,18 @@ + state); } } + + public VmIsolatedStatics getIsolatedStatics() { + return isolatedStatics; + } + + @Uninterruptible + final Monitor getLastOwnedMonitor() { + return lastOwnedMonitor; + } + + @Uninterruptible + final void setLastOwnedMonitor(Monitor lastOwnedMonitor) { + this.lastOwnedMonitor = lastOwnedMonitor; + } } Modified: trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java =================================================================== --- trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-11-09 10:31:21 UTC (rev 4690) +++ trunk/core/src/test/org/jnode/test/core/StatusLinkTest.java 2008-11-09 12:24:49 UTC (rev 4691) @@ -213,7 +213,7 @@ Math.sin(i); if (i % 100 == 0) { org.jnode.vm.Unsafe.debug("i=" + i + "\n"); - //System.out.println("i=" + i); + System.out.println("i=" + i); } } System.out.println("Child thread: exiting"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-12-08 14:51:53
|
Revision: 4783 http://jnode.svn.sourceforge.net/jnode/?rev=4783&view=rev Author: lsantha Date: 2008-12-08 14:51:34 +0000 (Mon, 08 Dec 2008) Log Message: ----------- Integrated java.lang.reflect.Array from OpenJDK. Added Paths: ----------- trunk/core/src/classpath/java/java/lang/reflect/CPArray.java trunk/core/src/openjdk/java/java/lang/reflect/Array.java trunk/core/src/openjdk/vm/java/lang/reflect/NativeArray.java Added: trunk/core/src/classpath/java/java/lang/reflect/CPArray.java =================================================================== --- trunk/core/src/classpath/java/java/lang/reflect/CPArray.java (rev 0) +++ trunk/core/src/classpath/java/java/lang/reflect/CPArray.java 2008-12-08 14:51:34 UTC (rev 4783) @@ -0,0 +1,656 @@ +/* java.lang.reflect.Array - manipulate arrays by reflection + Copyright (C) 1998, 1999, 2001, 2003, 2005 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 java.lang.reflect; + +/** + * Array holds static helper functions that allow you to create and + * manipulate arrays by reflection. Operations know how to perform widening + * conversions, but throw {@link IllegalArgumentException} if you attempt + * a narrowing conversion. Also, when accessing primitive arrays, this + * class performs object wrapping and unwrapping as necessary.<p> + * + * <B>Note:</B> This class returns and accepts types as Classes, even + * primitive types; there are Class types defined that represent each + * different primitive type. They are <code>java.lang.Boolean.TYPE, + * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class, + * byte.class</code>, etc. These are not to be confused with the + * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are + * real classes. Note also that the shorthand <code>Object[].class</code> + * is a convenient way to get array Classes.<p> + * + * <B>Performance note:</B> This class performs best when it does not have + * to convert primitive types. The further along the chain it has to convert, + * the worse performance will be. You're best off using the array as whatever + * type it already is, and then converting the result. You will do even + * worse if you do this and use the generic set() function. + * + * @author John Keiser + * @author Eric Blake (eb...@em...) + * @author Per Bothner (bo...@cy...) + * @see java.lang.Boolean#TYPE + * @see java.lang.Byte#TYPE + * @see java.lang.Short#TYPE + * @see java.lang.Character#TYPE + * @see java.lang.Integer#TYPE + * @see java.lang.Long#TYPE + * @see java.lang.Float#TYPE + * @see java.lang.Double#TYPE + * @since 1.1 + * @status updated to 1.4 + */ +public final class CPArray +{ + + /** + * This class is uninstantiable. + */ + private CPArray() + { + } + + /** + * Creates a new single-dimensioned array. + * @param componentType the type of the array to create + * @param length the length of the array to create + * @return the created array, cast to an Object + * @throws NullPointerException if <code>componentType</code> is null + * @throws IllegalArgumentException if <code>componentType</code> is + * <code>Void.TYPE</code> + * @throws NegativeArraySizeException when length is less than 0 + * @throws OutOfMemoryError if memory allocation fails + */ + public static Object newInstance(Class<?> componentType, int length) + { + if (! componentType.isPrimitive()) + return VMArray.createObjectArray(componentType, length); + if (componentType == boolean.class) + return new boolean[length]; + if (componentType == byte.class) + return new byte[length]; + if (componentType == char.class) + return new char[length]; + if (componentType == short.class) + return new short[length]; + if (componentType == int.class) + return new int[length]; + if (componentType == long.class) + return new long[length]; + if (componentType == float.class) + return new float[length]; + if (componentType == double.class) + return new double[length]; + // assert componentType == void.class + throw new IllegalArgumentException(); + } + + /** + * Creates a new multi-dimensioned array. The new array has the same + * component type as the argument class, and the number of dimensions + * in the new array is the sum of the dimensions of the argument class + * and the length of the argument dimensions. Virtual Machine limitations + * forbid too many dimensions (usually 255 is the maximum); but even + * 50 dimensions of 2 elements in each dimension would exceed your memory + * long beforehand! + * + * @param componentType the type of the array to create. + * @param dimensions the dimensions of the array to create. Each element + * in <code>dimensions</code> makes another dimension of the new + * array. Thus, <code>Array.newInstance(java.lang.Boolean, + * new int[]{1,2,3})</code> is the same as + * <code>new java.lang.Boolean[1][2][3]</code> + * @return the created array, cast to an Object + * @throws NullPointerException if componentType or dimension is null + * @throws IllegalArgumentException if the the size of + * <code>dimensions</code> is 0 or exceeds the maximum number of + * array dimensions in the VM; or if componentType is Void.TYPE + * @throws NegativeArraySizeException when any of the dimensions is less + * than 0 + * @throws OutOfMemoryError if memory allocation fails + */ + public static Object newInstance(Class<?> componentType, int[] dimensions) + { + if (dimensions.length <= 0) + throw new IllegalArgumentException ("Empty dimensions array."); + return createMultiArray(componentType, dimensions, + dimensions.length - 1); + } + + /** + * Gets the array length. + * @param array the array + * @return the length of the array + * @throws IllegalArgumentException if <code>array</code> is not an array + * @throws NullPointerException if <code>array</code> is null + */ + public static int getLength(Object array) + { + if (array instanceof Object[]) + return ((Object[]) array).length; + if (array instanceof boolean[]) + return ((boolean[]) array).length; + if (array instanceof byte[]) + return ((byte[]) array). length; + if (array instanceof char[]) + return ((char[]) array).length; + if (array instanceof short[]) + return ((short[]) array).length; + if (array instanceof int[]) + return ((int[]) array).length; + if (array instanceof long[]) + return ((long[]) array).length; + if (array instanceof float[]) + return ((float[]) array).length; + if (array instanceof double[]) + return ((double[]) array).length; + if (array == null) + throw new NullPointerException(); + throw new IllegalArgumentException(); + } + + /** + * Gets an element of an array. Primitive elements will be wrapped in + * the corresponding class type. + * + * @param array the array to access + * @param index the array index to access + * @return the element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not an array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #getBoolean(Object, int) + * @see #getByte(Object, int) + * @see #getChar(Object, int) + * @see #getShort(Object, int) + * @see #getInt(Object, int) + * @see #getLong(Object, int) + * @see #getFloat(Object, int) + * @see #getDouble(Object, int) + */ + public static Object get(Object array, int index) + { + if (array instanceof Object[]) + return ((Object[]) array)[index]; + if (array instanceof boolean[]) + return ((boolean[]) array)[index] ? Boolean.TRUE : Boolean.FALSE; + if (array instanceof byte[]) + return new Byte(((byte[]) array)[index]); + if (array instanceof char[]) + return new Character(((char[]) array)[index]); + if (array instanceof short[]) + return new Short(((short[]) array)[index]); + if (array instanceof int[]) + return new Integer(((int[]) array)[index]); + if (array instanceof long[]) + return new Long(((long[]) array)[index]); + if (array instanceof float[]) + return new Float(((float[]) array)[index]); + if (array instanceof double[]) + return new Double(((double[]) array)[index]); + if (array == null) + throw new NullPointerException(); + throw new IllegalArgumentException(); + } + + /** + * Gets an element of a boolean array. + * + * @param array the array to access + * @param index the array index to access + * @return the boolean element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a boolean + * array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static boolean getBoolean(Object array, int index) + { + if (array instanceof boolean[]) + return ((boolean[]) array)[index]; + if (array == null) + throw new NullPointerException(); + throw new IllegalArgumentException(); + } + + /** + * Gets an element of a byte array. + * + * @param array the array to access + * @param index the array index to access + * @return the byte element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a byte + * array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static byte getByte(Object array, int index) + { + if (array instanceof byte[]) + return ((byte[]) array)[index]; + if (array == null) + throw new NullPointerException(); + throw new IllegalArgumentException(); + } + + /** + * Gets an element of a char array. + * + * @param array the array to access + * @param index the array index to access + * @return the char element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a char + * array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static char getChar(Object array, int index) + { + if (array instanceof char[]) + return ((char[]) array)[index]; + if (array == null) + throw new NullPointerException(); + throw new IllegalArgumentException(); + } + + /** + * Gets an element of a short array. + * + * @param array the array to access + * @param index the array index to access + * @return the short element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a byte + * or char array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static short getShort(Object array, int index) + { + if (array instanceof short[]) + return ((short[]) array)[index]; + return getByte(array, index); + } + + /** + * Gets an element of an int array. + * + * @param array the array to access + * @param index the array index to access + * @return the int element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a byte, + * char, short, or int array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static int getInt(Object array, int index) + { + if (array instanceof int[]) + return ((int[]) array)[index]; + if (array instanceof char[]) + return ((char[]) array)[index]; + return getShort(array, index); + } + + /** + * Gets an element of a long array. + * + * @param array the array to access + * @param index the array index to access + * @return the long element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a byte, + * char, short, int, or long array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static long getLong(Object array, int index) + { + if (array instanceof long[]) + return ((long[]) array)[index]; + return getInt(array, index); + } + + /** + * Gets an element of a float array. + * + * @param array the array to access + * @param index the array index to access + * @return the float element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a byte, + * char, short, int, long, or float array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static float getFloat(Object array, int index) + { + if (array instanceof float[]) + return ((float[]) array)[index]; + return getLong(array, index); + } + + /** + * Gets an element of a double array. + * + * @param array the array to access + * @param index the array index to access + * @return the double element at <code>array[index]</code> + * @throws IllegalArgumentException if <code>array</code> is not a byte, + * char, short, int, long, float, or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #get(Object, int) + */ + public static double getDouble(Object array, int index) + { + if (array instanceof double[]) + return ((double[]) array)[index]; + return getFloat(array, index); + } + + /** + * Sets an element of an array. If the array is primitive, then the new + * value is unwrapped and widened. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not an array, + * or the array is primitive and unwrapping value fails, or the + * value is not assignable to the array component type + * @throws NullPointerException if array is null, or if array is primitive + * and value is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #setBoolean(Object, int, boolean) + * @see #setByte(Object, int, byte) + * @see #setChar(Object, int, char) + * @see #setShort(Object, int, short) + * @see #setInt(Object, int, int) + * @see #setLong(Object, int, long) + * @see #setFloat(Object, int, float) + * @see #setDouble(Object, int, double) + */ + public static void set(Object array, int index, Object value) + { + if (array instanceof Object[]) + { + // Too bad the API won't let us throw the easier ArrayStoreException! + if (value != null + && ! array.getClass().getComponentType().isInstance(value)) + throw new IllegalArgumentException(); + ((Object[]) array)[index] = value; + } + else if (value instanceof Byte) + setByte(array, index, ((Byte) value).byteValue()); + else if (value instanceof Short) + setShort(array, index, ((Short) value).shortValue()); + else if (value instanceof Integer) + setInt(array, index, ((Integer) value).intValue()); + else if (value instanceof Long) + setLong(array, index, ((Long) value).longValue()); + else if (value instanceof Float) + setFloat(array, index, ((Float) value).floatValue()); + else if (value instanceof Double) + setDouble(array, index, ((Double) value).doubleValue()); + else if (value instanceof Character) + setChar(array, index, ((Character) value).charValue()); + else if (value instanceof Boolean) + setBoolean(array, index, ((Boolean) value).booleanValue()); + else if (array == null) + throw new NullPointerException(); + else + throw new IllegalArgumentException(); + } + + /** + * Sets an element of a boolean array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a boolean + * array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setBoolean(Object array, int index, boolean value) + { + if (array instanceof boolean[]) + ((boolean[]) array)[index] = value; + else if (array == null) + throw new NullPointerException(); + else + throw new IllegalArgumentException(); + } + + /** + * Sets an element of a byte array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a byte, + * short, int, long, float, or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setByte(Object array, int index, byte value) + { + if (array instanceof byte[]) + ((byte[]) array)[index] = value; + else + setShort(array, index, value); + } + + /** + * Sets an element of a char array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a char, + * int, long, float, or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setChar(Object array, int index, char value) + { + if (array instanceof char[]) + ((char[]) array)[index] = value; + else + setInt(array, index, value); + } + + /** + * Sets an element of a short array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a short, + * int, long, float, or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setShort(Object array, int index, short value) + { + if (array instanceof short[]) + ((short[]) array)[index] = value; + else + setInt(array, index, value); + } + + /** + * Sets an element of an int array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not an int, + * long, float, or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setInt(Object array, int index, int value) + { + if (array instanceof int[]) + ((int[]) array)[index] = value; + else + setLong(array, index, value); + } + + /** + * Sets an element of a long array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a long, + * float, or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setLong(Object array, int index, long value) + { + if (array instanceof long[]) + ((long[]) array)[index] = value; + else + setFloat(array, index, value); + } + + /** + * Sets an element of a float array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a float + * or double array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setFloat(Object array, int index, float value) + { + if (array instanceof float[]) + ((float[]) array)[index] = value; + else + setDouble(array, index, value); + } + + /** + * Sets an element of a double array. + * + * @param array the array to set a value of + * @param index the array index to set the value to + * @param value the value to set + * @throws IllegalArgumentException if <code>array</code> is not a double + * array + * @throws NullPointerException if <code>array</code> is null + * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of + * bounds + * @see #set(Object, int, Object) + */ + public static void setDouble(Object array, int index, double value) + { + if (array instanceof double[]) + ((double[]) array)[index] = value; + else if (array == null) + throw new NullPointerException(); + else + throw new IllegalArgumentException(); + } + + /** + * Dynamically and recursively create a multi-dimensioned array of objects. + * + * @param type guaranteed to be a valid object type + * @param dimensions the dimensions of the array + * @param index index of the current dimension to build + * @return the new multi-dimensioned array + * @throws NegativeArraySizeException if any entry of dimensions is negative + * @throws OutOfMemoryError if memory allocation fails + */ + // This would be faster if implemented natively, using the multianewarray + // bytecode instead of this recursive call + private static Object createMultiArray(Class type, int[] dimensions, + int index) + { + if (index == 0) + return newInstance(type, dimensions[0]); + + Object toAdd = createMultiArray(type, dimensions, index - 1); + Class thisType = toAdd.getClass(); + Object[] retval + = (Object[]) VMArray.createObjectArray(thisType, dimensions[index]); + if (dimensions[index] > 0) + retval[0] = toAdd; + int i = dimensions[index]; + while (--i > 0) + retval[i] = createMultiArray(type, dimensions, index - 1); + return retval; + } + +} Added: trunk/core/src/openjdk/java/java/lang/reflect/Array.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/reflect/Array.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/reflect/Array.java 2008-12-08 14:51:34 UTC (rev 4783) @@ -0,0 +1,485 @@ +/* + * Copyright 1996-2006 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.reflect; + +/** + * The {@code Array} class provides static methods to dynamically create and + * access Java arrays. + * + * <p>{@code Array} permits widening conversions to occur during a get or set + * operation, but throws an {@code IllegalArgumentException} if a narrowing + * conversion would occur. + * + * @author Nakul Saraiya + */ +public final +class Array { + + /** + * Constructor. Class Array is not instantiable. + */ + private Array() {} + + /** + * Creates a new array with the specified component type and + * length. + * Invoking this method is equivalent to creating an array + * as follows: + * <blockquote> + * <pre> + * int[] x = {length}; + * Array.newInstance(componentType, x); + * </pre> + * </blockquote> + * + * @param componentType the {@code Class} object representing the + * component type of the new array + * @param length the length of the new array + * @return the new array + * @exception NullPointerException if the specified + * {@code componentType} parameter is null + * @exception IllegalArgumentException if componentType is {@link Void#TYPE} + * @exception NegativeArraySizeException if the specified {@code length} + * is negative + */ + public static Object newInstance(Class<?> componentType, int length) + throws NegativeArraySizeException { + return newArray(componentType, length); + } + + /** + * Creates a new array + * with the specified component type and dimensions. + * If {@code componentType} + * represents a non-array class or interface, the new array + * has {@code dimensions.length} dimensions and + * {@code componentType} as its component type. If + * {@code componentType} represents an array class, the + * number of dimensions of the new array is equal to the sum + * of {@code dimensions.length} and the number of + * dimensions of {@code componentType}. In this case, the + * component type of the new array is the component type of + * {@code componentType}. + * + * <p>The number of dimensions of the new array must not + * exceed the number of array dimensions supported by the + * implementation (typically 255). + * + * @param componentType the {@code Class} object representing the component + * type of the new array + * @param dimensions an array of {@code int} representing the dimensions of + * the new array + * @return the new array + * @exception NullPointerException if the specified + * {@code componentType} argument is null + * @exception IllegalArgumentException if the specified {@code dimensions} + * argument is a zero-dimensional array, or if the number of + * requested dimensions exceeds the limit on the number of array dimensions + * supported by the implementation (typically 255), or if componentType + * is {@link Void#TYPE}. + * @exception NegativeArraySizeException if any of the components in + * the specified {@code dimensions} argument is negative. + */ + public static Object newInstance(Class<?> componentType, int... dimensions) + throws IllegalArgumentException, NegativeArraySizeException { + return multiNewArray(componentType, dimensions); + } + + /** + * Returns the length of the specified array object, as an {@code int}. + * + * @param array the array + * @return the length of the array + * @exception IllegalArgumentException if the object argument is not + * an array + */ + public static native int getLength(Object array) + throws IllegalArgumentException; + + /** + * Returns the value of the indexed component in the specified + * array object. The value is automatically wrapped in an object + * if it has a primitive type. + * + * @param array the array + * @param index the index + * @return the (possibly wrapped) value of the indexed component in + * the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + */ + public static native Object get(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code boolean}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native boolean getBoolean(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code byte}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native byte getByte(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code char}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native char getChar(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code short}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native short getShort(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as an {@code int}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native int getInt(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code long}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native long getLong(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code float}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native float getFloat(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Returns the value of the indexed component in the specified + * array object, as a {@code double}. + * + * @param array the array + * @param index the index + * @return the value of the indexed component in the specified array + * @exception NullPointerException If the specified object is null + * @exception IllegalArgumentException If the specified object is not + * an array, or if the indexed element cannot be converted to the + * return type by an identity or widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to the + * length of the specified array + * @see Array#get + */ + public static native double getDouble(Object array, int index) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified new value. The new value is first + * automatically unwrapped if the array has a primitive component + * type. + * @param array the array + * @param index the index into the array + * @param value the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the array component type is primitive and + * an unwrapping conversion fails + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + */ + public static native void set(Object array, int index, Object value) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code boolean} value. + * @param array the array + * @param index the index into the array + * @param z the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setBoolean(Object array, int index, boolean z) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code byte} value. + * @param array the array + * @param index the index into the array + * @param b the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setByte(Object array, int index, byte b) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code char} value. + * @param array the array + * @param index the index into the array + * @param c the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setChar(Object array, int index, char c) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code short} value. + * @param array the array + * @param index the index into the array + * @param s the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setShort(Object array, int index, short s) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code int} value. + * @param array the array + * @param index the index into the array + * @param i the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setInt(Object array, int index, int i) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code long} value. + * @param array the array + * @param index the index into the array + * @param l the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setLong(Object array, int index, long l) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code float} value. + * @param array the array + * @param index the index into the array + * @param f the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setFloat(Object array, int index, float f) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /** + * Sets the value of the indexed component of the specified array + * object to the specified {@code double} value. + * @param array the array + * @param index the index into the array + * @param d the new value of the indexed component + * @exception NullPointerException If the specified object argument + * is null + * @exception IllegalArgumentException If the specified object argument + * is not an array, or if the specified value cannot be converted + * to the underlying array's component type by an identity or a + * primitive widening conversion + * @exception ArrayIndexOutOfBoundsException If the specified {@code index} + * argument is negative, or if it is greater than or equal to + * the length of the specified array + * @see Array#set + */ + public static native void setDouble(Object array, int index, double d) + throws IllegalArgumentException, ArrayIndexOutOfBoundsException; + + /* + * Private + */ + + private static native Object newArray(Class componentType, int length) + throws NegativeArraySizeException; + + private static native Object multiNewArray(Class componentType, + int[] dimensions) + throws IllegalArgumentException, NegativeArraySizeException; + + +} Added: trunk/core/src/openjdk/vm/java/lang/reflect/NativeArray.java =================================================================== --- trunk/core/src/openjdk/vm/java/lang/reflect/NativeArray.java (rev 0) +++ trunk/core/src/openjdk/vm/java/lang/reflect/NativeArray.java 2008-12-08 14:51:34 UTC (rev 4783) @@ -0,0 +1,133 @@ +package java.lang.reflect; + +/** + * @see java.lang.reflect.Array + */ +class NativeArray { //TODO OPTIMIZE IT! + /** + * @see java.lang.reflect.Array#getLength(java.lang.Object) + */ + private static int getLength(Object arg1) { + return CPArray.getLength(arg1); + } + /** + * @see java.lang.reflect.Array#get(java.lang.Object, int) + */ + private static Object get(Object arg1, int arg2) { + return CPArray.get(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getBoolean(java.lang.Object, int) + */ + private static boolean getBoolean(Object arg1, int arg2) { + return CPArray.getBoolean(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getByte(java.lang.Object, int) + */ + private static byte getByte(Object arg1, int arg2) { + return CPArray.getByte(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getChar(java.lang.Object, int) + */ + private static char getChar(Object arg1, int arg2) { + return CPArray.getChar(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getShort(java.lang.Object, int) + */ + private static short getShort(Object arg1, int arg2) { + return CPArray.getShort(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getInt(java.lang.Object, int) + */ + private static int getInt(Object arg1, int arg2) { + return CPArray.getInt(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getLong(java.lang.Object, int) + */ + private static long getLong(Object arg1, int arg2) { + return CPArray.getLong(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getFloat(java.lang.Object, int) + */ + private static float getFloat(Object arg1, int arg2) { + return CPArray.getFloat(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#getDouble(java.lang.Object, int) + */ + private static double getDouble(Object arg1, int arg2) { + return CPArray.getDouble(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#set(java.lang.Object, int, java.lang.Object) + */ + private static void set(Object arg1, int arg2, Object arg3) { + CPArray.set(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setBoolean(java.lang.Object, int, boolean) + */ + private static void setBoolean(Object arg1, int arg2, boolean arg3) { + CPArray.setBoolean(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setByte(java.lang.Object, int, byte) + */ + private static void setByte(Object arg1, int arg2, byte arg3) { + CPArray.setByte(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setChar(java.lang.Object, int, char) + */ + private static void setChar(Object arg1, int arg2, char arg3) { + CPArray.setChar(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setShort(java.lang.Object, int, short) + */ + private static void setShort(Object arg1, int arg2, short arg3) { + CPArray.setShort(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setInt(java.lang.Object, int, int) + */ + private static void setInt(Object arg1, int arg2, int arg3) { + CPArray.setInt(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setLong(java.lang.Object, int, long) + */ + private static void setLong(Object arg1, int arg2, long arg3) { + CPArray.setLong(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setFloat(java.lang.Object, int, float) + */ + private static void setFloat(Object arg1, int arg2, float arg3) { + CPArray.setFloat(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#setDouble(java.lang.Object, int, double) + */ + private static void setDouble(Object arg1, int arg2, double arg3) { + CPArray.setDouble(arg1, arg2, arg3); + } + /** + * @see java.lang.reflect.Array#newArray(java.lang.Class, int) + */ + private static Object newArray(Class arg1, int arg2) { + return CPArray.newInstance(arg1, arg2); + } + /** + * @see java.lang.reflect.Array#multiNewArray(java.lang.Class, int[]) + */ + private static Object multiNewArray(Class arg1, int[] arg2) { + return CPArray.newInstance(arg1, arg2); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-12-13 21:11:18
|
Revision: 4786 http://jnode.svn.sourceforge.net/jnode/?rev=4786&view=rev Author: lsantha Date: 2008-12-13 21:11:12 +0000 (Sat, 13 Dec 2008) Log Message: ----------- Intgerated java.lang.reflect.Field from OpenJDK. Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java trunk/core/src/core/org/jnode/vm/classmgr/VmField.java trunk/core/src/openjdk/vm/sun/misc/NativeUnsafe.java trunk/core/src/openjdk/vm/sun/misc/UnsafeHelper.java trunk/core/src/openjdk/vm/sun/reflect/NativeReflection.java Added Paths: ----------- trunk/core/src/openjdk/java/java/lang/reflect/Field.java trunk/core/src/openjdk/vm/sun/misc/NativeGC.java trunk/core/src/openjdk/vm/sun/misc/NativeNativeSignalHandler.java trunk/core/src/openjdk/vm/sun/misc/NativePerf.java trunk/core/src/openjdk/vm/sun/misc/NativeSignal.java trunk/core/src/openjdk/vm/sun/misc/NativeVMSupport.java trunk/core/src/openjdk/vm/sun/misc/NativeVersion.java trunk/core/src/openjdk/vm/sun/reflect/NativeNativeConstructorAccessorImpl.java trunk/core/src/openjdk/vm/sun/reflect/NativeNativeMethodAccessorImpl.java Removed Paths: ------------- trunk/core/src/classpath/vm/java/lang/reflect/Field.java Deleted: trunk/core/src/classpath/vm/java/lang/reflect/Field.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/reflect/Field.java 2008-12-13 04:47:08 UTC (rev 4785) +++ trunk/core/src/classpath/vm/java/lang/reflect/Field.java 2008-12-13 21:11:12 UTC (rev 4786) @@ -1,783 +0,0 @@ -/* java.lang.reflect.Field - reflection of Java fields - Copyright (C) 1998, 2001, 2005 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 java.lang.reflect; - -import gnu.java.lang.ClassHelper; -import gnu.java.lang.reflect.FieldSignatureParser; - -import org.jnode.vm.VmReflection; -import org.jnode.vm.classmgr.VmField; -import java.lang.annotation.Annotation; - -/** - * The Field class represents a member variable of a class. It also allows - * dynamic access to a member, via reflection. This works for both - * static and instance fields. Operations on Field objects know how to - * do widening conversions, but throw {@link IllegalArgumentException} if - * a narrowing conversion would be necessary. You can query for information - * on this Field regardless of location, but get and set access may be limited - * by Java language access controls. If you can't do it in the compiler, you - * can't normally do it here either.<p> - * - * <B>Note:</B> This class returns and accepts types as Classes, even - * primitive types; there are Class types defined that represent each - * different primitive type. They are <code>java.lang.Boolean.TYPE, - * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class, - * byte.class</code>, etc. These are not to be confused with the - * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are - * real classes.<p> - * - * Also note that this is not a serializable class. It is entirely feasible - * to make it serializable using the Externalizable interface, but this is - * on Sun, not me. - * - * @author John Keiser - * @author Eric Blake <eb...@em...> - * @see Member - * @see Class - * @see Class#getField(String) - * @see Class#getDeclaredField(String) - * @see Class#getFields() - * @see Class#getDeclaredFields() - * @since 1.1 - * @status updated to 1.4 - */ -public final class Field -extends AccessibleObject implements Member -{ - private final VmField vmField; - - private static final int FIELD_MODIFIERS - = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED - | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT - | Modifier.VOLATILE; - - /** - * This class is uninstantiable except natively. - */ - public Field(VmField vmField) { - this.vmField = vmField; - } - - public Field(Class declaringClass, String name, Class type, int modifiers, int slot, String signature, byte[] annotations) { - //todo implement it - throw new UnsupportedOperationException(); - } - - /** - * Gets the class that declared this field, or the class where this field - * is a non-inherited member. - * @return the class that declared this member - */ - public Class<?> getDeclaringClass() - { - return vmField.getDeclaringClass().asClass(); - } - - /** - * Gets the name of this field. - * - * @return the name of this field - */ - public String getName() { - return vmField.getName(); - } - - /** - * Return the raw modifiers for this field. - * @return the field's modifiers - */ - public int getModifiersInternal() { - return vmField.getModifiers(); - } - - /** - * Gets the modifiers this field uses. Use the <code>Modifier</code> - * class to interpret the values. A field can only have a subset of the - * following modifiers: public, private, protected, static, final, - * transient, and volatile. - * - * @return an integer representing the modifiers to this Member - * @see Modifier - */ - public int getModifiers() - { - return getModifiersInternal() & FIELD_MODIFIERS; - } - - /** - * Return true if this field is synthetic, false otherwise. - * @since 1.5 - */ - public boolean isSynthetic() - { - return (getModifiersInternal() & Modifier.SYNTHETIC) != 0; - } - - /** - * Return true if this field represents an enum constant, - * false otherwise. - * @since 1.5 - */ - public boolean isEnumConstant() - { - return (getModifiersInternal() & Modifier.ENUM) != 0; - } - - /** - * Gets the type of this field. - * - * @return the type of this field - */ - public Class getType() { - return vmField.getType().asClass(); - } - - /** - * Compare two objects to see if they are semantically equivalent. - * Two Fields are semantically equivalent if they have the same declaring - * class, name, and type. Since you can't creat a Field except through - * the VM, this is just the == relation. - * - * @param o the object to compare to - * @return <code>true</code> if they are equal; <code>false</code> if not - */ - public boolean equals(Object o) - { - if (!(o instanceof Field)) - return false; - Field that = (Field)o; - if (this.getDeclaringClass() != that.getDeclaringClass()) - return false; - if (!this.getName().equals(that.getName())) - return false; - if (this.getType() != that.getType()) - return false; - return true; - } - - /** - * Get the hash code for the Field. The Field hash code is the hash code - * of its name XOR'd with the hash code of its class name. - * - * @return the hash code for the object. - */ - public int hashCode() - { - return getDeclaringClass().getName().hashCode() ^ getName().hashCode(); - } - - /** - * Get a String representation of the Field. A Field's String - * representation is "<modifiers> <type> - * <class>.<fieldname>".<br> Example: - * <code>public transient boolean gnu.parse.Parser.parseComplete</code> - * - * @return the String representation of the Field - */ - public String toString() { - // 64 is a reasonable buffer initial size for field - StringBuilder sb = new StringBuilder(64); - sb.append(Modifier.toString(getModifiers())).append(' '); - sb.append(ClassHelper.getUserName(getType())).append(' '); - sb.append(getDeclaringClass().getName()).append('.'); - sb.append(getName()); - return sb.toString(); - } - - public String toGenericString() - { - StringBuilder sb = new StringBuilder(64); - sb.append(Modifier.toString(getModifiers())).append(' '); - sb.append(getGenericType()).append(' '); - sb.append(getDeclaringClass().getName()).append('.'); - sb.append(getName()); - return sb.toString(); - } - - /** - * Get the value of this Field. If it is primitive, it will be wrapped - * in the appropriate wrapper type (boolean = java.lang.Boolean).<p> - * - * If the field is static, <code>o</code> will be ignored. Otherwise, if - * <code>o</code> is null, you get a <code>NullPointerException</code>, - * and if it is incompatible with the declaring class of the field, you - * get an <code>IllegalArgumentException</code>.<p> - * - * Next, if this Field enforces access control, your runtime context is - * evaluated, and you may have an <code>IllegalAccessException</code> if - * you could not access this field in similar compiled code. If the field - * is static, and its class is uninitialized, you trigger class - * initialization, which may end in a - * <code>ExceptionInInitializerError</code>.<p> - * - * Finally, the field is accessed, and primitives are wrapped (but not - * necessarily in new objects). This method accesses the field of the - * declaring class, even if the instance passed in belongs to a subclass - * which declares another field to hide this one. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if <code>o</code> is not an instance of - * the class or interface declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #getBoolean(Object) - * @see #getByte(Object) - * @see #getChar(Object) - * @see #getShort(Object) - * @see #getInt(Object) - * @see #getLong(Object) - * @see #getFloat(Object) - * @see #getDouble(Object) - */ - public Object get(Object o) throws IllegalAccessException { - if (vmField.isPrimitive()) { - switch (vmField.getSignature().charAt(0)) { - case 'Z': - return Boolean.valueOf(VmReflection.getBoolean(vmField, o)); - case 'B': - return new Byte(VmReflection.getByte(vmField, o)); - case 'C': - return new Character(VmReflection.getChar(vmField, o)); - case 'S': - return new Short(VmReflection.getShort(vmField, o)); - case 'I': - return new Integer(VmReflection.getInt(vmField, o)); - case 'J': - return new Long(VmReflection.getLong(vmField, o)); - case 'F': - return new Float(VmReflection.getFloat(vmField, o)); - case 'D': - return new Double(VmReflection.getDouble(vmField, o)); - default: - throw new IllegalArgumentException("Unknown primitive type"); - } - } else { - return VmReflection.getObject(vmField, o); - } - } - - /** - * Get the value of this boolean Field. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a boolean field of - * <code>o</code>, or if <code>o</code> is not an instance of the - * declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public boolean getBoolean(Object o) throws IllegalAccessException { - return VmReflection.getBoolean(vmField, o); - } - - /** - * Get the value of this byte Field. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte field of - * <code>o</code>, or if <code>o</code> is not an instance of the - * declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public byte getByte(Object o) throws IllegalAccessException { - return VmReflection.getByte(vmField, o); - } - - /** - * Get the value of this Field as a char. If the field is static, - * <code>o</code> will be ignored. - * - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a char field of - * <code>o</code>, or if <code>o</code> is not an instance - * of the declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public char getChar(Object o) throws IllegalAccessException { - return VmReflection.getChar(vmField, o); - } - - /** - * Get the value of this Field as a short. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte or short - * field of <code>o</code>, or if <code>o</code> is not an instance - * of the declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public short getShort(Object o) throws IllegalAccessException { - return VmReflection.getShort(vmField, o); - } - - /** - * Get the value of this Field as an int. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, or - * int field of <code>o</code>, or if <code>o</code> is not an - * instance of the declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public int getInt(Object o) throws IllegalAccessException { - return VmReflection.getInt(vmField, o); - } - - /** - * Get the value of this Field as a long. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, int, - * or long field of <code>o</code>, or if <code>o</code> is not an - * instance of the declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public long getLong(Object o) throws IllegalAccessException { - return VmReflection.getLong(vmField, o); - } - - /** - * Get the value of this Field as a float. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, int, - * long, or float field of <code>o</code>, or if <code>o</code> is - * not an instance of the declaring class of this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public float getFloat(Object o) throws IllegalAccessException { - return VmReflection.getFloat(vmField, o); - } - - /** - * Get the value of this Field as a double. If the field is static, - * <code>o</code> will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, int, - * long, float, or double field of <code>o</code>, or if - * <code>o</code> is not an instance of the declaring class of this - * field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public double getDouble(Object o) throws IllegalAccessException { - return VmReflection.getDouble(vmField, o); - } - - /** - * Set the value of this Field. If it is a primitive field, the value - * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p> - * - * If the field is static, <code>o</code> will be ignored. Otherwise, if - * <code>o</code> is null, you get a <code>NullPointerException</code>, - * and if it is incompatible with the declaring class of the field, you - * get an <code>IllegalArgumentException</code>.<p> - * - * Next, if this Field enforces access control, your runtime context is - * evaluated, and you may have an <code>IllegalAccessException</code> if - * you could not access this field in similar compiled code. This also - * occurs whether or not there is access control if the field is final. - * If the field is primitive, and unwrapping your argument fails, you will - * get an <code>IllegalArgumentException</code>; likewise, this error - * happens if <code>value</code> cannot be cast to the correct object type. - * If the field is static, and its class is uninitialized, you trigger class - * initialization, which may end in a - * <code>ExceptionInInitializerError</code>.<p> - * - * Finally, the field is set with the widened value. This method accesses - * the field of the declaring class, even if the instance passed in belongs - * to a subclass which declares another field to hide this one. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if <code>value</code> cannot be - * converted by a widening conversion to the underlying type of - * the Field, or if <code>o</code> is not an instance of the class - * declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #setBoolean(Object, boolean) - * @see #setByte(Object, byte) - * @see #setChar(Object, char) - * @see #setShort(Object, short) - * @see #setInt(Object, int) - * @see #setLong(Object, long) - * @see #setFloat(Object, float) - * @see #setDouble(Object, double) - */ - public void set(Object o, Object value) throws IllegalAccessException { - if (vmField.isPrimitive()) { - switch (vmField.getSignature().charAt(0)) { - case 'Z': - VmReflection.setBoolean(vmField, o, ((Boolean) value).booleanValue()); - break; - case 'B': - VmReflection.setByte(vmField, o, ((Byte) value).byteValue()); - break; - case 'C': - VmReflection.setChar(vmField, o, ((Character) value).charValue()); - break; - case 'S': - VmReflection.setShort(vmField, o, ((Short) value).shortValue()); - break; - case 'I': - VmReflection.setInt(vmField, o, ((Integer) value).intValue()); - break; - case 'J': - VmReflection.setLong(vmField, o, ((Long) value).longValue()); - break; - case 'F': - VmReflection.setFloat(vmField, o, ((Float) value).floatValue()); - break; - case 'D': - VmReflection.setDouble(vmField, o, ((Double) value).doubleValue()); - break; - default: - throw new IllegalArgumentException("Unknown primitive type"); - } - } else { - VmReflection.setObject(vmField, o, value); - } - } - - /** - * Set this boolean Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a boolean field, or if - * <code>o</code> is not an instance of the class declaring this - * field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setBoolean(Object o, boolean value) - throws IllegalAccessException { - VmReflection.setBoolean(vmField, o, value); - } - - /** - * Set this byte Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, int, long, - * float, or double field, or if <code>o</code> is not an instance - * of the class declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setByte(Object o, byte value) throws IllegalAccessException { - VmReflection.setByte(vmField, o, value); - } - - /** - * Set this char Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a char, int, long, - * float, or double field, or if <code>o</code> is not an instance - * of the class declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setChar(Object o, char value) throws IllegalAccessException { - VmReflection.setChar(vmField, o, value); - } - - /** - * Set this short Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a short, int, long, - * float, or double field, or if <code>o</code> is not an instance - * of the class declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setShort(Object o, short value) throws IllegalAccessException { - VmReflection.setShort(vmField, o, value); - } - - /** - * Set this int Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not an int, long, float, or - * double field, or if <code>o</code> is not an instance of the - * class declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setInt(Object o, int value) throws IllegalAccessException { - VmReflection.setInt(vmField, o, value); - } - - /** - * Set this long Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a long, float, or double - * field, or if <code>o</code> is not an instance of the class - * declaring this field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setLong(Object o, long value) throws IllegalAccessException { - VmReflection.setLong(vmField, o, value); - } - - /** - * Set this float Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a float or long field, or - * if <code>o</code> is not an instance of the class declaring this - * field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setFloat(Object o, float value) throws IllegalAccessException { - VmReflection.setFloat(vmField, o, value); - } - - /** - * Set this double Field. If the field is static, <code>o</code> will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a double field, or if - * <code>o</code> is not an instance of the class declaring this - * field - * @throws NullPointerException if <code>o</code> is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public void setDouble(Object o, double value) throws IllegalAccessException { - VmReflection.setDouble(vmField, o, value); - } - - /** - * Return the generic type of the field. If the field type is not a generic - * type, the method returns the same as <code>getType()</code>. - * - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type getGenericType() - { - String signature = getSignature(); - if (signature == null) - return getType(); - FieldSignatureParser p = new FieldSignatureParser(getDeclaringClass(), - signature); - return p.getFieldType(); - } - - /** - * Return the String in the Signature attribute for this field. If there - * is no Signature attribute, return null. - */ - private String getSignature() { - return vmField.getSignature(); - } - - - - /** - * @see java.lang.reflect.AnnotatedElement#getAnnotation(java.lang.Class) - */ - public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { - return vmField.getAnnotation(annotationClass); - } - - /** - * @see java.lang.reflect.AnnotatedElement#getAnnotations() - */ - public Annotation[] getAnnotations() { - return vmField.getAnnotations(); - } - - /** - * @see java.lang.reflect.AnnotatedElement#getDeclaredAnnotations() - */ - public Annotation[] getDeclaredAnnotations() { - return vmField.getDeclaredAnnotations(); - } - - /** - * @see java.lang.reflect.AnnotatedElement#isAnnotationPresent(java.lang.Class) - */ - public boolean isAnnotationPresent(Class< ? extends Annotation> annotationClass) { - return vmField.isAnnotationPresent(annotationClass); - } - - public Field copy() { - //todo implement it - throw new UnsupportedOperationException(); - } - - //todo hide it - public VmField getVmField(){ - return vmField; - } -} Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java 2008-12-13 04:47:08 UTC (rev 4785) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java 2008-12-13 21:11:12 UTC (rev 4786) @@ -47,7 +47,7 @@ VmConstFieldRef f = cp.getConstFieldRef(index); f.doResolve(loader); VmField vmf = f.getResolvedVmField(); - return new Field(vmf); + return vmf.asField(); } @Override @@ -55,7 +55,7 @@ VmConstFieldRef f = cp.getConstFieldRef(index); try { VmField vmf = f.getResolvedVmField(); - return new Field(vmf); + return vmf.asField(); } catch (NotResolvedYetException x) { return null; } Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmField.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmField.java 2008-12-13 04:47:08 UTC (rev 4785) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmField.java 2008-12-13 21:11:12 UTC (rev 4786) @@ -122,15 +122,16 @@ } Field javaField = javaFieldHolder.get(); if (javaField == null) { - javaFieldHolder.set(javaField = new Field(this)); + //todo add annotations + javaField = new Field(getDeclaringClass().asClass(), getName(), getType().asClass(), getModifiers(), -1, + getSignature(), null); + javaFieldHolder.set(javaField); } return javaField; } /** * Resolve the type of this field - * - * @param cl */ protected final synchronized void resolve() { try { Added: trunk/core/src/openjdk/java/java/lang/reflect/Field.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/reflect/Field.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/reflect/Field.java 2008-12-13 21:11:12 UTC (rev 4786) @@ -0,0 +1,1041 @@ +/* + * Copyright 1996-2006 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.reflect; + +import sun.reflect.FieldAccessor; +import sun.reflect.Reflection; +import sun.reflect.generics.repository.FieldRepository; +import sun.reflect.generics.factory.CoreReflectionFactory; +import sun.reflect.generics.factory.GenericsFactory; +import sun.reflect.generics.scope.ClassScope; +import java.lang.annotation.Annotation; +import java.util.Map; +import sun.reflect.annotation.AnnotationParser; + + +/** + * A {@code Field} provides information about, and dynamic access to, a + * single field of a class or an interface. The reflected field may + * be a class (static) field or an instance field. + * + * <p>A {@code Field} permits widening conversions to occur during a get or + * set access operation, but throws an {@code IllegalArgumentException} if a + * narrowing conversion would occur. + * + * @see Member + * @see java.lang.Class + * @see java.lang.Class#getFields() + * @see java.lang.Class#getField(String) + * @see java.lang.Class#getDeclaredFields() + * @see java.lang.Class#getDeclaredField(String) + * + * @author Kenneth Russell + * @author Nakul Saraiya + */ +public final +class Field extends AccessibleObject implements Member { + + private Class clazz; + private int slot; + // This is guaranteed to be interned by the VM in the 1.4 + // reflection implementation + private String name; + private Class type; + private int modifiers; + // Generics and annotations support + private transient String signature; + // generic info repository; lazily initialized + private transient FieldRepository genericInfo; + private byte[] annotations; + // Cached field accessor created without override + private FieldAccessor fieldAccessor; + // Cached field accessor created with override + private FieldAccessor overrideFieldAccessor; + // For sharing of FieldAccessors. This branching structure is + // currently only two levels deep (i.e., one root Field and + // potentially many Field objects pointing to it.) + private Field root; + + // More complicated security check cache needed here than for + // Class.newInstance() and Constructor.newInstance() + private Class securityCheckCache; + private Class securityCheckTargetClassCache; + + // Generics infrastructure + + private String getGenericSignature() {return signature;} + + // Accessor for factory + private GenericsFactory getFactory() { + Class<?> c = getDeclaringClass(); + // create scope and factory + return CoreReflectionFactory.make(c, ClassScope.make(c)); + } + + // Accessor for generic info repository + private FieldRepository getGenericInfo() { + // lazily initialize repository if necessary + if (genericInfo == null) { + // create and cache generic info repository + genericInfo = FieldRepository.make(getGenericSignature(), + getFactory()); + } + return genericInfo; //return cached repository + } + + //jnode + /** + * Package-private constructor used by ReflectAccess to enable + * instantiation of these objects in Java code from the java.lang + * package via sun.reflect.LangReflectAccess. + */ + public Field(Class declaringClass, + String name, + Class type, + int modifiers, + int slot, + String signature, + byte[] annotations) + { + this.clazz = declaringClass; + this.name = name; + this.type = type; + this.modifiers = modifiers; + this.slot = slot; + this.signature = signature; + this.annotations = annotations; + } + + /** + * Package-private routine (exposed to java.lang.Class via + * ReflectAccess) which returns a copy of this Field. The copy's + * "root" field points to this Field. + */ + Field copy() { + // This routine enables sharing of FieldAccessor objects + // among Field objects which refer to the same underlying + // method in the VM. (All of this contortion is only necessary + // because of the "accessibility" bit in AccessibleObject, + // which implicitly requires that new java.lang.reflect + // objects be fabricated for each reflective call on Class + // objects.) + Field res = new Field(clazz, name, type, modifiers, slot, signature, annotations); + res.root = this; + // Might as well eagerly propagate this if already present + res.fieldAccessor = fieldAccessor; + res.overrideFieldAccessor = overrideFieldAccessor; + return res; + } + + /** + * Returns the {@code Class} object representing the class or interface + * that declares the field represented by this {@code Field} object. + */ + public Class<?> getDeclaringClass() { + return clazz; + } + + /** + * Returns the name of the field represented by this {@code Field} object. + */ + public String getName() { + return name; + } + + /** + * Returns the Java language modifiers for the field represented + * by this {@code Field} object, as an integer. The {@code Modifier} class should + * be used to decode the modifiers. + * + * @see Modifier + */ + public int getModifiers() { + return modifiers; + } + + /** + * Returns {@code true} if this field represents an element of + * an enumerated type; returns {@code false} otherwise. + * + * @return {@code true} if and only if this field represents an element of + * an enumerated type. + * @since 1.5 + */ + public boolean isEnumConstant() { + return (getModifiers() & Modifier.ENUM) != 0; + } + + /** + * Returns {@code true} if this field is a synthetic + * field; returns {@code false} otherwise. + * + * @return true if and only if this field is a synthetic + * field as defined by the Java Language Specification. + * @since 1.5 + */ + public boolean isSynthetic() { + return Modifier.isSynthetic(getModifiers()); + } + + /** + * Returns a {@code Class} object that identifies the + * declared type for the field represented by this + * {@code Field} object. + * + * @return a {@code Class} object identifying the declared + * type of the field represented by this object + */ + public Class<?> getType() { + return type; + } + + /** + * Returns a {@code Type} object that represents the declared type for + * the field represented by this {@code Field} object. + * + * <p>If the {@code Type} is a parameterized type, the + * {@code Type} object returned must accurately reflect the + * actual type parameters used in the source code. + * + * <p>If the type of the underlying field is a type variable or a + * parameterized type, it is created. Otherwise, it is resolved. + * + * @return a {@code Type} object that represents the declared type for + * the field represented by this {@code Field} object + * @throws GenericSignatureFormatError if the generic field + * signature does not conform to the format specified in the Java + * Virtual Machine Specification, 3rd edition + * @throws TypeNotPresentException if the generic type + * signature of the underlying field refers to a non-existent + * type declaration + * @throws MalformedParameterizedTypeException if the generic + * signature of the underlying field refers to a parameterized type + * that cannot be instantiated for any reason + * @since 1.5 + */ + public Type getGenericType() { + if (getGenericSignature() != null) + return getGenericInfo().getGenericType(); + else + return getType(); + } + + + /** + * Compares this {@code Field} against the specified object. Returns + * true if the objects are the same. Two {@code Field} objects are the same if + * they were declared by the same class and have the same name + * and type. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof Field) { + Field other = (Field)obj; + return (getDeclaringClass() == other.getDeclaringClass()) + && (getName() == other.getName()) + && (getType() == other.getType()); + } + return false; + } + + /** + * Returns a hashcode for this {@code Field}. This is computed as the + * exclusive-or of the hashcodes for the underlying field's + * declaring class name and its name. + */ + public int hashCode() { + return getDeclaringClass().getName().hashCode() ^ getName().hashCode(); + } + + /** + * Returns a string describing this {@code Field}. The format is + * the access modifiers for the field, if any, followed + * by the field type, followed by a space, followed by + * the fully-qualified name of the class declaring the field, + * followed by a period, followed by the name of the field. + * For example: + * <pre> + * public static final int java.lang.Thread.MIN_PRIORITY + * private int java.io.FileDescriptor.fd + * </pre> + * + * <p>The modifiers are placed in canonical order as specified by + * "The Java Language Specification". This is {@code public}, + * {@code protected} or {@code private} first, and then other + * modifiers in the following order: {@code static}, {@code final}, + * {@code transient}, {@code volatile}. + */ + public String toString() { + int mod = getModifiers(); + return (((mod == 0) ? "" : (Modifier.toString(mod) + " ")) + + getTypeName(getType()) + " " + + getTypeName(getDeclaringClass()) + "." + + getName()); + } + + /** + * Returns a string describing this {@code Field}, including + * its generic type. The format is the access modifiers for the + * field, if any, followed by the generic field type, followed by + * a space, followed by the fully-qualified name of the class + * declaring the field, followed by a period, followed by the name + * of the field. + * + * <p>The modifiers are placed in canonical order as specified by + * "The Java Language Specification". This is {@code public}, + * {@code protected} or {@code private} first, and then other + * modifiers in the following order: {@code static}, {@code final}, + * {@code transient}, {@code volatile}. + * + * @return a string describing this {@code Field}, including + * its generic type + * + * @since 1.5 + */ + public String toGenericString() { + int mod = getModifiers(); + Type fieldType = getGenericType(); + return (((mod == 0) ? "" : (Modifier.toString(mod) + " ")) + + ((fieldType instanceof Class) ? + getTypeName((Class)fieldType): fieldType.toString())+ " " + + getTypeName(getDeclaringClass()) + "." + + getName()); + } + + /** + * Returns the value of the field represented by this {@code Field}, on + * the specified object. The value is automatically wrapped in an + * object if it has a primitive type. + * + * <p>The underlying field's value is obtained as follows: + * + * <p>If the underlying field is a static field, the {@code obj} argument + * is ignored; it may be null. + * + * <p>Otherwise, the underlying field is an instance field. If the + * specified {@code obj} argument is null, the method throws a + * {@code NullPointerException}. If the specified object is not an + * instance of the class or interface declaring the underlying + * field, the method throws an {@code IllegalArgumentException}. + * + * <p>If this {@code Field} object enforces Java language access control, and + * the underlying field is inaccessible, the method throws an + * {@code IllegalAccessException}. + * If the underlying field is static, the class that declared the + * field is initialized if it has not already been initialized. + * + * <p>Otherwise, the value is retrieved from the underlying instance + * or static field. If the field has a primitive type, the value + * is wrapped in an object before being returned, otherwise it is + * returned as is. + * + * <p>If the field is hidden in the type of {@code obj}, + * the field's value is obtained according to the preceding rules. + * + * @param obj object from which the represented field's value is + * to be extracted + * @return the value of the represented field in object + * {@code obj}; primitive values are wrapped in an appropriate + * object before being returned + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not an + * instance of the class or interface declaring the underlying + * field (or a subclass or implementor thereof). + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + */ + public Object get(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).get(obj); + } + + /** + * Gets the value of a static or instance {@code boolean} field. + * + * @param obj the object to extract the {@code boolean} value + * from + * @return the value of the {@code boolean} field + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code boolean} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public boolean getBoolean(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getBoolean(obj); + } + + /** + * Gets the value of a static or instance {@code byte} field. + * + * @param obj the object to extract the {@code byte} value + * from + * @return the value of the {@code byte} field + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code byte} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public byte getByte(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getByte(obj); + } + + /** + * Gets the value of a static or instance field of type + * {@code char} or of another primitive type convertible to + * type {@code char} via a widening conversion. + * + * @param obj the object to extract the {@code char} value + * from + * @return the value of the field converted to type {@code char} + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code char} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public char getChar(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getChar(obj); + } + + /** + * Gets the value of a static or instance field of type + * {@code short} or of another primitive type convertible to + * type {@code short} via a widening conversion. + * + * @param obj the object to extract the {@code short} value + * from + * @return the value of the field converted to type {@code short} + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code short} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public short getShort(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getShort(obj); + } + + /** + * Gets the value of a static or instance field of type + * {@code int} or of another primitive type convertible to + * type {@code int} via a widening conversion. + * + * @param obj the object to extract the {@code int} value + * from + * @return the value of the field converted to type {@code int} + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code int} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public int getInt(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getInt(obj); + } + + /** + * Gets the value of a static or instance field of type + * {@code long} or of another primitive type convertible to + * type {@code long} via a widening conversion. + * + * @param obj the object to extract the {@code long} value + * from + * @return the value of the field converted to type {@code long} + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code long} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public long getLong(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getLong(obj); + } + + /** + * Gets the value of a static or instance field of type + * {@code float} or of another primitive type convertible to + * type {@code float} via a widening conversion. + * + * @param obj the object to extract the {@code float} value + * from + * @return the value of the field converted to type {@code float} + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code float} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public float getFloat(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getFloat(obj); + } + + /** + * Gets the value of a static or instance field of type + * {@code double} or of another primitive type convertible to + * type {@code double} via a widening conversion. + * + * @param obj the object to extract the {@code double} value + * from + * @return the value of the field converted to type {@code double} + * + * @exception IllegalAccessException if the underlying field + * is inaccessible. + * @exception IllegalArgumentException if the specified object is not + * an instance of the class or interface declaring the + * underlying field (or a subclass or implementor + * thereof), or if the field value cannot be + * converted to the type {@code double} by a + * widening conversion. + * @exception NullPointerException if the specified object is null + * and the field is an instance field. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + * @see Field#get + */ + public double getDouble(Object obj) + throws IllegalArgumentException, IllegalAccessException + { + return getFieldAccessor(obj).getDouble(obj); + } + + /** + * Sets the field represented by this {@code Field} object on the + * specified object argument to the specified new value. The new + * value is automatically unwrapped if the underlying field has a + * primitive type. + * + * <p>The operation proceeds as follows: + * + * <p>If the underlying field is static, the {@code obj} argument is + * ignored; it may be null. + * + * <p>Otherwise the underlying field is an instance field. If the + * specified object argument is null, the method throws a + * {@code NullPointerException}. If the spec... [truncated message content] |
From: <ls...@us...> - 2008-12-14 22:22:13
|
Revision: 4788 http://jnode.svn.sourceforge.net/jnode/?rev=4788&view=rev Author: lsantha Date: 2008-12-14 21:49:21 +0000 (Sun, 14 Dec 2008) Log Message: ----------- Intgerated java.lang.reflect.Constructor from OpenJDK. Modified Paths: -------------- trunk/core/src/classpath/vm/java/lang/Thread.java trunk/core/src/classpath/vm/java/lang/reflect/Method.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java trunk/core/src/openjdk/java/java/lang/ThreadGroup.java trunk/core/src/openjdk/vm/sun/reflect/NativeNativeConstructorAccessorImpl.java Added Paths: ----------- trunk/core/src/openjdk/java/java/lang/reflect/Constructor.java Removed Paths: ------------- trunk/core/src/classpath/vm/java/lang/reflect/Constructor.java Modified: trunk/core/src/classpath/vm/java/lang/Thread.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/Thread.java 2008-12-13 21:11:59 UTC (rev 4787) +++ trunk/core/src/classpath/vm/java/lang/Thread.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -41,6 +41,7 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.HashMap; +import java.lang.reflect.Constructor; import org.jnode.security.JNodePermission; @@ -1365,7 +1366,13 @@ static { ThreadGroup g = null; try { - g = ThreadGroup.class.getDeclaredConstructor().newInstance(); + /* + Constructor<ThreadGroup> constr = ThreadGroup.class.getDeclaredConstructor(); + constr.setAccessible(true); + g = constr.newInstance(); + constr.setAccessible(false); + */ + g = new ThreadGroup(); }catch (Exception e){ e.printStackTrace(); org.jnode.vm.Unsafe.die("Root ThreadGroup creation failure."); Deleted: trunk/core/src/classpath/vm/java/lang/reflect/Constructor.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/reflect/Constructor.java 2008-12-13 21:11:59 UTC (rev 4787) +++ trunk/core/src/classpath/vm/java/lang/reflect/Constructor.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -1,566 +0,0 @@ -/* java.lang.reflect.Constructor - reflection of Java constructors - Copyright (C) 1998, 2001, 2004, 2005 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 java.lang.reflect; - -import gnu.java.lang.ClassHelper; -import java.lang.annotation.Annotation; -import java.lang.annotation.AnnotationFormatError; -import java.util.ArrayList; - -import org.jnode.vm.VmReflection; -import org.jnode.vm.classmgr.VmExceptions; -import org.jnode.vm.classmgr.VmMethod; -import org.jnode.vm.classmgr.Signature; -import gnu.java.lang.reflect.MethodSignatureParser; - -import java.util.Arrays; -import sun.reflect.annotation.AnnotationParser; -import sun.reflect.ConstructorAccessor; - -/** - * The Constructor class represents a constructor of a class. It also allows - * dynamic creation of an object, via reflection. Invocation on Constructor - * objects knows how to do widening conversions, but throws - * {@link IllegalArgumentException} if a narrowing conversion would be - * necessary. You can query for information on this Constructor regardless - * of location, but construction access may be limited by Java language - * access controls. If you can't do it in the compiler, you can't normally - * do it here either.<p> - * - * <B>Note:</B> This class returns and accepts types as Classes, even - * primitive types; there are Class types defined that represent each - * different primitive type. They are <code>java.lang.Boolean.TYPE, - * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class, - * byte.class</code>, etc. These are not to be confused with the - * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are - * real classes.<p> - * - * Also note that this is not a serializable class. It is entirely feasible - * to make it serializable using the Externalizable interface, but this is - * on Sun, not me. - * - * @author John Keiser - * @author Eric Blake <eb...@em...> - * @see Member - * @see Class - * @see java.lang.Class#getConstructor(Class[]) - * @see java.lang.Class#getDeclaredConstructor(Class[]) - * @see java.lang.Class#getConstructors() - * @see java.lang.Class#getDeclaredConstructors() - * @since 1.1 - * @status updated to 1.4 - */ -public final class Constructor<T> - extends AccessibleObject - implements GenericDeclaration, Member -{ - private Class<T> clazz; - private int slot; - - private final VmMethod vmMethod; - private ArrayList<Class> parameterTypes; - private ArrayList<Class> exceptionTypes; - - private static final int CONSTRUCTOR_MODIFIERS - = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC; - - /** - * This class is uninstantiable except from native code. - */ - public Constructor(VmMethod vmMethod) { - this.vmMethod = vmMethod; - } - - /** - * Gets the class that declared this constructor. - * @return the class that declared this member - */ - public Class<T> getDeclaringClass() - { - return (Class<T>) vmMethod.getDeclaringClass().asClass(); - } - - /** - * Gets the name of this constructor (the non-qualified name of the class - * it was declared in). - * @return the name of this constructor - */ - public String getName() - { - return getDeclaringClass().getName(); - } - - /** - * Return the raw modifiers for this constructor. In particular - * this will include the synthetic and varargs bits. - * @return the constructor's modifiers - */ - private int getModifiersInternal() - { - return vmMethod.getModifiers(); - } - - /** - * Gets the modifiers this constructor uses. Use the <code>Modifier</code> - * class to interpret the values. A constructor can only have a subset of the - * following modifiers: public, private, protected. - * - * @return an integer representing the modifiers to this Member - * @see Modifier - */ - public int getModifiers() - { - return getModifiersInternal() & CONSTRUCTOR_MODIFIERS; - } - - /** - * Return true if this constructor is synthetic, false otherwise. - * A synthetic member is one which is created by the compiler, - * and which does not appear in the user's source code. - * @since 1.5 - */ - public boolean isSynthetic() - { - return (getModifiersInternal() & Modifier.SYNTHETIC) != 0; - } - - /** - * Return true if this is a varargs constructor, that is if - * the constructor takes a variable number of arguments. - * @since 1.5 - */ - public boolean isVarArgs() - { - return (getModifiersInternal() & Modifier.VARARGS) != 0; - } - - /** - * Get the parameter list for this constructor, in declaration order. If the - * constructor takes no parameters, returns a 0-length array (not null). - * - * @return a list of the types of the constructor's parameters - */ - public Class<?>[] getParameterTypes() - { - if (parameterTypes == null) { - int cnt = vmMethod.getNoArguments(); - ArrayList<Class> list = new ArrayList<Class>(cnt); - for (int i = 0; i < cnt; i++) { - list.add(vmMethod.getArgumentType(i).asClass()); - } - parameterTypes = list; - } - return (Class[])parameterTypes.toArray(new Class[parameterTypes.size()]); - } - - /** - * Get the exception types this constructor says it throws, in no particular - * order. If the constructor has no throws clause, returns a 0-length array - * (not null). - * - * @return a list of the types in the constructor's throws clause - */ - public Class<?>[] getExceptionTypes() { - if (exceptionTypes == null) { - final VmExceptions exceptions = vmMethod.getExceptions(); - final int cnt = exceptions.getLength(); - final ArrayList<Class> list = new ArrayList<Class>(cnt); - for (int i = 0; i < cnt; i++) { - list.add(exceptions.getException(i).getResolvedVmClass().asClass()); - } - exceptionTypes = list; - } - return (Class[])exceptionTypes.toArray(new Class[exceptionTypes.size()]); - } - - /** - * Compare two objects to see if they are semantically equivalent. - * Two Constructors are semantically equivalent if they have the same - * declaring class and the same parameter list. This ignores different - * exception clauses, but since you can't create a Method except through the - * VM, this is just the == relation. - * - * @param o the object to compare to - * @return <code>true</code> if they are equal; <code>false</code> if not. - */ - public boolean equals(Object o) - { - if (!(o instanceof Constructor)) - return false; - Constructor that = (Constructor)o; - if (this.getDeclaringClass() != that.getDeclaringClass()) - return false; - if (!Arrays.equals(this.getParameterTypes(), that.getParameterTypes())) - return false; - return true; - } - - /** - * Get the hash code for the Constructor. The Constructor hash code is the - * hash code of the declaring class's name. - * - * @return the hash code for the object - */ - public int hashCode() - { - return getDeclaringClass().getName().hashCode(); - } - - /** - * Get a String representation of the Constructor. A Constructor's String - * representation is "<modifier> <classname>(<paramtypes>) - * throws <exceptions>", where everything after ')' is omitted if - * there are no exceptions.<br> Example: - * <code>public java.io.FileInputStream(java.lang.Runnable) - * throws java.io.FileNotFoundException</code> - * - * @return the String representation of the Constructor - */ - public String toString() { - // 128 is a reasonable buffer initial size for constructor - StringBuilder sb = new StringBuilder(128); - sb.append(Modifier.toString(getModifiers())).append(' '); - sb.append(getDeclaringClass().getName()).append('('); - Class[] c = getParameterTypes(); - if (c.length > 0) - { - sb.append(ClassHelper.getUserName(c[0])); - for (int i = 1; i < c.length; i++) - sb.append(',').append(ClassHelper.getUserName(c[i])); - } - sb.append(')'); - c = getExceptionTypes(); - if (c.length > 0) { - sb.append(" throws ").append(c[0].getName()); - for (int i = 1; i < c.length; i++) - sb.append(',').append(c[i].getName()); - } - return sb.toString(); - } - - static <X extends GenericDeclaration> - void addTypeParameters(StringBuilder sb, TypeVariable<X>[] typeArgs) - { - if (typeArgs.length == 0) - return; - sb.append('<'); - for (int i = 0; i < typeArgs.length; ++i) - { - if (i > 0) - sb.append(','); - sb.append(typeArgs[i]); - } - sb.append("> "); - } - - public String toGenericString() - { - StringBuilder sb = new StringBuilder(128); - sb.append(Modifier.toString(getModifiers())).append(' '); - addTypeParameters(sb, getTypeParameters()); - sb.append(getDeclaringClass().getName()).append('('); - Type[] types = getGenericParameterTypes(); - if (types.length > 0) - { - sb.append(types[0]); - for (int i = 1; i < types.length; ++i) - sb.append(',').append(types[i]); - } - sb.append(')'); - types = getGenericExceptionTypes(); - if (types.length > 0) - { - sb.append(" throws ").append(types[0]); - for (int i = 1; i < types.length; i++) - sb.append(',').append(types[i]); - } - return sb.toString(); - } - - /** - * Create a new instance by invoking the constructor. Arguments are - * automatically unwrapped and widened, if needed.<p> - * - * If this class is abstract, you will get an - * <code>InstantiationException</code>. If the constructor takes 0 - * arguments, you may use null or a 0-length array for <code>args</code>.<p> - * - * If this Constructor enforces access control, your runtime context is - * evaluated, and you may have an <code>IllegalAccessException</code> if - * you could not create this object in similar compiled code. If the class - * is uninitialized, you trigger class initialization, which may end in a - * <code>ExceptionInInitializerError</code>.<p> - * - * Then, the constructor is invoked. If it completes normally, the return - * value will be the new object. If it completes abruptly, the exception is - * wrapped in an <code>InvocationTargetException</code>. - * - * @param args the arguments to the constructor - * @return the newly created object - * @throws IllegalAccessException if the constructor could not normally be - * called by the Java code (i.e. it is not public) - * @throws IllegalArgumentException if the number of arguments is incorrect; - * or if the arguments types are wrong even with a widening - * conversion - * @throws InstantiationException if the class is abstract - * @throws InvocationTargetException if the constructor throws an exception - * @throws ExceptionInInitializerError if construction triggered class - * initialization, which then failed - */ - public T newInstance(Object... args) throws InstantiationException, IllegalAccessException, InvocationTargetException { - if(constructorAccessor == null) - return (T) VmReflection.newInstance(vmMethod, args); - else - return (T) constructorAccessor.newInstance(args); - } - - - /** - * Returns an array of <code>TypeVariable</code> objects that represents - * the type variables declared by this constructor, in declaration order. - * An array of size zero is returned if this constructor has no type - * variables. - * - * @return the type variables associated with this constructor. - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public TypeVariable<Constructor<T>>[] getTypeParameters() - { - String sig = getSignature(); - if (sig == null) - return new TypeVariable[0]; - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getTypeParameters(); - } - - /** - * Return the String in the Signature attribute for this constructor. If there - * is no Signature attribute, return null. - */ - String getSignature() - { - return vmMethod.getSignature(); - } - - /** - * Returns an array of <code>Type</code> objects that represents - * the exception types declared by this constructor, in declaration order. - * An array of size zero is returned if this constructor declares no - * exceptions. - * - * @return the exception types declared by this constructor. - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type[] getGenericExceptionTypes() - { - String sig = getSignature(); - if (sig == null) - return getExceptionTypes(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericExceptionTypes(); - } - - /** - * Returns an array of <code>Type</code> objects that represents - * the parameter list for this constructor, in declaration order. - * An array of size zero is returned if this constructor takes no - * parameters. - * - * @return a list of the types of the constructor's parameters - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type[] getGenericParameterTypes() - { - String sig = getSignature(); - if (sig == null) - return getParameterTypes(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericParameterTypes(); - } - - - /** - * @see java.lang.reflect.AnnotatedElement#getAnnotation(java.lang.Class) - */ - public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { - return vmMethod.getAnnotation(annotationClass); - } - - /** - * @see java.lang.reflect.AnnotatedElement#getAnnotations() - */ - public Annotation[] getAnnotations() { - return vmMethod.getAnnotations(); - } - - /** - * @see java.lang.reflect.AnnotatedElement#getDeclaredAnnotations() - */ - public Annotation[] getDeclaredAnnotations() { - return vmMethod.getDeclaredAnnotations(); - } - - - /** - * @see java.lang.reflect.AnnotatedElement#isAnnotationPresent(java.lang.Class) - */ - public boolean isAnnotationPresent(Class< ? extends Annotation> annotationClass) { - return vmMethod.isAnnotationPresent(annotationClass); - } - - //jnode openjdk - - private byte[] parameterAnnotations; - /** - * Returns an array of arrays that represent the annotations on the formal - * parameters, in declaration order, of the method represented by - * this <tt>Constructor</tt> object. (Returns an array of length zero if the - * underlying method is parameterless. If the method has one or more - * parameters, a nested array of length zero is returned for each parameter - * with no annotations.) The annotation objects contained in the returned - * arrays are serializable. The caller of this method is free to modify - * the returned arrays; it will have no effect on the arrays returned to - * other callers. - * - * @return an array of arrays that represent the annotations on the formal - * parameters, in declaration order, of the method represented by this - * Constructor object - * @since 1.5 - */ - public Annotation[][] getParameterAnnotations() { - int numParameters = parameterTypes.size(); - if (parameterAnnotations == null) - return new Annotation[numParameters][0]; - - Annotation[][] result = AnnotationParser.parseParameterAnnotations( - parameterAnnotations, - sun.misc.SharedSecrets.getJavaLangAccess(). - getConstantPool(getDeclaringClass()), - getDeclaringClass()); - if (result.length != numParameters) { - Class<?> declaringClass = getDeclaringClass(); - if (declaringClass.isEnum() || - declaringClass.isAnonymousClass() || - declaringClass.isLocalClass() ) - ; // Can't do reliable parameter counting - else { - if (!declaringClass.isMemberClass() || // top-level - // Check for the enclosing instance parameter for - // non-static member classes - (declaringClass.isMemberClass() && - ((declaringClass.getModifiers() & Modifier.STATIC) == 0) && - result.length + 1 != numParameters) ) { - throw new AnnotationFormatError( - "Parameter annotations don't match number of parameters"); - } - } - } - return result; - } - - - public Constructor(Class<T> declaringClass, Class[] parameterTypes, Class[] checkedExceptions, int modifiers, int slot, String signature, byte[] annotations, byte[] parameterAnnotations) { - //todo implement it - String my_signature = Signature.toSignature(null, parameterTypes); - this.vmMethod = declaringClass.getVmClass().link().getDeclaredMethod("<init>", my_signature); - if(this.vmMethod == null) throw new RuntimeException("Constructor creation failure"); - - this.modifiers = modifiers; - this.slot = slot; - this.signature = signature; - this.annotations = annotations; - this.parameterAnnotations = parameterAnnotations; - } - - - private int modifiers; - // Generics and annotations support - private transient String signature; - // generic info repository; lazily initialized - private byte[] annotations; - - private volatile ConstructorAccessor constructorAccessor; - - /** - * Returns <tt>true</tt> if and only if the underlying class - * is a member class. - * - * @return <tt>true</tt> if and only if this class is a member class. - * @since 1.5 - */ - public ConstructorAccessor getConstructorAccessor() { - return constructorAccessor; - } - - public void setConstructorAccessor(ConstructorAccessor accessor) { - constructorAccessor = accessor; - // Propagate up - /* - if (root != null) { - root.setConstructorAccessor(accessor); - } - */ - } - - public int getSlot() { - return slot; - } - - public byte[] getRawAnnotations() { - return annotations; - } - - public byte[] getRawParameterAnnotations() { - return parameterAnnotations; - } - - public Constructor<T> copy() { - //todo implement it - throw new UnsupportedOperationException(); - } -} Modified: trunk/core/src/classpath/vm/java/lang/reflect/Method.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/reflect/Method.java 2008-12-13 21:11:59 UTC (rev 4787) +++ trunk/core/src/classpath/vm/java/lang/reflect/Method.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -319,7 +319,7 @@ // 128 is a reasonable buffer initial size for constructor StringBuilder sb = new StringBuilder(128); sb.append(Modifier.toString(getModifiers())).append(' '); - Constructor.addTypeParameters(sb, getTypeParameters()); + addTypeParameters(sb, getTypeParameters()); sb.append(getGenericReturnType()).append(' '); sb.append(getDeclaringClass().getName()).append('.'); sb.append(getName()).append('('); @@ -596,4 +596,18 @@ return result; } + static <X extends GenericDeclaration> + void addTypeParameters(StringBuilder sb, TypeVariable<X>[] typeArgs) + { + if (typeArgs.length == 0) + return; + sb.append('<'); + for (int i = 0; i < typeArgs.length; ++i) + { + if (i > 0) + sb.append(','); + sb.append(typeArgs[i]); + } + sb.append("> "); + } } Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2008-12-13 21:11:59 UTC (rev 4787) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -194,7 +194,41 @@ Member javaMember = javaMemberHolder.get(); if (javaMember == null) { if (isConstructor()) { - javaMember = new Constructor(this); + //parameter types + int arg_count = getNoArguments(); + Class[] args = new Class[arg_count]; + for (int i = 0; i < arg_count; i++) { + args[i] = getArgumentType(i).asClass(); + } + + //checked exceptions + final VmExceptions exceptions = getExceptions(); + int ce_count = exceptions.getLength(); + final Class[] ces = new Class[ce_count]; + for (int i = 0; i < ce_count; i++) { + VmConstClass vmConstClass = exceptions.getException(i); + if (!vmConstClass.isResolved()) { + vmConstClass.doResolve(getDeclaringClass().getLoader()); + } + ces[i] = vmConstClass.getResolvedVmClass().asClass(); + } + + //slot + VmType decl_type = getDeclaringClass(); + int slot = -1; + for (int i = 0; i < decl_type.getNoDeclaredMethods(); i++) { + if (this == decl_type.getDeclaredMethod(i)) { + slot = i; + break; + } + } + + if (slot == -1) { + throw new ClassFormatError("Invalid constructor"); + } + + javaMember = new Constructor(getDeclaringClass().asClass(), args, ces, getModifiers(), slot, + getSignature(), getRawAnnotations(), getRawParameterAnnotations()); } else { javaMember = new Method(this); } Modified: trunk/core/src/openjdk/java/java/lang/ThreadGroup.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ThreadGroup.java 2008-12-13 21:11:59 UTC (rev 4787) +++ trunk/core/src/openjdk/java/java/lang/ThreadGroup.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -68,12 +68,12 @@ int ngroups; ThreadGroup groups[]; - + //jnode /** * Creates an empty Thread group that is not in any Thread group. * This method is used to create the system Thread group. */ - private ThreadGroup() { // called from C code + public ThreadGroup() { // called from C code this.name = "system"; this.maxPriority = Thread.MAX_PRIORITY; } Added: trunk/core/src/openjdk/java/java/lang/reflect/Constructor.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/reflect/Constructor.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/reflect/Constructor.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -0,0 +1,691 @@ +/* + * Copyright 1996-2006 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.reflect; + +import sun.reflect.ConstructorAccessor; +import sun.reflect.Reflection; +import sun.reflect.generics.repository.ConstructorRepository; +import sun.reflect.generics.factory.CoreReflectionFactory; +import sun.reflect.generics.factory.GenericsFactory; +import sun.reflect.generics.scope.ConstructorScope; +import java.lang.annotation.Annotation; +import java.util.Map; +import sun.reflect.annotation.AnnotationParser; +import java.lang.annotation.AnnotationFormatError; +import java.lang.reflect.Modifier; + +/** + * {@code Constructor} provides information about, and access to, a single + * constructor for a class. + * + * <p>{@code Constructor} permits widening conversions to occur when matching the + * actual parameters to newInstance() with the underlying + * constructor's formal parameters, but throws an + * {@code IllegalArgumentException} if a narrowing conversion would occur. + * + * @param <T> the class in which the constructor is declared + * + * @see Member + * @see java.lang.Class + * @see java.lang.Class#getConstructors() + * @see java.lang.Class#getConstructor(Class[]) + * @see java.lang.Class#getDeclaredConstructors() + * + * @author Kenneth Russell + * @author Nakul Saraiya + */ +public final + class Constructor<T> extends AccessibleObject implements + GenericDeclaration, + Member { + + private Class<T> clazz; + private int slot; + private Class[] parameterTypes; + private Class[] exceptionTypes; + private int modifiers; + // Generics and annotations support + private transient String signature; + // generic info repository; lazily initialized + private transient ConstructorRepository genericInfo; + private byte[] annotations; + private byte[] parameterAnnotations; + + // For non-public members or members in package-private classes, + // it is necessary to perform somewhat expensive security checks. + // If the security check succeeds for a given class, it will + // always succeed (it is not affected by the granting or revoking + // of permissions); we speed up the check in the common case by + // remembering the last Class for which the check succeeded. + private volatile Class securityCheckCache; + + // Modifiers that can be applied to a constructor in source code + private static final int LANGUAGE_MODIFIERS = + Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE; + + // Generics infrastructure + // Accessor for factory + private GenericsFactory getFactory() { + // create scope and factory + return CoreReflectionFactory.make(this, ConstructorScope.make(this)); + } + + // Accessor for generic info repository + private ConstructorRepository getGenericInfo() { + // lazily initialize repository if necessary + if (genericInfo == null) { + // create and cache generic info repository + genericInfo = + ConstructorRepository.make(getSignature(), + getFactory()); + } + return genericInfo; //return cached repository + } + + private volatile ConstructorAccessor constructorAccessor; + // For sharing of ConstructorAccessors. This branching structure + // is currently only two levels deep (i.e., one root Constructor + // and potentially many Constructor objects pointing to it.) + private Constructor<T> root; + + //jnode + /** + * Package-private constructor used by ReflectAccess to enable + * instantiation of these objects in Java code from the java.lang + * package via sun.reflect.LangReflectAccess. + */ + public Constructor(Class<T> declaringClass, + Class[] parameterTypes, + Class[] checkedExceptions, + int modifiers, + int slot, + String signature, + byte[] annotations, + byte[] parameterAnnotations) + { + this.clazz = declaringClass; + this.parameterTypes = parameterTypes; + this.exceptionTypes = checkedExceptions; + this.modifiers = modifiers; + this.slot = slot; + this.signature = signature; + this.annotations = annotations; + this.parameterAnnotations = parameterAnnotations; + } + + /** + * Package-private routine (exposed to java.lang.Class via + * ReflectAccess) which returns a copy of this Constructor. The copy's + * "root" field points to this Constructor. + */ + Constructor<T> copy() { + // This routine enables sharing of ConstructorAccessor objects + // among Constructor objects which refer to the same underlying + // method in the VM. (All of this contortion is only necessary + // because of the "accessibility" bit in AccessibleObject, + // which implicitly requires that new java.lang.reflect + // objects be fabricated for each reflective call on Class + // objects.) + Constructor<T> res = new Constructor<T>(clazz, + parameterTypes, + exceptionTypes, modifiers, slot, + signature, + annotations, + parameterAnnotations); + res.root = this; + // Might as well eagerly propagate this if already present + res.constructorAccessor = constructorAccessor; + return res; + } + + /** + * Returns the {@code Class} object representing the class that declares + * the constructor represented by this {@code Constructor} object. + */ + public Class<T> getDeclaringClass() { + return clazz; + } + + /** + * Returns the name of this constructor, as a string. This is + * always the same as the simple name of the constructor's declaring + * class. + */ + public String getName() { + return getDeclaringClass().getName(); + } + + /** + * Returns the Java language modifiers for the constructor + * represented by this {@code Constructor} object, as an integer. The + * {@code Modifier} class should be used to decode the modifiers. + * + * @see Modifier + */ + public int getModifiers() { + return modifiers; + } + + /** + * Returns an array of {@code TypeVariable} objects that represent the + * type variables declared by the generic declaration represented by this + * {@code GenericDeclaration} object, in declaration order. Returns an + * array of length 0 if the underlying generic declaration declares no type + * variables. + * + * @return an array of {@code TypeVariable} objects that represent + * the type variables declared by this generic declaration + * @throws GenericSignatureFormatError if the generic + * signature of this generic declaration does not conform to + * the format specified in the Java Virtual Machine Specification, + * 3rd edition + * @since 1.5 + */ + public TypeVariable<Constructor<T>>[] getTypeParameters() { + if (getSignature() != null) { + return (TypeVariable<Constructor<T>>[])getGenericInfo().getTypeParameters(); + } else + return (TypeVariable<Constructor<T>>[])new TypeVariable[0]; + } + + + /** + * Returns an array of {@code Class} objects that represent the formal + * parameter types, in declaration order, of the constructor + * represented by this {@code Constructor} object. Returns an array of + * length 0 if the underlying constructor takes no parameters. + * + * @return the parameter types for the constructor this object + * represents + */ + public Class<?>[] getParameterTypes() { + return (Class<?>[]) parameterTypes.clone(); + } + + + /** + * Returns an array of {@code Type} objects that represent the formal + * parameter types, in declaration order, of the method represented by + * this {@code Constructor} object. Returns an array of length 0 if the + * underlying method takes no parameters. + * + * <p>If a formal parameter type is a parameterized type, + * the {@code Type} object returned for it must accurately reflect + * the actual type parameters used in the source code. + * + * <p>If a formal parameter type is a type variable or a parameterized + * type, it is created. Otherwise, it is resolved. + * + * @return an array of {@code Type}s that represent the formal + * parameter types of the underlying method, in declaration order + * @throws GenericSignatureFormatError + * if the generic method signature does not conform to the format + * specified in the Java Virtual Machine Specification, 3rd edition + * @throws TypeNotPresentException if any of the parameter + * types of the underlying method refers to a non-existent type + * declaration + * @throws MalformedParameterizedTypeException if any of + * the underlying method's parameter types refer to a parameterized + * type that cannot be instantiated for any reason + * @since 1.5 + */ + public Type[] getGenericParameterTypes() { + if (getSignature() != null) + return getGenericInfo().getParameterTypes(); + else + return getParameterTypes(); + } + + + /** + * Returns an array of {@code Class} objects that represent the types + * of exceptions declared to be thrown by the underlying constructor + * represented by this {@code Constructor} object. Returns an array of + * length 0 if the constructor declares no exceptions in its {@code throws} clause. + * + * @return the exception types declared as being thrown by the + * constructor this object represents + */ + public Class<?>[] getExceptionTypes() { + return (Class<?>[])exceptionTypes.clone(); + } + + + /** + * Returns an array of {@code Type} objects that represent the + * exceptions declared to be thrown by this {@code Constructor} object. + * Returns an array of length 0 if the underlying method declares + * no exceptions in its {@code throws} clause. + * + * <p>If an exception type is a parameterized type, the {@code Type} + * object returned for it must accurately reflect the actual type + * parameters used in the source code. + * + * <p>If an exception type is a type variable or a parameterized + * type, it is created. Otherwise, it is resolved. + * + * @return an array of Types that represent the exception types + * thrown by the underlying method + * @throws GenericSignatureFormatError + * if the generic method signature does not conform to the format + * specified in the Java Virtual Machine Specification, 3rd edition + * @throws TypeNotPresentException if the underlying method's + * {@code throws} clause refers to a non-existent type declaration + * @throws MalformedParameterizedTypeException if + * the underlying method's {@code throws} clause refers to a + * parameterized type that cannot be instantiated for any reason + * @since 1.5 + */ + public Type[] getGenericExceptionTypes() { + Type[] result; + if (getSignature() != null && + ( (result = getGenericInfo().getExceptionTypes()).length > 0 )) + return result; + else + return getExceptionTypes(); + } + + /** + * Compares this {@code Constructor} against the specified object. + * Returns true if the objects are the same. Two {@code Constructor} objects are + * the same if they were declared by the same class and have the + * same formal parameter types. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof Constructor) { + Constructor other = (Constructor)obj; + if (getDeclaringClass() == other.getDeclaringClass()) { + /* Avoid unnecessary cloning */ + Class[] params1 = parameterTypes; + Class[] params2 = other.parameterTypes; + if (params1.length == params2.length) { + for (int i = 0; i < params1.length; i++) { + if (params1[i] != params2[i]) + return false; + } + return true; + } + } + } + return false; + } + + /** + * Returns a hashcode for this {@code Constructor}. The hashcode is + * the same as the hashcode for the underlying constructor's + * declaring class name. + */ + public int hashCode() { + return getDeclaringClass().getName().hashCode(); + } + + /** + * Returns a string describing this {@code Constructor}. The string is + * formatted as the constructor access modifiers, if any, + * followed by the fully-qualified name of the declaring class, + * followed by a parenthesized, comma-separated list of the + * constructor's formal parameter types. For example: + * <pre> + * public java.util.Hashtable(int,float) + * </pre> + * + * <p>The only possible modifiers for constructors are the access + * modifiers {@code public}, {@code protected} or + * {@code private}. Only one of these may appear, or none if the + * constructor has default (package) access. + */ + public String toString() { + try { + StringBuffer sb = new StringBuffer(); + int mod = getModifiers() & LANGUAGE_MODIFIERS; + if (mod != 0) { + sb.append(Modifier.toString(mod) + " "); + } + sb.append(Field.getTypeName(getDeclaringClass())); + sb.append("("); + Class[] params = parameterTypes; // avoid clone + for (int j = 0; j < params.length; j++) { + sb.append(Field.getTypeName(params[j])); + if (j < (params.length - 1)) + sb.append(","); + } + sb.append(")"); + Class[] exceptions = exceptionTypes; // avoid clone + if (exceptions.length > 0) { + sb.append(" throws "); + for (int k = 0; k < exceptions.length; k++) { + sb.append(exceptions[k].getName()); + if (k < (exceptions.length - 1)) + sb.append(","); + } + } + return sb.toString(); + } catch (Exception e) { + return "<" + e + ">"; + } + } + + /** + * Returns a string describing this {@code Constructor}, + * including type parameters. The string is formatted as the + * constructor access modifiers, if any, followed by an + * angle-bracketed comma separated list of the constructor's type + * parameters, if any, followed by the fully-qualified name of the + * declaring class, followed by a parenthesized, comma-separated + * list of the constructor's generic formal parameter types. + * + * A space is used to separate access modifiers from one another + * and from the type parameters or return type. If there are no + * type parameters, the type parameter list is elided; if the type + * parameter list is present, a space separates the list from the + * class name. If the constructor is declared to throw + * exceptions, the parameter list is followed by a space, followed + * by the word "{@code throws}" followed by a + * comma-separated list of the thrown exception types. + * + * <p>The only possible modifiers for constructors are the access + * modifiers {@code public}, {@code protected} or + * {@code private}. Only one of these may appear, or none if the + * constructor has default (package) access. + * + * @return a string describing this {@code Constructor}, + * include type parameters + * + * @since 1.5 + */ + public String toGenericString() { + try { + StringBuilder sb = new StringBuilder(); + int mod = getModifiers() & LANGUAGE_MODIFIERS; + if (mod != 0) { + sb.append(Modifier.toString(mod) + " "); + } + TypeVariable<?>[] typeparms = getTypeParameters(); + if (typeparms.length > 0) { + boolean first = true; + sb.append("<"); + for(TypeVariable<?> typeparm: typeparms) { + if (!first) + sb.append(","); + // Class objects can't occur here; no need to test + // and call Class.getName(). + sb.append(typeparm.toString()); + first = false; + } + sb.append("> "); + } + sb.append(Field.getTypeName(getDeclaringClass())); + sb.append("("); + Type[] params = getGenericParameterTypes(); + for (int j = 0; j < params.length; j++) { + String param = (params[j] instanceof Class<?>)? + Field.getTypeName((Class<?>)params[j]): + (params[j].toString()); + sb.append(param); + if (j < (params.length - 1)) + sb.append(","); + } + sb.append(")"); + Type[] exceptions = getGenericExceptionTypes(); + if (exceptions.length > 0) { + sb.append(" throws "); + for (int k = 0; k < exceptions.length; k++) { + sb.append((exceptions[k] instanceof Class)? + ((Class)exceptions[k]).getName(): + exceptions[k].toString()); + if (k < (exceptions.length - 1)) + sb.append(","); + } + } + return sb.toString(); + } catch (Exception e) { + return "<" + e + ">"; + } + } + + /** + * Uses the constructor represented by this {@code Constructor} object to + * create and initialize a new instance of the constructor's + * declaring class, with the specified initialization parameters. + * Individual parameters are automatically unwrapped to match + * primitive formal parameters, and both primitive and reference + * parameters are subject to method invocation conversions as necessary. + * + * <p>If the number of formal parameters required by the underlying constructor + * is 0, the supplied {@code initargs} array may be of length 0 or null. + * + * <p>If the constructor's declaring class is an inner class in a + * non-static context, the first argument to the constructor needs + * to be the enclosing instance; see <i>The Java Language + * Specification</i>, section 15.9.3. + * + * <p>If the required access and argument checks succeed and the + * instantiation will proceed, the constructor's declaring class + * is initialized if it has not already been initialized. + * + * <p>If the constructor completes normally, returns the newly + * created and initialized instance. + * + * @param initargs array of objects to be passed as arguments to + * the constructor call; values of primitive types are wrapped in + * a wrapper object of the appropriate type (e.g. a {@code float} + * in a {@link java.lang.Float Float}) + * + * @return a new object created by calling the constructor + * this object represents + * + * @exception IllegalAccessException if this {@code Constructor} object + * enforces Java language access control and the underlying + * constructor is inaccessible. + * @exception IllegalArgumentException if the number of actual + * and formal parameters differ; if an unwrapping + * conversion for primitive arguments fails; or if, + * after possible unwrapping, a parameter value + * cannot be converted to the corresponding formal + * parameter type by a method invocation conversion; if + * this constructor pertains to an enum type. + * @exception InstantiationException if the class that declares the + * underlying constructor represents an abstract class. + * @exception InvocationTargetException if the underlying constructor + * throws an exception. + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails. + */ + public T newInstance(Object ... initargs) + throws InstantiationException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException + { + if (!override) { + if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) { + Class caller = Reflection.getCallerClass(2); + if (securityCheckCache != caller) { + Reflection.ensureMemberAccess(caller, clazz, null, modifiers); + securityCheckCache = caller; + } + } + } + if ((clazz.getModifiers() & Modifier.ENUM) != 0) + throw new IllegalArgumentException("Cannot reflectively create enum objects"); + if (constructorAccessor == null) acquireConstructorAccessor(); + return (T) constructorAccessor.newInstance(initargs); + } + + /** + * Returns {@code true} if this constructor was declared to take + * a variable number of arguments; returns {@code false} + * otherwise. + * + * @return {@code true} if an only if this constructor was declared to + * take a variable number of arguments. + * @since 1.5 + */ + public boolean isVarArgs() { + return (getModifiers() & Modifier.VARARGS) != 0; + } + + /** + * Returns {@code true} if this constructor is a synthetic + * constructor; returns {@code false} otherwise. + * + * @return true if and only if this constructor is a synthetic + * constructor as defined by the Java Language Specification. + * @since 1.5 + */ + public boolean isSynthetic() { + return Modifier.isSynthetic(getModifiers()); + } + + // NOTE that there is no synchronization used here. It is correct + // (though not efficient) to generate more than one + // ConstructorAccessor for a given Constructor. However, avoiding + // synchronization will probably make the implementation more + // scalable. + private void acquireConstructorAccessor() { + // First check to see if one has been created yet, and take it + // if so. + ConstructorAccessor tmp = null; + if (root != null) tmp = root.getConstructorAccessor(); + if (tmp != null) { + constructorAccessor = tmp; + return; + } + // Otherwise fabricate one and propagate it up to the root + tmp = reflectionFactory.newConstructorAccessor(this); + setConstructorAccessor(tmp); + } + + // Returns ConstructorAccessor for this Constructor object, not + // looking up the chain to the root + ConstructorAccessor getConstructorAccessor() { + return constructorAccessor; + } + + // Sets the ConstructorAccessor for this Constructor object and + // (recursively) its root + void setConstructorAccessor(ConstructorAccessor accessor) { + constructorAccessor = accessor; + // Propagate up + if (root != null) { + root.setConstructorAccessor(accessor); + } + } + + //jnode + public int getSlot() { + return slot; + } + + String getSignature() { + return signature; + } + + byte[] getRawAnnotations() { + return annotations; + } + + byte[] getRawParameterAnnotations() { + return parameterAnnotations; + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.5 + */ + public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { + if (annotationClass == null) + throw new NullPointerException(); + + return (T) declaredAnnotations().get(annotationClass); + } + + private static final Annotation[] EMPTY_ANNOTATION_ARRAY=new Annotation[0]; + + /** + * @since 1.5 + */ + public Annotation[] getDeclaredAnnotations() { + return declaredAnnotations().values().toArray(EMPTY_ANNOTATION_ARRAY); + } + + private transient Map<Class, Annotation> declaredAnnotations; + + private synchronized Map<Class, Annotation> declaredAnnotations() { + if (declaredAnnotations == null) { + declaredAnnotations = AnnotationParser.parseAnnotations( + annotations, sun.misc.SharedSecrets.getJavaLangAccess(). + getConstantPool(getDeclaringClass()), + getDeclaringClass()); + } + return declaredAnnotations; + } + + /** + * Returns an array of arrays that represent the annotations on the formal + * parameters, in declaration order, of the method represented by + * this {@code Constructor} object. (Returns an array of length zero if the + * underlying method is parameterless. If the method has one or more + * parameters, a nested array of length zero is returned for each parameter + * with no annotations.) The annotation objects contained in the returned + * arrays are serializable. The caller of this method is free to modify + * the returned arrays; it will have no effect on the arrays returned to + * other callers. + * + * @return an array of arrays that represent the annotations on the formal + * parameters, in declaration order, of the method represented by this + * Constructor object + * @since 1.5 + */ + public Annotation[][] getParameterAnnotations() { + int numParameters = parameterTypes.length; + if (parameterAnnotations == null) + return new Annotation[numParameters][0]; + + Annotation[][] result = AnnotationParser.parseParameterAnnotations( + parameterAnnotations, + sun.misc.SharedSecrets.getJavaLangAccess(). + getConstantPool(getDeclaringClass()), + getDeclaringClass()); + if (result.length != numParameters) { + Class<?> declaringClass = getDeclaringClass(); + if (declaringClass.isEnum() || + declaringClass.isAnonymousClass() || + declaringClass.isLocalClass() ) + ; // Can't do reliable parameter counting + else { + if (!declaringClass.isMemberClass() || // top-level + // Check for the enclosing instance parameter for + // non-static member classes + (declaringClass.isMemberClass() && + ((declaringClass.getModifiers() & Modifier.STATIC) == 0) && + result.length + 1 != numParameters) ) { + throw new AnnotationFormatError( + "Parameter annotations don't match number of parameters"); + } + } + } + return result; + } +} Modified: trunk/core/src/openjdk/vm/sun/reflect/NativeNativeConstructorAccessorImpl.java =================================================================== --- trunk/core/src/openjdk/vm/sun/reflect/NativeNativeConstructorAccessorImpl.java 2008-12-13 21:11:59 UTC (rev 4787) +++ trunk/core/src/openjdk/vm/sun/reflect/NativeNativeConstructorAccessorImpl.java 2008-12-14 21:49:21 UTC (rev 4788) @@ -1,6 +1,10 @@ package sun.reflect; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.jnode.vm.classmgr.VmType; +import org.jnode.vm.classmgr.VmMethod; +import org.jnode.vm.VmReflection; /** * @see sun.reflect.NativeConstructorAccessorImpl @@ -9,8 +13,16 @@ /** * @see sun.reflect.NativeConstructorAccessorImpl#newInstance0(java.lang.reflect.Constructor, java.lang.Object[]) */ - private static Object newInstance0(Constructor arg1, Object[] arg2) { - //todo implement it - throw new UnsupportedOperationException(); + private static Object newInstance0(Constructor arg1, Object[] arg2) throws InstantiationException, + IllegalArgumentException, + InvocationTargetException{ + VmType vmt = arg1.getDeclaringClass().getVmClass(); + VmMethod vmm = vmt.getDeclaredMethod(arg1.getSlot()); + try { + return VmReflection.newInstance(vmm, arg2); + } catch (IllegalAccessException iae) { //todo| this should not happen, fix VmReflection.newInstance() to not + //todo| throw this exception + throw new InstantiationException("Unexpected IllegalAccessException"); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-12-27 17:00:29
|
Revision: 4809 http://jnode.svn.sourceforge.net/jnode/?rev=4809&view=rev Author: lsantha Date: 2008-12-27 17:00:27 +0000 (Sat, 27 Dec 2008) Log Message: ----------- Improved reflective field access. Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/classmgr/VmField.java trunk/core/src/openjdk/java/java/lang/reflect/Field.java trunk/core/src/openjdk/vm/sun/misc/NativeUnsafe.java Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmField.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmField.java 2008-12-27 09:16:49 UTC (rev 4808) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmField.java 2008-12-27 17:00:27 UTC (rev 4809) @@ -122,8 +122,20 @@ } Field javaField = javaFieldHolder.get(); if (javaField == null) { + //slot + VmType<?> d_class = getDeclaringClass(); + int slot = -1; + for (int i = 0; i < d_class.getNoDeclaredFields(); i++) { + if (this == d_class.getDeclaredField(i)) { + slot = i; + break; + } + } + if (slot == -1) { + throw new ClassFormatError("Invalid field: " + this.getName()); + } //todo add annotations - javaField = new Field(getDeclaringClass().asClass(), getName(), getType().asClass(), getModifiers(), -1, + javaField = new Field(d_class.asClass(), getName(), getType().asClass(), getModifiers(), slot, getSignature(), null); javaFieldHolder.set(javaField); } Modified: trunk/core/src/openjdk/java/java/lang/reflect/Field.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/reflect/Field.java 2008-12-27 09:16:49 UTC (rev 4808) +++ trunk/core/src/openjdk/java/java/lang/reflect/Field.java 2008-12-27 17:00:27 UTC (rev 4809) @@ -1038,4 +1038,9 @@ } return declaredAnnotations; } + + //jnode + public int getSlot() { + return slot; + } } Modified: trunk/core/src/openjdk/vm/sun/misc/NativeUnsafe.java =================================================================== --- trunk/core/src/openjdk/vm/sun/misc/NativeUnsafe.java 2008-12-27 09:16:49 UTC (rev 4808) +++ trunk/core/src/openjdk/vm/sun/misc/NativeUnsafe.java 2008-12-27 17:00:27 UTC (rev 4809) @@ -417,8 +417,8 @@ private static VmField getVmField(Field f) { VmType<?> vmClass = VmType.fromClass((Class<?>) f.getDeclaringClass()); - vmClass.link(); - return vmClass.getField(f.getName()); + //vmClass.link(); + return vmClass.getDeclaredField(f.getSlot()); } public static void ensureClassInitialized(Unsafe instance, Class c) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-12-30 18:20:30
|
Revision: 4810 http://jnode.svn.sourceforge.net/jnode/?rev=4810&view=rev Author: lsantha Date: 2008-12-30 18:20:25 +0000 (Tue, 30 Dec 2008) Log Message: ----------- Bugfixes and cleanups related to reflection. Modified Paths: -------------- trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMVirtualMachine.java trunk/core/src/core/org/jnode/util/IOUtils.java trunk/core/src/core/org/jnode/vm/VmReflection.java trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java trunk/core/src/core/org/jnode/vm/classmgr/TIBBuilder.java trunk/core/src/core/org/jnode/vm/classmgr/VmClassType.java Modified: trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMVirtualMachine.java =================================================================== --- trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMVirtualMachine.java 2008-12-27 17:00:27 UTC (rev 4809) +++ trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMVirtualMachine.java 2008-12-30 18:20:25 UTC (rev 4810) @@ -68,7 +68,7 @@ } public Object next() { - return iter.next().newClass(); + return iter.next().asClass(); } public void remove() { Modified: trunk/core/src/core/org/jnode/util/IOUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/IOUtils.java 2008-12-27 17:00:27 UTC (rev 4809) +++ trunk/core/src/core/org/jnode/util/IOUtils.java 2008-12-30 18:20:25 UTC (rev 4810) @@ -106,7 +106,9 @@ try { Class<FilterInputStream> cls = FilterInputStream.class; Field field = cls.getDeclaredField("in"); + field.setAccessible(true); Object in = field.get(inputStream); + field.setAccessible(false); return (InputStream) in; } catch (Exception ex) { Logger.getLogger(IOUtils.class).error("Cannot extract the 'in' field", ex); Modified: trunk/core/src/core/org/jnode/vm/VmReflection.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmReflection.java 2008-12-27 17:00:27 UTC (rev 4809) +++ trunk/core/src/core/org/jnode/vm/VmReflection.java 2008-12-30 18:20:25 UTC (rev 4810) @@ -82,7 +82,7 @@ return (byte) getStaticFieldAddress(sf).loadInt(); } else { final VmInstanceField inf = (VmInstanceField) field; - return (byte) getInstanceFieldAddress(o, inf).loadByte(); + return getInstanceFieldAddress(o, inf).loadByte(); } } @@ -93,7 +93,7 @@ return (char) getStaticFieldAddress(sf).loadInt(); } else { final VmInstanceField inf = (VmInstanceField) field; - return (char) getInstanceFieldAddress(o, inf).loadChar(); + return getInstanceFieldAddress(o, inf).loadChar(); } } @@ -104,7 +104,7 @@ return (short) getStaticFieldAddress(sf).loadInt(); } else { final VmInstanceField inf = (VmInstanceField) field; - return (short) getInstanceFieldAddress(o, inf).loadShort(); + return getInstanceFieldAddress(o, inf).loadShort(); } } @@ -343,39 +343,133 @@ Unsafe.pushObject(o); if (!method.isConstructor()) { - method = VmType.fromClass(o.getClass()).getMethod(method.getName(), method.getSignature()); + //todo implement dynamic method lookup according to JLS 15.12.4.4 + if(method.isAbstract()) + method = VmType.fromClass(o.getClass()).getMethod(method.getName(), method.getSignature()); + else if(java.lang.reflect.Proxy.isProxyClass(o.getClass())) { + method = VmType.fromClass(o.getClass()).getMethod(method.getName(), method.getSignature()); + } } } else { method.getDeclaringClass().initialize(); } + for (int i = 0; i < argCount; i++) { final VmType<?> argType = method.getArgumentType(i); final Object arg = args[i]; if (argType.isPrimitive()) { + if (arg == null) + throw new IllegalArgumentException(); + int v = 0; long lv = 0; boolean wide = false; - if (arg == null) { - /* do nothing */ - } else if (arg instanceof Boolean) { - v = ((Boolean) arg).booleanValue() ? 1 : 0; - } else if (arg instanceof Byte) { - v = ((Byte) arg).byteValue(); - } else if (arg instanceof Character) { - v = ((Character) arg).charValue(); - } else if (arg instanceof Short) { - v = ((Short) arg).shortValue(); - } else if (arg instanceof Integer) { - v = ((Integer) arg).intValue(); - } else if (arg instanceof Long) { - lv = ((Long) arg).longValue(); - wide = true; - } else if (arg instanceof Float) { - v = Float.floatToRawIntBits(((Float) arg).floatValue()); - } else if (arg instanceof Double) { - lv = Double.doubleToRawLongBits(((Double) arg) - .doubleValue()); - wide = true; + switch (argType.getJvmType()) { + case JvmType.BOOLEAN: { + if (arg instanceof Boolean) { + v = (Boolean) arg ? 1 : 0; + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.INT: { + if (arg instanceof Integer) { + v = (Integer) arg; + } else if (arg instanceof Byte) { + v = (Byte) arg; + } else if (arg instanceof Character) { + v = (Character) arg; + } else if (arg instanceof Short) { + v = (Short) arg; + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.CHAR: { + if (arg instanceof Character) { + v = (Character) arg; + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.BYTE: { + if (arg instanceof Byte) { + v = (Byte) arg; + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.SHORT: { + if (arg instanceof Short) { + v = (Short) arg; + } else if (arg instanceof Byte) { + v = (Byte) arg; + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.FLOAT: { + if (arg instanceof Float) { + v = Float.floatToRawIntBits((Float) arg); + } else if (arg instanceof Byte) { + v = Float.floatToRawIntBits((Byte) arg); + } else if (arg instanceof Short) { + v = Float.floatToRawIntBits((Short) arg); + } else if (arg instanceof Integer) { + v = Float.floatToRawIntBits((Integer) arg); + } else if (arg instanceof Character) { + v = Float.floatToRawIntBits((Character) arg); + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.LONG: { + wide = true; + if (arg instanceof Long) { + lv = (Long) arg; + } else if (arg instanceof Integer) { + lv = (Integer) arg; + } else if (arg instanceof Byte) { + lv = (Byte) arg; + } else if (arg instanceof Short) { + lv = (Short) arg; + } else if (arg instanceof Character) { + lv = (Character) arg; + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + case JvmType.DOUBLE: { + wide = true; + if (arg instanceof Double) { + lv = Double.doubleToRawLongBits((Double) arg); + } else if (arg instanceof Integer) { + lv = Double.doubleToRawLongBits((Integer) arg); + } else if (arg instanceof Byte) { + lv = Double.doubleToRawLongBits((Byte) arg); + } else if (arg instanceof Short) { + lv = Double.doubleToRawLongBits((Short) arg); + } else if (arg instanceof Character) { + lv = Double.doubleToRawLongBits((Character) arg); + } else if (arg instanceof Float) { + lv = Double.doubleToRawLongBits((Float) arg); + } else if (arg instanceof Long) { + lv = Double.doubleToRawLongBits((Long) arg); + } else { + throw new IllegalArgumentException("argument type mismatch"); + } + break; + } + default: { + throw new RuntimeException("invalid argument type: " + argType); + } } final Class argClass = argType.asClass(); @@ -395,6 +489,11 @@ } } } else { + if(arg != null) { + if(!argType.isAssignableFrom(VmType.fromClass(arg.getClass()))) { + throw new IllegalArgumentException ("argument type mismatch"); + } + } // Non-primitive argument Unsafe.pushObject(arg); } @@ -410,25 +509,25 @@ long rc = Unsafe.invokeLong(method); final Class<?> retType = method.getReturnType().asClass(); if (Long.TYPE == retType) { - return new Long(rc); + return rc; } else { - return new Double(Double.longBitsToDouble(rc)); + return Double.longBitsToDouble(rc); } } else { int rc = Unsafe.invokeInt(method); final Class retType = method.getReturnType().asClass(); if (Byte.TYPE == retType) { - return new Byte((byte) rc); + return (byte) rc; } else if (Boolean.TYPE == retType) { - return Boolean.valueOf(rc != 0); + return rc != 0; } else if (Character.TYPE == retType) { - return new Character((char) rc); + return (char) rc; } else if (Short.TYPE == retType) { - return new Short((short) rc); + return (short) rc; } else if (Float.TYPE == retType) { - return new Float(Float.intBitsToFloat(rc)); + return Float.intBitsToFloat(rc); } else { - return new Integer(rc); + return rc; } } } catch (Throwable ex) { Modified: trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2008-12-27 17:00:27 UTC (rev 4809) +++ trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2008-12-30 18:20:25 UTC (rev 4810) @@ -1015,7 +1015,7 @@ break; } - r_class = vtm.newClass(); + r_class = vtm.asClass(); } else { try { r_class = Class.forName(vtm.getName(), false, vtm.getLoader().asClassLoader()); @@ -1024,7 +1024,7 @@ } } Object defo = AnnotationParser.parseMemberValue(r_class, data, new VmConstantPool(cls), - cls.newClass()); + cls.asClass()); mts.setAnnotationDefault(defo); } else { skip(data, length); @@ -1263,7 +1263,7 @@ break; } - r_class = vtm.newClass(); + r_class = vtm.asClass(); } else { try { r_class = vtm.getLoader().asClassLoader().loadClass(vtm.getName()); Modified: trunk/core/src/core/org/jnode/vm/classmgr/TIBBuilder.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/TIBBuilder.java 2008-12-27 17:00:27 UTC (rev 4809) +++ trunk/core/src/core/org/jnode/vm/classmgr/TIBBuilder.java 2008-12-30 18:20:25 UTC (rev 4810) @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.HashMap; +import gnu.java.lang.VMClassHelper; /** * @author epr @@ -103,7 +104,28 @@ method.setTibOffset(index); } + //todo review rules for overriding and do more testing /** + * Check if the method has the correct visibility ofr overriding the method at index. + * It asumed that the signutares were already checked and they match + * @param index + * @param method + * @return + */ + boolean overrides(int index, VmInstanceMethod method) { + if (tibAsArray != null) { + throw new RuntimeException("This VMT is locked"); + } + if (index < FIRST_METHOD_INDEX) { + throw new IndexOutOfBoundsException("Index (" + index + ")must be >= " + FIRST_METHOD_INDEX); + } + VmInstanceMethod met = (VmInstanceMethod) tibAsList.get(index); + return (met.isPublic() || met.isProtected() || (!met.isPrivate() && + VMClassHelper.getPackagePortion(met.getDeclaringClass().getName()). + equals(VMClassHelper.getPackagePortion(method.getDeclaringClass().getName())))); + } + + /** * Search through a given VMT for a method with a given name & signature. * Return the index in the VMT (0..length-1) if found, -1 otherwise. * Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmClassType.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmClassType.java 2008-12-27 17:00:27 UTC (rev 4809) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmClassType.java 2008-12-30 18:20:25 UTC (rev 4810) @@ -148,7 +148,11 @@ final int index = vmt.indexOf(name, signature); if (index >= 0) { // The method existed in the super class, overwrite it - vmt.set(index, method); + if(vmt.overrides(index, method)){ + vmt.set(index, method); + } else { + vmt.add(method); + } } else { // The method does not exist yet. vmt.add(method); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-01-04 10:08:49
|
Revision: 4824 http://jnode.svn.sourceforge.net/jnode/?rev=4824&view=rev Author: lsantha Date: 2009-01-04 10:08:42 +0000 (Sun, 04 Jan 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/core/src/classpath/java/java/security/CodeSource.java Added Paths: ----------- trunk/core/src/openjdk/java/java/net/URLClassLoader.java Removed Paths: ------------- trunk/core/src/classpath/java/java/net/URLClassLoader.java Deleted: trunk/core/src/classpath/java/java/net/URLClassLoader.java =================================================================== --- trunk/core/src/classpath/java/java/net/URLClassLoader.java 2009-01-04 01:48:18 UTC (rev 4823) +++ trunk/core/src/classpath/java/java/net/URLClassLoader.java 2009-01-04 10:08:42 UTC (rev 4824) @@ -1,1325 +0,0 @@ -/* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - 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 java.net; - -import java.io.ByteArrayOutputStream; -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FilePermission; -import java.io.IOException; -import java.io.InputStream; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.CodeSource; -import java.security.PermissionCollection; -import java.security.PrivilegedAction; -import java.security.SecureClassLoader; -import java.security.cert.Certificate; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - - -/** - * A secure class loader that can load classes and resources from - * multiple locations. Given an array of <code>URL</code>s this class - * loader will retrieve classes and resources by fetching them from - * possible remote locations. Each <code>URL</code> is searched in - * order in which it was added. If the file portion of the - * <code>URL</code> ends with a '/' character then it is interpreted - * as a base directory, otherwise it is interpreted as a jar file from - * which the classes/resources are resolved. - * - * <p>New instances can be created by two static - * <code>newInstance()</code> methods or by three public - * contructors. Both ways give the option to supply an initial array - * of <code>URL</code>s and (optionally) a parent classloader (that is - * different from the standard system class loader).</p> - * - * <p>Normally creating a <code>URLClassLoader</code> throws a - * <code>SecurityException</code> if a <code>SecurityManager</code> is - * installed and the <code>checkCreateClassLoader()</code> method does - * not return true. But the <code>newInstance()</code> methods may be - * used by any code as long as it has permission to acces the given - * <code>URL</code>s. <code>URLClassLoaders</code> created by the - * <code>newInstance()</code> methods also explicitly call the - * <code>checkPackageAccess()</code> method of - * <code>SecurityManager</code> if one is installed before trying to - * load a class. Note that only subclasses of - * <code>URLClassLoader</code> can add new URLs after the - * URLClassLoader had been created. But it is always possible to get - * an array of all URLs that the class loader uses to resolve classes - * and resources by way of the <code>getURLs()</code> method.</p> - * - * <p>Open issues: - * <ul> - * - * <li>Should the URLClassLoader actually add the locations found in - * the manifest or is this the responsibility of some other - * loader/(sub)class? (see <a - * href="http://java.sun.com/products/jdk/1.4/docs/guide/extensions/spec.html"> - * Extension Mechanism Architecture - Bundles Extensions</a>)</li> - * - * <li>How does <code>definePackage()</code> and sealing work - * precisely?</li> - * - * <li>We save and use the security context (when a created by - * <code>newInstance()</code> but do we have to use it in more - * places?</li> - * - * <li>The use of <code>URLStreamHandler</code>s has not been tested.</li> - * - * </ul> - * </p> - * - * @since 1.2 - * - * @author Mark Wielaard (ma...@kl...) - * @author Wu Gansha (gan...@in...) - */ -public class URLClassLoader extends SecureClassLoader -{ - // Class Variables - - /** - * A global cache to store mappings between URLLoader and URL, - * so we can avoid do all the homework each time the same URL - * comes. - * XXX - Keeps these loaders forever which prevents garbage collection. - */ - private static HashMap urlloaders = new HashMap(); - - /** - * A cache to store mappings between handler factory and its - * private protocol handler cache (also a HashMap), so we can avoid - * create handlers each time the same protocol comes. - */ - private static HashMap factoryCache = new HashMap(5); - - // Instance variables - - /** Locations to load classes from */ - private final Vector urls = new Vector(); - - /** - * Store pre-parsed information for each url into this vector: each - * element is a URL loader. A jar file has its own class-path - * attribute which adds to the URLs that will be searched, but this - * does not add to the list of urls. - */ - private final Vector urlinfos = new Vector(); - - /** Factory used to get the protocol handlers of the URLs */ - private final URLStreamHandlerFactory factory; - - /** - * The security context when created from <code>newInstance()</code> - * or null when created through a normal constructor or when no - * <code>SecurityManager</code> was installed. - */ - private final AccessControlContext securityContext; - - // Helper classes - - /** - * A <code>URLLoader</code> contains all logic to load resources from a - * given base <code>URL</code>. - */ - abstract static class URLLoader - { - /** - * Our classloader to get info from if needed. - */ - final URLClassLoader classloader; - - /** - * The base URL from which all resources are loaded. - */ - final URL baseURL; - - /** - * A <code>CodeSource</code> without any associated certificates. - * It is common for classes to not have certificates associated - * with them. If they come from the same <code>URLLoader</code> - * then it is safe to share the associated <code>CodeSource</code> - * between them since <code>CodeSource</code> is immutable. - */ - final CodeSource noCertCodeSource; - - URLLoader(URLClassLoader classloader, URL baseURL) - { - this(classloader, baseURL, baseURL); - } - - URLLoader(URLClassLoader classloader, URL baseURL, URL overrideURL) - { - this.classloader = classloader; - this.baseURL = baseURL; - this.noCertCodeSource = new CodeSource(overrideURL, (Certificate[])null); - } - - /** - * Returns a <code>Resource</code> loaded by this - * <code>URLLoader</code>, or <code>null</code> when no - * <code>Resource</code> with the given name exists. - */ - abstract Resource getResource(String s); - - /** - * Returns the <code>Manifest</code> associated with the - * <code>Resource</code>s loaded by this <code>URLLoader</code> or - * <code>null</code> there is no such <code>Manifest</code>. - */ - Manifest getManifest() - { - return null; - } - - Vector getClassPath() - { - return null; - } - } - - /** - * A <code>Resource</code> represents a resource in some - * <code>URLLoader</code>. It also contains all information (e.g., - * <code>URL</code>, <code>CodeSource</code>, <code>Manifest</code> and - * <code>InputStream</code>) that is necessary for loading resources - * and creating classes from a <code>URL</code>. - */ - abstract static class Resource - { - final URLLoader loader; - - Resource(URLLoader loader) - { - this.loader = loader; - } - - /** - * Returns the non-null <code>CodeSource</code> associated with - * this resource. - */ - CodeSource getCodeSource() - { - Certificate[] certs = getCertificates(); - if (certs == null) - return loader.noCertCodeSource; - else - return new CodeSource(loader.baseURL, certs); - } - - /** - * Returns <code>Certificates</code> associated with this - * resource, or null when there are none. - */ - Certificate[] getCertificates() - { - return null; - } - - /** - * Return a <code>URL</code> that can be used to access this resource. - */ - abstract URL getURL(); - - /** - * Returns the size of this <code>Resource</code> in bytes or - * <code>-1</code> when unknown. - */ - abstract int getLength(); - - /** - * Returns the non-null <code>InputStream</code> through which - * this resource can be loaded. - */ - abstract InputStream getInputStream() throws IOException; - } - - /** - * A <code>JarURLLoader</code> is a type of <code>URLLoader</code> - * only loading from jar url. - */ - static final class JarURLLoader extends URLLoader - { - final JarFile jarfile; // The jar file for this url - final URL baseJarURL; // Base jar: url for all resources loaded from jar - - Vector classPath; // The "Class-Path" attribute of this Jar's manifest - - public JarURLLoader(URLClassLoader classloader, URL baseURL, - URL absoluteUrl) - { - super(classloader, baseURL, absoluteUrl); - - // Cache url prefix for all resources in this jar url. - String external = baseURL.toExternalForm(); - StringBuffer sb = new StringBuffer(external.length() + 6); - sb.append("jar:"); - sb.append(external); - sb.append("!/"); - String jarURL = sb.toString(); - - this.classPath = null; - URL baseJarURL = null; - JarFile jarfile = null; - try - { - baseJarURL = - new URL(null, jarURL, classloader.getURLStreamHandler("jar")); - - jarfile = - ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); - - Manifest manifest; - Attributes attributes; - String classPathString; - - if ((manifest = jarfile.getManifest()) != null - && (attributes = manifest.getMainAttributes()) != null - && ((classPathString - = attributes.getValue(Attributes.Name.CLASS_PATH)) - != null)) - { - this.classPath = new Vector(); - - StringTokenizer st = new StringTokenizer(classPathString, " "); - while (st.hasMoreElements ()) - { - String e = st.nextToken (); - try - { - URL url = new URL(baseURL, e); - this.classPath.add(url); - } - catch (java.net.MalformedURLException xx) - { - // Give up - } - } - } - } - catch (IOException ioe) - { - /* ignored */ - } - - this.baseJarURL = baseJarURL; - this.jarfile = jarfile; - } - - /** get resource with the name "name" in the jar url */ - Resource getResource(String name) - { - if (jarfile == null) - return null; - - if (name.startsWith("/")) - name = name.substring(1); - - JarEntry je = jarfile.getJarEntry(name); - if (je != null) - return new JarURLResource(this, name, je); - else - return null; - } - - Manifest getManifest() - { - try - { - return (jarfile == null) ? null : jarfile.getManifest(); - } - catch (IOException ioe) - { - return null; - } - } - - Vector getClassPath() - { - return classPath; - } - } - - static final class JarURLResource extends Resource - { - private final JarEntry entry; - private final String name; - - JarURLResource(JarURLLoader loader, String name, JarEntry entry) - { - super(loader); - this.entry = entry; - this.name = name; - } - - InputStream getInputStream() throws IOException - { - return ((JarURLLoader) loader).jarfile.getInputStream(entry); - } - - int getLength() - { - return (int) entry.getSize(); - } - - Certificate[] getCertificates() - { - // We have to get the entry from the jar file again, because the - // certificates will not be available until the entire entry has - // been read. - return ((JarEntry) ((JarURLLoader) loader).jarfile.getEntry(name)) - .getCertificates(); - } - - URL getURL() - { - try - { - return new URL(((JarURLLoader) loader).baseJarURL, name, - loader.classloader.getURLStreamHandler("jar")); - } - catch (MalformedURLException e) - { - InternalError ie = new InternalError(); - ie.initCause(e); - throw ie; - } - } - } - - /** - * Loader for remote directories. - */ - static final class RemoteURLLoader extends URLLoader - { - private final String protocol; - - RemoteURLLoader(URLClassLoader classloader, URL url) - { - super(classloader, url); - protocol = url.getProtocol(); - } - - /** - * Get a remote resource. - * Returns null if no such resource exists. - */ - Resource getResource(String name) - { - try - { - URL url = - new URL(baseURL, name, classloader.getURLStreamHandler(protocol)); - URLConnection connection = url.openConnection(); - - // Open the connection and check the stream - // just to be sure it exists. - int length = connection.getContentLength(); - InputStream stream = connection.getInputStream(); - - // We can do some extra checking if it is a http request - if (connection instanceof HttpURLConnection) - { - int response = - ((HttpURLConnection) connection).getResponseCode(); - if (response / 100 != 2) - return null; - } - - if (stream != null) - return new RemoteResource(this, name, url, stream, length); - else - return null; - } - catch (IOException ioe) - { - return null; - } - } - } - - /** - * A resource from some remote location. - */ - static final class RemoteResource extends Resource - { - private final URL url; - private final InputStream stream; - private final int length; - - RemoteResource(RemoteURLLoader loader, String name, URL url, - InputStream stream, int length) - { - super(loader); - this.url = url; - this.stream = stream; - this.length = length; - } - - InputStream getInputStream() throws IOException - { - return stream; - } - - public int getLength() - { - return length; - } - - public URL getURL() - { - return url; - } - } - - /** - * A <code>FileURLLoader</code> is a type of <code>URLLoader</code> - * only loading from file url. - */ - static final class FileURLLoader extends URLLoader - { - File dir; //the file for this file url - - FileURLLoader(URLClassLoader classloader, URL url, URL absoluteUrl) - { - super(classloader, url, absoluteUrl); - dir = new File(absoluteUrl.getFile()); - } - - /** get resource with the name "name" in the file url */ - Resource getResource(String name) - { - try - { - // Make sure that all components in name are valid by walking through - // them - File file = walkPathComponents(name); - - if (file == null) - return null; - - return new FileResource(this, file); - } - catch (IOException e) - { - // Fall through... - } - return null; - } - - /** - * Walk all path tokens and check them for validity. At no moment, we are - * allowed to reach a directory located "above" the root directory, stored - * in "dir" property. We are also not allowed to enter a non existing - * directory or a non directory component (plain file, symbolic link, ...). - * An empty or null path is valid. Pathnames components are separated by - * <code>File.separatorChar</code> - * - * @param resourceFileName the name to be checked for validity. - * @return the canonical file pointed by the resourceFileName or null if the - * walking failed - * @throws IOException in case of issue when creating the canonical - * resulting file - * @see File#separatorChar - */ - private File walkPathComponents(String resourceFileName) throws IOException - { - StringTokenizer stringTokenizer = new StringTokenizer(resourceFileName, File.separator); - File currentFile = dir; - int tokenCount = stringTokenizer.countTokens(); - - for (int i = 0; i < tokenCount - 1; i++) - { - String currentToken = stringTokenizer.nextToken(); - - // If we are at the root directory and trying to go up, the walking is - // finished with an error - if ("..".equals(currentToken) && currentFile.equals(dir)) - return null; - - currentFile = new File(currentFile, currentToken); - - // If the current file doesn't exist or is not a directory, the walking is - // finished with an error - if (! (currentFile.exists() && currentFile.isDirectory())) - return null; - - } - - // Treat the last token differently, if it exists, because it does not need - // to be a directory - if (tokenCount > 0) - { - String currentToken = stringTokenizer.nextToken(); - - if ("..".equals(currentToken) && currentFile.equals(dir)) - return null; - - currentFile = new File(currentFile, currentToken); - - // If the current file doesn't exist, the walking is - // finished with an error - if (! currentFile.exists()) - return null; - } - - return currentFile.getCanonicalFile(); - } - } - - static final class FileResource extends Resource - { - final File file; - - FileResource(FileURLLoader loader, File file) - { - super(loader); - this.file = file; - } - - InputStream getInputStream() throws IOException - { - return new FileInputStream(file); - } - - public int getLength() - { - return (int) file.length(); - } - - public URL getURL() - { - try - { - return file.toURL(); - } - catch (MalformedURLException e) - { - InternalError ie = new InternalError(); - ie.initCause(e); - throw ie; - } - } - } - - // Constructors - - /** - * Creates a URLClassLoader that gets classes from the supplied URLs. - * To determine if this classloader may be created the constructor of - * the super class (<code>SecureClassLoader</code>) is called first, which - * can throw a SecurityException. Then the supplied URLs are added - * in the order given to the URLClassLoader which uses these URLs to - * load classes and resources (after using the default parent ClassLoader). - * - * @param urls Locations that should be searched by this ClassLoader when - * resolving Classes or Resources. - * @exception SecurityException if the SecurityManager disallows the - * creation of a ClassLoader. - * @see SecureClassLoader - */ - public URLClassLoader(URL[] urls) throws SecurityException - { - super(); - this.factory = null; - this.securityContext = null; - addURLs(urls); - } - - /** - * Creates a <code>URLClassLoader</code> that gets classes from the supplied - * <code>URL</code>s. - * To determine if this classloader may be created the constructor of - * the super class (<code>SecureClassLoader</code>) is called first, which - * can throw a SecurityException. Then the supplied URLs are added - * in the order given to the URLClassLoader which uses these URLs to - * load classes and resources (after using the supplied parent ClassLoader). - * @param urls Locations that should be searched by this ClassLoader when - * resolving Classes or Resources. - * @param parent The parent class loader used before trying this class - * loader. - * @exception SecurityException if the SecurityManager disallows the - * creation of a ClassLoader. - * @exception SecurityException - * @see SecureClassLoader - */ - public URLClassLoader(URL[] urls, ClassLoader parent) - throws SecurityException - { - super(parent); - this.factory = null; - this.securityContext = null; - addURLs(urls); - } - - // Package-private to avoid a trampoline constructor. - /** - * Package-private constructor used by the static - * <code>newInstance(URL[])</code> method. Creates an - * <code>URLClassLoader</code> with the given parent but without any - * <code>URL</code>s yet. This is used to bypass the normal security - * check for creating classloaders, but remembers the security - * context which will be used when defining classes. The - * <code>URL</code>s to load from must be added by the - * <code>newInstance()</code> method in the security context of the - * caller. - * - * @param securityContext the security context of the unprivileged code. - */ - URLClassLoader(ClassLoader parent, AccessControlContext securityContext) - { - super(parent); - this.factory = null; - this.securityContext = securityContext; - } - - /** - * Creates a URLClassLoader that gets classes from the supplied URLs. - * To determine if this classloader may be created the constructor of - * the super class (<CODE>SecureClassLoader</CODE>) is called first, which - * can throw a SecurityException. Then the supplied URLs are added - * in the order given to the URLClassLoader which uses these URLs to - * load classes and resources (after using the supplied parent ClassLoader). - * It will use the supplied <CODE>URLStreamHandlerFactory</CODE> to get the - * protocol handlers of the supplied URLs. - * @param urls Locations that should be searched by this ClassLoader when - * resolving Classes or Resources. - * @param parent The parent class loader used before trying this class - * loader. - * @param factory Used to get the protocol handler for the URLs. - * @exception SecurityException if the SecurityManager disallows the - * creation of a ClassLoader. - * @exception SecurityException - * @see SecureClassLoader - */ - public URLClassLoader(URL[] urls, ClassLoader parent, - URLStreamHandlerFactory factory) - throws SecurityException - { - super(parent); - this.securityContext = null; - this.factory = factory; - addURLs(urls); - - // If this factory is still not in factoryCache, add it, - // since we only support three protocols so far, 5 is enough - // for cache initial size - synchronized (factoryCache) - { - if (factory != null && factoryCache.get(factory) == null) - factoryCache.put(factory, new HashMap(5)); - } - } - - // Methods - - /** - * Adds a new location to the end of the internal URL store. - * @param newUrl the location to add - */ - protected void addURL(URL newUrl) - { - urls.add(newUrl); - addURLImpl(newUrl); - } - - private void addURLImpl(URL newUrl) - { - synchronized (this) - { - if (newUrl == null) - return; // Silently ignore... - - // Reset the toString() value. - thisString = null; - - // Check global cache to see if there're already url loader - // for this url. - URLLoader loader = (URLLoader) urlloaders.get(newUrl); - if (loader == null) - { - String file = newUrl.getFile(); - String protocol = newUrl.getProtocol(); - - // If we have a file: URL, we want to make it absolute - // here, before we decide whether it is really a jar. - URL absoluteURL; - if ("file".equals (protocol)) - { - File dir = new File(file); - URL absUrl; - try - { - absoluteURL = dir.getCanonicalFile().toURL(); - } - catch (IOException ignore) - { - try - { - absoluteURL = dir.getAbsoluteFile().toURL(); - } - catch (MalformedURLException _) - { - // This really should not happen. - absoluteURL = newUrl; - } - } - } - else - { - // This doesn't hurt, and it simplifies the logic a - // little. - absoluteURL = newUrl; - } - - // Check that it is not a directory - if (! (file.endsWith("/") || file.endsWith(File.separator))) - loader = new JarURLLoader(this, newUrl, absoluteURL); - else if ("file".equals(protocol)) - loader = new FileURLLoader(this, newUrl, absoluteURL); - else - loader = new RemoteURLLoader(this, newUrl); - - // Cache it. - urlloaders.put(newUrl, loader); - } - - urlinfos.add(loader); - - Vector extraUrls = loader.getClassPath(); - if (extraUrls != null) - { - Iterator it = extraUrls.iterator(); - while (it.hasNext()) - { - URL url = (URL)it.next(); - URLLoader extraLoader = (URLLoader) urlloaders.get(url); - if (! urlinfos.contains (extraLoader)) - addURLImpl(url); - } - } - - } - } - - /** - * Adds an array of new locations to the end of the internal URL - * store. Called from the the constructors. Should not call to the - * protected addURL() method since that can be overridden and - * subclasses are not yet in a good state at this point. - * jboss 4.0.3 for example depends on this. - * - * @param newUrls the locations to add - */ - private void addURLs(URL[] newUrls) - { - for (int i = 0; i < newUrls.length; i++) - { - urls.add(newUrls[i]); - addURLImpl(newUrls[i]); - } - } - - /** - * Look in both Attributes for a given value. The first Attributes - * object, if not null, has precedence. - */ - private String getAttributeValue(Attributes.Name name, Attributes first, - Attributes second) - { - String result = null; - if (first != null) - result = first.getValue(name); - if (result == null) - result = second.getValue(name); - return result; - } - - /** - * Defines a Package based on the given name and the supplied manifest - * information. The manifest indicates the title, version and - * vendor information of the specification and implementation and whether the - * package is sealed. If the Manifest indicates that the package is sealed - * then the Package will be sealed with respect to the supplied URL. - * - * @param name The name of the package - * @param manifest The manifest describing the specification, - * implementation and sealing details of the package - * @param url the code source url to seal the package - * @return the defined Package - * @throws IllegalArgumentException If this package name already exists - * in this class loader - */ - protected Package definePackage(String name, Manifest manifest, URL url) - throws IllegalArgumentException - { - // Compute the name of the package as it may appear in the - // Manifest. - StringBuffer xform = new StringBuffer(name); - for (int i = xform.length () - 1; i >= 0; --i) - if (xform.charAt(i) == '.') - xform.setCharAt(i, '/'); - xform.append('/'); - String xformName = xform.toString(); - - Attributes entryAttr = manifest.getAttributes(xformName); - Attributes attr = manifest.getMainAttributes(); - - String specTitle - = getAttributeValue(Attributes.Name.SPECIFICATION_TITLE, - entryAttr, attr); - String specVersion - = getAttributeValue(Attributes.Name.SPECIFICATION_VERSION, - entryAttr, attr); - String specVendor - = getAttributeValue(Attributes.Name.SPECIFICATION_VENDOR, - entryAttr, attr); - String implTitle - = getAttributeValue(Attributes.Name.IMPLEMENTATION_TITLE, - entryAttr, attr); - String implVersion - = getAttributeValue(Attributes.Name.IMPLEMENTATION_VERSION, - entryAttr, attr); - String implVendor - = getAttributeValue(Attributes.Name.IMPLEMENTATION_VENDOR, - entryAttr, attr); - - // Look if the Manifest indicates that this package is sealed - // XXX - most likely not completely correct! - // Shouldn't we also check the sealed attribute of the complete jar? - // http://java.sun.com/products/jdk/1.4/docs/guide/extensions/spec.html#bundled - // But how do we get that jar manifest here? - String sealed = attr.getValue(Attributes.Name.SEALED); - if ("false".equals(sealed)) - // make sure that the URL is null so the package is not sealed - url = null; - - return definePackage(name, - specTitle, specVendor, specVersion, - implTitle, implVendor, implVersion, - url); - } - - /** - * Finds (the first) class by name from one of the locations. The locations - * are searched in the order they were added to the URLClassLoader. - * - * @param className the classname to find - * @exception ClassNotFoundException when the class could not be found or - * loaded - * @return a Class object representing the found class - */ - protected Class findClass(final String className) - throws ClassNotFoundException - { - // Just try to find the resource by the (almost) same name - String resourceName = className.replace('.', '/') + ".class"; - Resource resource = findURLResource(resourceName); - if (resource == null) - throw new ClassNotFoundException(className + " not found in " + this); - - // Try to read the class data, create the CodeSource, Package and - // construct the class (and watch out for those nasty IOExceptions) - try - { - byte[] data; - InputStream in = resource.getInputStream(); - try - { - int length = resource.getLength(); - if (length != -1) - { - // We know the length of the data. - // Just try to read it in all at once - data = new byte[length]; - int pos = 0; - while (length - pos > 0) - { - int len = in.read(data, pos, length - pos); - if (len == -1) - throw new EOFException("Not enough data reading from: " - + in); - pos += len; - } - } - else - { - // We don't know the data length. - // Have to read it in chunks. - ByteArrayOutputStream out = new ByteArrayOutputStream(4096); - byte[] b = new byte[4096]; - int l = 0; - while (l != -1) - { - l = in.read(b); - if (l != -1) - out.write(b, 0, l); - } - data = out.toByteArray(); - } - } - finally - { - in.close(); - } - final byte[] classData = data; - - // Now get the CodeSource - final CodeSource source = resource.getCodeSource(); - - // Find out package name - String packageName = null; - int lastDot = className.lastIndexOf('.'); - if (lastDot != -1) - packageName = className.substring(0, lastDot); - - if (packageName != null && getPackage(packageName) == null) - { - // define the package - Manifest manifest = resource.loader.getManifest(); - if (manifest == null) - definePackage(packageName, null, null, null, null, null, null, - null); - else - definePackage(packageName, manifest, resource.loader.baseURL); - } - - // And finally construct the class! - SecurityManager sm = System.getSecurityManager(); - Class result = null; - if (sm != null && securityContext != null) - { - result = (Class)AccessController.doPrivileged - (new PrivilegedAction() - { - public Object run() - { - return defineClass(className, classData, - 0, classData.length, - source); - } - }, securityContext); - } - else - result = defineClass(className, classData, 0, classData.length, source); - - // Avoid NullPointerExceptions. - Certificate[] resourceCertificates = resource.getCertificates(); - if(resourceCertificates != null) - super.setSigners(result, resourceCertificates); - - return result; - } - catch (IOException ioe) - { - ClassNotFoundException cnfe; - cnfe = new ClassNotFoundException(className + " not found in " + this); - cnfe.initCause(ioe); - throw cnfe; - } - } - - // Cached String representation of this URLClassLoader - private String thisString; - - /** - * Returns a String representation of this URLClassLoader giving the - * actual Class name, the URLs that are searched and the parent - * ClassLoader. - */ - public String toString() - { - synchronized (this) - { - if (thisString == null) - { - StringBuffer sb = new StringBuffer(); - sb.append(this.getClass().getName()); - sb.append("{urls=[" ); - URL[] thisURLs = getURLs(); - for (int i = 0; i < thisURLs.length; i++) - { - sb.append(thisURLs[i]); - if (i < thisURLs.length - 1) - sb.append(','); - } - sb.append(']'); - sb.append(", parent="); - sb.append(getParent()); - sb.append('}'); - thisString = sb.toString(); - } - return thisString; - } - } - - /** - * Finds the first occurrence of a resource that can be found. The locations - * are searched in the order they were added to the URLClassLoader. - * - * @param resourceName the resource name to look for - * @return the URLResource for the resource if found, null otherwise - */ - private Resource findURLResource(String resourceName) - { - int max = urlinfos.size(); - for (int i = 0; i < max; i++) - { - URLLoader loader = (URLLoader) urlinfos.elementAt(i); - if (loader == null) - continue; - - Resource resource = loader.getResource(resourceName); - if (resource != null) - return resource; - } - return null; - } - - /** - * Finds the first occurrence of a resource that can be found. - * - * @param resourceName the resource name to look for - * @return the URL if found, null otherwise - */ - public URL findResource(String resourceName) - { - Resource resource = findURLResource(resourceName); - if (resource != null) - return resource.getURL(); - - // Resource not found - return null; - } - - /** - * If the URLStreamHandlerFactory has been set this return the appropriate - * URLStreamHandler for the given protocol, if not set returns null. - * - * @param protocol the protocol for which we need a URLStreamHandler - * @return the appropriate URLStreamHandler or null - */ - URLStreamHandler getURLStreamHandler(String protocol) - { - if (factory == null) - return null; - - URLStreamHandler handler; - synchronized (factoryCache) - { - // Check if there're handler for the same protocol in cache. - HashMap cache = (HashMap) factoryCache.get(factory); - handler = (URLStreamHandler) cache.get(protocol); - if (handler == null) - { - // Add it to cache. - handler = factory.createURLStreamHandler(protocol); - cache.put(protocol, handler); - } - } - return handler; - } - - /** - * Finds all the resources with a particular name from all the locations. - * - * @param resourceName the name of the resource to lookup - * @return a (possible empty) enumeration of URLs where the resource can be - * found - * @exception IOException when an error occurs accessing one of the - * locations - */ - public Enumeration findResources(String resourceName) - throws IOException - { - Vector resources = new Vector(); - int max = urlinfos.size(); - for (int i = 0; i < max; i++) - { - URLLoader loader = (URLLoader) urlinfos.elementAt(i); - Resource resource = loader.getResource(resourceName); - if (resource != null) - resources.add(resource.getURL()); - } - return resources.elements(); - } - - /** - * Returns the permissions needed to access a particular code - * source. These permissions includes those returned by - * <code>SecureClassLoader.getPermissions()</code> and the actual - * permissions to access the objects referenced by the URL of the - * code source. The extra permissions added depend on the protocol - * and file portion of the URL in the code source. If the URL has - * the "file" protocol ends with a '/' character then it must be a - * directory and a file Permission to read everything in that - * directory and all subdirectories is added. If the URL had the - * "file" protocol and doesn't end with a '/' character then it must - * be a normal file and a file permission to read that file is - * added. If the <code>URL</code> has any other protocol then a - * socket permission to connect and accept connections from the host - * portion of the URL is added. - * - * @param source The codesource that needs the permissions to be accessed - * @return the collection of permissions needed to access the code resource - * @see java.security.SecureClassLoader#getPermissions(CodeSource) - */ - protected PermissionCollection getPermissions(CodeSource source) - { - // XXX - This implementation does exactly as the Javadoc describes. - // But maybe we should/could use URLConnection.getPermissions()? - // First get the permissions that would normally be granted - PermissionCollection permissions = super.getPermissions(source); - - // Now add any extra permissions depending on the URL location. - URL url = source.getLocation(); - String protocol = url.getProtocol(); - if (protocol.equals("file")) - { - String file = url.getFile(); - - // If the file end in / it must be an directory. - if (file.endsWith("/") || file.endsWith(File.separator)) - { - // Grant permission to read everything in that directory and - // all subdirectories. - permissions.add(new FilePermission(file + "-", "read")); - } - else - { - // It is a 'normal' file. - // Grant permission to access that file. - permissions.add(new FilePermission(file, "read")); - } - } - else - { - // Grant permission to connect to and accept connections from host - String host = url.getHost(); - if (host != null) - permissions.add(new SocketPermission(host, "connect,accept")); - } - - return permissions; - } - - /** - * Returns all the locations that this class loader currently uses the - * resolve classes and resource. This includes both the initially supplied - * URLs as any URLs added later by the loader. - * @return All the currently used URLs - */ - public URL[] getURLs() - { - return (URL[]) urls.toArray(new URL[urls.size()]); - } - - /** - * Creates a new instance of a <code>URLClassLoader</code> that gets - * classes from the supplied <code>URL</code>s. This class loader - * will have as parent the standard system class loader. - * - * @param urls the initial URLs used to resolve classes and - * resources - * - * @return the class loader - * - * @exception SecurityException when the calling code does not have - * permission to access the given <code>URL</code>s - */ - public static URLClassLoader newInstance(URL[] urls) - throws SecurityException - { - return newInstance(urls, null); - } - - /** - * Creates a new instance of a <code>URLClassLoader</code> that gets - * classes from the supplied <code>URL</code>s and with the supplied - * loader as parent class loader. - * - * @param urls the initial URLs used to resolve classes and - * resources - * @param parent the parent class loader - * - * @return the class loader - * - * @exception SecurityException when the calling code does not have - * permission to access the given <code>URL</code>s - */ - public static URLClassLoader newInstance(URL[] urls, final ClassLoader parent) - throws SecurityException - { - SecurityManager sm = System.getSecurityManager(); - if (sm == null) - return new URLClassLoader(urls, parent); - else - { - final Object securityContext = sm.getSecurityContext(); - - // XXX - What to do with anything else then an AccessControlContext? - if (! (securityContext instanceof AccessControlContext)) - throw new SecurityException("securityContext must be AccessControlContext: " - + securityContext); - - URLClassLoader loader = - (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() - { - public Object run() - { - return new URLClassLoader(parent, - (AccessControlContext) securityContext); - } - }); - loader.addURLs(urls); - return loader; - } - } -} Modified: trunk/core/src/classpath/java/java/security/CodeSource.java =================================================================== --- trunk/core/src/classpath/java/java/security/CodeSource.java 2009-01-04 01:48:18 UTC (rev 4823) +++ trunk/core/src/classpath/java/java/security/CodeSource.java 2009-01-04 10:08:42 UTC (rev 4824) @@ -351,4 +351,28 @@ } } } + + //jnode openjdk + /** + * Constructs a CodeSource and associates it with the specified + * location and set of code signers. + * + * @param url the location (URL). + * @param signers the code signers. It may be null. The contents of the + * array are copied to protect against subsequent modification. + * + * @since 1.5 + */ + public CodeSource(URL url, CodeSigner[] signers) { + this.location = url; + + // Copy the supplied signers + if (signers != null) { + this.signers = signers.clone(); + } + } + /* + * The code signers. + */ + private transient CodeSigner[] signers = null; } // class CodeSource Added: trunk/core/src/openjdk/java/java/net/URLClassLoader.java =================================================================== --- trunk/core/src/openjdk/java/java/net/URLClassLoader.java (rev 0) +++ trunk/core/src/openjdk/java/java/net/URLClassLoader.java 2009-01-04 10:08:42 UTC (rev 4824) @@ -0,0 +1,617 @@ +/* + * Copyright 1997-2007 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.net; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.io.File; +import java.io.FilePermission; +import java.io.InputStream; +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandlerFactory; +import java.util.Enumeration; +import java.util.NoSuchElementException; +import java.util.StringTokenizer; +import java.util.jar.Manifest; +import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; +import java.security.CodeSigner; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.security.AccessController; +import java.security.AccessControlContext; +import java.security.SecureClassLoader; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import sun.misc.Resource; +import sun.misc.URLClassPath; +import sun.net.www.ParseUtil; +import sun.security.util.SecurityConstants; + +/** + * This class loader is used to load classes and resources from a search + * path of URLs referring to both JAR files and directories. Any URL that + * ends with a '/' is assumed to refer to a directory. Otherwise, the URL + * is assumed to refer to a JAR file which will be opened as needed. + * <p> + * The AccessControlContext of the thread that created the instance of + * URLClassLoader will be used when subsequently loading classes and + * resources. + * <p> + * The classes that are loaded are by default granted permission only to + * access the URLs specified when the URLClassLoader was created. + * + * @author David Connelly + * @since 1.2 + */ +public class URLClassLoader extends SecureClassLoader { + /* The search path for classes and resources */ + URLClassPath ucp; + + /* The context to be used when loading classes and resources */ + private AccessControlContext acc; + + /** + * Constructs a new URLClassLoader for the given URLs. The URLs will be + * searched in the order specified for classes and resources after first + * searching in the specified parent class loader. Any URL that ends with + * a '/' is assumed to refer to a directory. Otherwise, the URL is assumed + * to refer to a JAR file which will be downloaded and opened as needed. + * + * <p>If there is a security manager, this method first + * calls the security manager's <code>checkCreateClassLoader</code> method + * to ensure creation of a class loader is allowed. + * + * @param urls the URLs from which to load classes and resources + * @param parent the parent class loader for delegation + * @exception SecurityException if a security manager exists and its + * <code>checkCreateClassLoader</code> method doesn't allow + * creation of a class loader. + * @see SecurityManager#checkCreateClassLoader + */ + public URLClassLoader(URL[] urls, ClassLoader parent) { + super(parent); + // this is to make the stack depth consistent with 1.1 + SecurityManager security = System.getSecurityManager(); + if (security != null) { + security.checkCreateClassLoader(); + } + ucp = new URLClassPath(urls); + acc = AccessController.getContext(); + } + + /** + * Constructs a new URLClassLoader for the specified URLs using the + * default delegation parent <code>ClassLoader</code>. The URLs will + * be searched in the order specified for classes and resources after + * first searching in the parent class loader. Any URL that ends with + * a '/' is assumed to refer to a directory. Otherwise, the URL is + * assumed to refer to a JAR file which will be downloaded and opened + * as needed. + * + * <p>If there is a security manager, this method first + * calls the security manager's <code>checkCreateClassLoader</code> method + * to ensure creation of a class loader is allowed. + * + * @param urls the URLs from which to load classes and resources + * + * @exception SecurityException if a security manager exists and its + * <code>checkCreateClassLoader</code> method doesn't allow + * creation of a class loader. + * @see SecurityManager#checkCreateClassLoader + */ + public URLClassLoader(URL[] urls) { + super(); + // this is to make the stack depth consistent with 1.1 + SecurityManager security = System.getSecurityManager(); + if (security != null) { + security.checkCreateClassLoader(); + } + ucp = new URLClassPath(urls); + acc = AccessController.getContext(); + } + + /** + * Constructs a new URLClassLoader for the specified URLs, parent + * class loader, and URLStreamHandlerFactory. The parent argument + * will be used as the parent class loader for delegation. The + * factory argument will be used as the stream handler factory to + * obtain protocol handlers when creating new jar URLs. + * + * <p>If there is a security manager, this method first + * calls the security manager's <code>checkCreateClassLoader</code> method + * to ensure creation of a class loader is allowed. + * + * @param urls the URLs from which to load classes and resources + * @param parent the parent class loader for delegation + * @param factory the URLStreamHandlerFactory to use when creating URLs + * + * @exception SecurityException if a security manager exists and its + * <code>checkCreateClassLoader</code> method doesn't allow + * creation of a class loader. + * @see SecurityManager#checkCreateClassLoader + */ + public URLClassLoader(URL[] urls, ClassLoader parent, + URLStreamHandlerFactory factory) { + super(parent); + // this is to make the stack depth consistent with 1.1 + SecurityManager security = System.getSecurityManager(); + if (security != null) { + security.checkCreateClassLoader(); + } + ucp = new URLClassPath(urls, factory); + acc = AccessController.getContext(); + } + + /** + * Appends the specified URL to the list of URLs to search for + * classes and resources. + * + * @param url the URL to be added to the search path of URLs + */ + protected void addURL(URL url) { + ucp.addURL(url); + } + + /** + * Returns the search path of URLs for loading classes and resources. + * This includes the original list of URLs specified to the constructor, + * along with any URLs subsequently appended by the addURL() method. + * @return the search path of URLs for loading classes and resources. + */ + public URL[] getURLs() { + return ucp.getURLs(); + } + + /** + * Finds and loads the class with the specified name from the URL search + * path. Any URLs referring to JAR files are loaded and opened as needed + * until the class is found. + * + * @param name the name of the class + * @return the resulting class + * @exception ClassNotFoundException if the class could not be found + */ + protected Class<?> findClass(final String name) + throws ClassNotFoundException + { + try { + return (Class) + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws ClassNotFoundException { + String path = name.replace('.', '/').concat(".class"); + Resource res = ucp.getResource(path, false); + if (res != null) { + try { + return defineClass(name, res); + } catch (IOException e) { + throw new ClassNotFoundException(name, e); + } + } else { + throw new ClassNotFoundException(name); + } + } + }, acc); + } catch (java.security.PrivilegedActionException pae) { + throw (ClassNotFoundException) pae.getException(); + } + } + + /* + * Defines a Class using the class bytes obtained from the specified + * Resource. The resulting Class must be resolved before it can be + * used. + */ + private Class defineClass(String name, Resource res) throws IOException { + int i = name.lastIndexOf('.'); + URL url = res.getCodeSourceURL(); + if (i != -1) { + String pkgname = name.substring(0, i); + // Check if package already loaded. + Package pkg = getPackage(pkgname); + Manifest man = res.getManifest(); + if (pkg != null) { + // Package found, so check package sealing. + if (pkg.isSealed()) { + // Verify that code source URL is the same. + if (!pkg.isSealed(url)) { + throw new SecurityException( + "sealing violation: package " + pkgname + " is sealed"); + } + + } else { + // Make sure we are not attempting to seal the package + // at this code source URL. + if ((man != null) && isSealed(pkgname, man)) { + throw new SecurityException( + "sealing violation: can't seal package " + pkgname + + ": already loaded"); + } + } + } else { + if (man != null) { + definePackage(pkgname, man, url); + } else { + definePackage(pkgname, null, null, null, null, null, null, null); + } + } + } + // Now read the class bytes and define the class + java.nio.ByteBuffer bb = res.getByteBuffer(); + if (bb != null) { + // Use (direct) ByteBuffer: + CodeSigner[] signers = res.getCodeSigners(); + CodeSource cs = new CodeSource(url, signers); + return defineClass(name, bb, cs); + } else { + byte[] b = res.getBytes(); + // must read certificates AFTER reading bytes. + CodeSigner[] signers = res.getCodeSigners(); + CodeSource cs = new CodeSource(url, signers); + return defineClass(name, b, 0, b.length, cs); + } + } + + /** + * Defines a new package by name in this ClassLoader. The attributes + * contained in the specified Manifest will be used to obtain package + * version and sealing information. For sealed packages, the additional + * URL specifies the code source URL from which the package was loaded. + * + * @param name the package name + * @param man the Manifest containing package version and sealing + * information + * @param url the code source url for the package, or null if none + * @exception IllegalArgumentException if the package name duplicates + * an existing package either in this class loader or one + * of its ancestors + * @return the newly defined Package object + */ + protected Package definePackage(String name, Manifest man, URL url) + throws IllegalArgumentException + { + String path = name.replace('.', '/').concat("/"); + String specTitle = null, specVersion = null, specVendor = null; + String implTitle = null, implVersion = null, implVendor = null; + String sealed = null; + URL sealBase = null; + + Attributes attr = man.getAttributes(path); + if (attr != null) { + specTitle = attr.getValue(Name.SPECIFICATION_TITLE); + specVersion = attr.getValue(Name.SPECIFICATION_VERSION); + specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); + implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); + implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); + implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); + sealed = attr.getValue(Name.SEALED); + } + attr = man.getMainAttributes(); + if (attr != null) { + if (specTitle == null) { + specTitle = attr.getValue(Name.SPECIFICATION_TITLE); + } + if (specVersion == null) { + specVersion = attr.getValue(Name.SPECIFICATION_VERSION); + } + if (specVendor == null) { + specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); + } + if (implTitle == null) { + implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); + } + if (implVersion == null) { + implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); + } + if (implVendor == null) { + implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); + } + if (sealed == null) { + sealed = attr.getValue(Name.SEALED); + } + } + if ("true".equalsIgnoreCase(sealed)) { + sealBase = url; + } + return definePackage(name, specTitle, specVersion, specVendor, + implTitle, implVersion, implVendor, sealBase); + } + + /* + * Returns true if the specified package name is sealed according to the + * given manifest. + */ + private boolean isSealed(String name, Manifest man) { + String path = name.replace('.', '/').concat("/"); + Attributes attr = man.getAttributes(path); + String sealed = null; + if (attr != null) { + sealed = attr.getValue(Name.SEALED); + } + if (sealed == null) { + if ((attr = man.getMainAttributes()) != null) { + sealed = attr.getValue(Name.SEALED); + } + } + return "true".equalsIgnoreCase(sealed); + } + + /** + * Finds the resource with the specified name on the URL search path. + * + * @param name the name of the resource + * @return a <code>URL</code> for the resource, or <code>null</code> + * if the resource could not be found. + */ + public URL findResource(final String name) { + /* + * The same restriction to finding classes applies to resources + */ + URL url = + (URL) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return ucp.findResource(name, true); + } + }, acc); + + return url != null ? ucp.checkURL(url) : null; + } + + /** + * Returns an Enumeration of URLs representing all of the resources + * on the URL search path having the specified name. + * + * @param name the resource name + * @exception IOException if an I/O exception occurs + * @return an <code>Enumeration</code> of <code>URL</code>s + */ + public Enumeration<URL> findResources(final String name) + throws IOException + { + final Enumeration e = ucp.findResources(name, true); + + return new Enumeration<URL>() { + private URL url = null; + + private boolean next() { + if (url != null) { + return true; + } + do { + URL u = (URL) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ... [truncated message content] |
From: <ls...@us...> - 2009-01-04 16:31:57
|
Revision: 4828 http://jnode.svn.sourceforge.net/jnode/?rev=4828&view=rev Author: lsantha Date: 2009-01-04 16:31:52 +0000 (Sun, 04 Jan 2009) Log Message: ----------- VM interface cleanups. Modified Paths: -------------- trunk/core/src/classpath/vm/java/lang/Thread.java trunk/core/src/mmtk-vm/org/mmtk/vm/Strings.java trunk/core/src/openjdk/java/java/lang/System.java trunk/core/src/openjdk/vm/java/lang/NativeShutdown.java trunk/core/src/openjdk/vm/java/lang/NativeString.java trunk/core/src/openjdk/vm/java/lang/NativeSystem.java trunk/core/src/openjdk/vm/java/lang/NativeThrowable.java trunk/core/src/openjdk/vm/java/lang/reflect/NativeArray.java Removed Paths: ------------- trunk/core/src/classpath/java/java/lang/reflect/ trunk/core/src/classpath/vm/java/lang/VMCompiler.java trunk/core/src/classpath/vm/java/lang/VMDouble.java trunk/core/src/classpath/vm/java/lang/VMFloat.java trunk/core/src/classpath/vm/java/lang/VMMath.java trunk/core/src/classpath/vm/java/lang/VMObject.java trunk/core/src/classpath/vm/java/lang/VMString.java trunk/core/src/classpath/vm/java/lang/VMThrowable.java trunk/core/src/classpath/vm/java/lang/reflect/VMArray.java Modified: trunk/core/src/classpath/vm/java/lang/Thread.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/Thread.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/Thread.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -41,7 +41,6 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.HashMap; -import java.lang.reflect.Constructor; import org.jnode.security.JNodePermission; @@ -50,7 +49,6 @@ import org.jnode.vm.annotation.Internal; import org.jnode.vm.annotation.SharedStatics; import org.jnode.vm.classmgr.VmIsolatedStatics; -import org.jnode.vm.isolate.IsolateThread; import org.jnode.vm.scheduler.MonitorManager; import org.jnode.vm.scheduler.VmProcessor; import org.jnode.vm.scheduler.VmThread; @@ -1258,7 +1256,7 @@ if (!isAlive()) { return EMPTY_STACK_TRACE; } - return VMThrowable.backTrace2stackTrace(VmThread.getStackTrace(vmThread)); + return NativeThrowable.backTrace2stackTrace(VmThread.getStackTrace(vmThread)); } else { // Don't need JVM help for current thread return (new Exception()).getStackTrace(); @@ -1468,4 +1466,5 @@ // blocker = b; // } } + } Deleted: trunk/core/src/classpath/vm/java/lang/VMCompiler.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMCompiler.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMCompiler.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,94 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.lang; - -/** - * This class is just a per-VM reflection of java.lang.Compiler. All methods are - * defined identically. - */ -final class VMCompiler { - /** - * Don't allow new `Compiler's to be made. - */ - private VMCompiler() { - } - - /** - * Compile the class named by <code>oneClass</code>. - * - * @param oneClass - * the class to compile - * @return <code>false</code> if no compiler is available or compilation - * failed, <code>true</code> if compilation succeeded - * @throws NullPointerException - * if oneClass is null - */ - public static boolean compileClass(Class oneClass) { - // Never succeed. - return false; - } - - /** - * Compile the classes whose name matches <code>classNames</code>. - * - * @param classNames - * the name of classes to compile - * @return <code>false</code> if no compiler is available or compilation - * failed, <code>true</code> if compilation succeeded - * @throws NullPointerException - * if classNames is null - */ - public static boolean compileClasses(String classNames) { - // Note the incredibly lame interface. Always fail. - return false; - } - - /** - * This method examines the argument and performs an operation according to - * the compilers documentation. No specific operation is required. - * - * @param arg - * a compiler-specific argument - * @return a compiler-specific value, including null - * @throws NullPointerException - * if the compiler doesn't like a null arg - */ - public static Object command(Object arg) { - // Our implementation defines this to a no-op. - return null; - } - - /** - * Calling <code>Compiler.enable()</code> will cause the compiler to - * resume operation if it was previously disabled; provided that a compiler - * even exists. - */ - public static void enable() { - } - - /** - * Calling <code>Compiler.disable()</code> will cause the compiler to be - * suspended; provided that a compiler even exists. - */ - public static void disable() { - } -} Deleted: trunk/core/src/classpath/vm/java/lang/VMDouble.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMDouble.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMDouble.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,348 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.lang; - -import org.jnode.vm.VmMagic; -import org.jnode.vm.annotation.MagicPermission; - -/** - * VM specific double routines. - * - * @author Ewout Prangsma (ep...@us...) - */ -@MagicPermission -public final class VMDouble { - private char[] chars; - - private int length; - - private int index; - - /** - * Convert the double to the IEEE 754 floating-point "double format" bit - * layout. Bit 63 (the most significant) is the sign bit, bits 62-52 (masked - * by 0x7ff0000000000000L) represent the exponent, and bits 51-0 (masked by - * 0x000fffffffffffffL) are the mantissa. This function collapses all - * versions of NaN to 0x7ff8000000000000L. The result of this function can - * be used as the argument to <code>Double.longBitsToDouble(long)</code> - * to obtain the original <code>double</code> value. - * - * @param value - * the <code>double</code> to convert - * @return the bits of the <code>double</code> - * @see #longBitsToDouble(long) - */ - public static long doubleToLongBits(double value) { - if (Double.isNaN(value)) { - return 0x7ff8000000000000L; - } else { - return VmMagic.doubleToRawLongBits(value); - } - } - - /** - * Convert the double to the IEEE 754 floating-point "double format" bit - * layout. Bit 63 (the most significant) is the sign bit, bits 62-52 (masked - * by 0x7ff0000000000000L) represent the exponent, and bits 51-0 (masked by - * 0x000fffffffffffffL) are the mantissa. This function leaves NaN alone, - * rather than collapsing to a canonical value. The result of this function - * can be used as the argument to <code>Double.longBitsToDouble(long)</code> - * to obtain the original <code>double</code> value. - * - * @param value - * the <code>double</code> to convert - * @return the bits of the <code>double</code> - * @see #longBitsToDouble(long) - */ - public static long doubleToRawLongBits(double value) { - return VmMagic.doubleToRawLongBits(value); - } - - /** - * Convert the argument in IEEE 754 floating-point "double format" bit - * layout to the corresponding float. Bit 63 (the most significant) is the - * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the - * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa. - * This function leaves NaN alone, so that you can recover the bit pattern - * with <code>Double.doubleToRawLongBits(double)</code>. - * - * @param bits - * the bits to convert - * @return the <code>double</code> represented by the bits - * @see #doubleToLongBits(double) - * @see #doubleToRawLongBits(double) - */ - public static double longBitsToDouble(long bits) { - return VmMagic.longBitsToDouble(bits); - } - - private int parseUnsignedInt() throws NumberFormatException { - if (index >= length) - throw new NumberFormatException(); - - int start = index; - int value = 0; - - for (; index < length; index++) { - int d = Character.digit(chars[index], 10); - if (d < 0) - break; - value *= 10; - value += d; - } - - if (index == start) - throw new NumberFormatException(); - - return value; - } - - private int parseSignedInt() throws NumberFormatException { - if (index >= length) - throw new NumberFormatException(); - - char sign = ' '; - - switch (chars[index]) { - case '-': - sign = '-'; - index++; - break; - - case '+': - sign = '+'; - index++; - break; - } - - int value = parseUnsignedInt(); - - return (sign == '-') ? -value : value; - } - - private double parseFractionalPart(boolean nonEmpty) - throws NumberFormatException { - if (index >= length) - throw new NumberFormatException(); - - int start = index; - double value = 0.0d; - - for (; index < length; index++) { - int d = Character.digit(chars[index], 10); - if (d < 0) - break; - value += d; - value /= 10; - } - - if (nonEmpty && (index == start)) - throw new NumberFormatException(); - - return value; - } - - private double parseExponent(double value) throws NumberFormatException { - if (index >= chars.length) - return value; - - switch (chars[index]) { - case 'f': - case 'F': - case 'd': - case 'D': - return value; - - case 'e': - case 'E': - index++; - break; - - default: - throw new NumberFormatException(); - } - - int exponent = parseSignedInt(); - - char ch = 0; - if (index < chars.length && ((ch = chars[index]) != 'f' && ch != 'F' && ch != 'd' && ch != 'D')) - throw new NumberFormatException(); - - return value * Math.pow(10.0, exponent); - } - - public static double parseDouble(String s) { - return new VMDouble(s).parse(); - } - - public double parse() throws NumberFormatException { - if (index >= chars.length) - throw new NumberFormatException(); - - char sign = '+'; - - switch (chars[index]) { - case '-': - sign = '-'; - index++; - break; - - case '+': - sign = '+'; - index++; - break; - } - - if (index >= chars.length) - throw new NumberFormatException(); - - double value = 0; - - if (chars[index] == '.') { - index++; - value = parseFractionalPart(true); - value = parseExponent(value); - } else { - value = parseUnsignedInt(); - - if (index < chars.length){ - if(chars[index] == '.'){ - index++; - value += parseFractionalPart(false); - } - } - - - value = parseExponent(value); - } - - return (sign == '-') ? -value : value; - } - - public VMDouble(String s) { - chars = s.toCharArray(); - length = chars.length; - index = 0; - } - - /** - * Convert the <code>double</code> to a <code>String</code>. - * Floating-point string representation is fairly complex: here is a rundown - * of the possible values. "<code>[-]</code>" indicates that a negative - * sign will be printed if the value (or exponent) is negative. " - * <code><number></code>" means a string of digits ('0' to '9'). " - * <code><digit></code>" means a single digit ('0' to '9'). <br> - * - * <table border=1> - * <tr> - * <th>Value of Double</th> - * <th>String Representation</th> - * </tr> - * <tr> - * <td>[+-] 0</td> - * <td><code>[-]0.0</code></td> - * </tr> - * <tr> - * <td>Between [+-] 10 <sup>-3 </sup> and 10 <sup>7 </sup>, exclusive</td> - * <td><code>[-]number.number</code></td> - * </tr> - * <tr> - * <td>Other numeric value</td> - * <td><code>[-]<digit>.<number> - * E[-]<number></code> - * </td> - * </tr> - * <tr> - * <td>[+-] infinity</td> - * <td><code>[-]Infinity</code></td> - * </tr> - * <tr> - * <td>NaN</td> - * <td><code>NaN</code></td> - * </tr> - * </table> - * - * Yes, negative zero <em>is</em> a possible value. Note that there is - * <em>always</em> a <code>.</code> and at least one digit printed after - * it: even if the number is 3, it will be printed as <code>3.0</code>. - * After the ".", all digits will be printed except trailing zeros. The - * result is rounded to the shortest decimal number which will parse back to - * the same double. - * - * <p> - * To create other output formats, use {@link java.text.NumberFormat}. - * - * @XXX specify where we are not in accord with the spec. - * - * @param v - * the <code>double</code> to convert - * @return the <code>String</code> representing the <code>double</code> - */ - public static String toString(double v, boolean isFloat) { - - final int MAX_DIGITS = isFloat ? 10 : 19; - - if (Double.isNaN(v)) - return "NaN"; - if (v == Double.POSITIVE_INFINITY) - return "Infinity"; - if (v == Double.NEGATIVE_INFINITY) - return "-Infinity"; - - boolean negative = (doubleToLongBits(v) & (1L << 63)) != 0; - double m = negative ? -v : v; - - if (m == 0.0d) - return negative ? "-0.0" : "0.0"; - - StringBuffer result = new StringBuffer(MAX_DIGITS * 2); - if (negative) { - result.append('-'); - } - - if (m >= 1e-3 && m < 1e7) { - int digits = 0; - long digit = (long) (m - 0.5d); - result.append(digit); - result.append('.'); - m -= digit; - while ((m > 0.0d) && (digits < MAX_DIGITS)) { - m *= 10.0d; - digit = (long) (m - 0.5d); - m -= digit; - result.append(digit); - digits++; - } - if (digits == 0) { - result.append('0'); - } - } else { - int exponent = (int) (Math.log(m) / Math.log(10.0d)); - double mantissa = m / Math.pow(10.0d, exponent); - result.append(toString(mantissa, isFloat)); - result.append('E'); - result.append(Integer.toString(exponent)); - } - - return result.toString(); - } -} Deleted: trunk/core/src/classpath/vm/java/lang/VMFloat.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMFloat.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMFloat.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,97 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.lang; - -import org.jnode.vm.VmMagic; -import org.jnode.vm.annotation.MagicPermission; - -/* - * This class is a reference version, mainly for compiling a class library jar. - * It is likely that VM implementers replace this with their own version that - * can communicate effectively with the VM. - */ - -/** - * Code relocated from java.lang.Float by - * - * @author Dave Grove <gr...@us...> - */ -@MagicPermission -final class VMFloat { - /** - * Convert the float to the IEEE 754 floating-point "single format" bit - * layout. Bit 31 (the most significant) is the sign bit, bits 30-23 (masked - * by 0x7f800000) represent the exponent, and bits 22-0 (masked by - * 0x007fffff) are the mantissa. This function collapses all versions of NaN - * to 0x7fc00000. The result of this function can be used as the argument to - * <code>Float.intBitsToFloat(int)</code> to obtain the original - * <code>float</code> value. - * - * @param value - * the <code>float</code> to convert - * @return the bits of the <code>float</code> - * @see #intBitsToFloat(int) - */ - static int floatToIntBits(float value) { - if (Float.isNaN(value)) { - return 0x7fc00000; - } else { - return VmMagic.floatToRawIntBits(value); - } - } - - /** - * Convert the float to the IEEE 754 floating-point "single format" bit - * layout. Bit 31 (the most significant) is the sign bit, bits 30-23 (masked - * by 0x7f800000) represent the exponent, and bits 22-0 (masked by - * 0x007fffff) are the mantissa. This function leaves NaN alone, rather than - * collapsing to a canonical value. The result of this function can be used - * as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the - * original <code>float</code> value. - * - * @param value - * the <code>float</code> to convert - * @return the bits of the <code>float</code> - * @see #intBitsToFloat(int) - */ - static int floatToRawIntBits(float value) { - return VmMagic.floatToRawIntBits(value); - } - - /** - * Convert the argument in IEEE 754 floating-point "single format" bit - * layout to the corresponding float. Bit 31 (the most significant) is the - * sign bit, bits 30-23 (masked by 0x7f800000) represent the exponent, and - * bits 22-0 (masked by 0x007fffff) are the mantissa. This function leaves - * NaN alone, so that you can recover the bit pattern with - * <code>Float.floatToRawIntBits(float)</code>. - * - * @param bits - * the bits to convert - * @return the <code>float</code> represented by the bits - * @see #floatToIntBits(float) - * @see #floatToRawIntBits(float) - */ - static float intBitsToFloat(int bits) { - return VmMagic.intBitsToFloat(bits); - } -} // class VMFloat Deleted: trunk/core/src/classpath/vm/java/lang/VMMath.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMMath.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMMath.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,541 +0,0 @@ -/* VMMath.java -- Common mathematical functions. - Copyright (C) 2006 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 java.lang; - -import gnu.classpath.Configuration; - -class VMMath -{ - - static - { - if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary("javalang"); - } - } - - /** - * The trigonometric function <em>sin</em>. The sine of NaN or infinity is - * NaN, and the sine of 0 retains its sign. This is accurate within 1 ulp, - * and is semi-monotonic. - * - * @param a the angle (in radians) - * @return sin(a) - */ - public static double sin(double a) { - return StrictMath.sin(a); - } - - /** - * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is - * NaN. This is accurate within 1 ulp, and is semi-monotonic. - * - * @param a the angle (in radians) - * @return cos(a) - */ - public static double cos(double a) { - return StrictMath.cos(a); - } - - /** - * The trigonometric function <em>tan</em>. The tangent of NaN or infinity - * is NaN, and the tangent of 0 retains its sign. This is accurate within 1 - * ulp, and is semi-monotonic. - * - * @param a the angle (in radians) - * @return tan(a) - */ - public static double tan(double a) { - return StrictMath.tan(a); - } - - /** - * The trigonometric function <em>arcsin</em>. The range of angles returned - * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN or - * its absolute value is beyond 1, the result is NaN; and the arcsine of - * 0 retains its sign. This is accurate within 1 ulp, and is semi-monotonic. - * - * @param a the sin to turn back into an angle - * @return arcsin(a) - */ - public static double asin(double a) { - return StrictMath.asin(a); - } - - /** - * The trigonometric function <em>arccos</em>. The range of angles returned - * is 0 to pi radians (0 to 180 degrees). If the argument is NaN or - * its absolute value is beyond 1, the result is NaN. This is accurate - * within 1 ulp, and is semi-monotonic. - * - * @param a the cos to turn back into an angle - * @return arccos(a) - */ - public static double acos(double a) { - return StrictMath.acos(a); - } - - /** - * The trigonometric function <em>arcsin</em>. The range of angles returned - * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN, the - * result is NaN; and the arctangent of 0 retains its sign. This is accurate - * within 1 ulp, and is semi-monotonic. - * - * @param a the tan to turn back into an angle - * @return arcsin(a) - * @see #atan2(double, double) - */ - public static double atan(double a) { - return StrictMath.atan(a); - } - - /** - * A special version of the trigonometric function <em>arctan</em>, for - * converting rectangular coordinates <em>(x, y)</em> to polar - * <em>(r, theta)</em>. This computes the arctangent of x/y in the range - * of -pi to pi radians (-180 to 180 degrees). Special cases:<ul> - * <li>If either argument is NaN, the result is NaN.</li> - * <li>If the first argument is positive zero and the second argument is - * positive, or the first argument is positive and finite and the second - * argument is positive infinity, then the result is positive zero.</li> - * <li>If the first argument is negative zero and the second argument is - * positive, or the first argument is negative and finite and the second - * argument is positive infinity, then the result is negative zero.</li> - * <li>If the first argument is positive zero and the second argument is - * negative, or the first argument is positive and finite and the second - * argument is negative infinity, then the result is the double value - * closest to pi.</li> - * <li>If the first argument is negative zero and the second argument is - * negative, or the first argument is negative and finite and the second - * argument is negative infinity, then the result is the double value - * closest to -pi.</li> - * <li>If the first argument is positive and the second argument is - * positive zero or negative zero, or the first argument is positive - * infinity and the second argument is finite, then the result is the - * double value closest to pi/2.</li> - * <li>If the first argument is negative and the second argument is - * positive zero or negative zero, or the first argument is negative - * infinity and the second argument is finite, then the result is the - * double value closest to -pi/2.</li> - * <li>If both arguments are positive infinity, then the result is the - * double value closest to pi/4.</li> - * <li>If the first argument is positive infinity and the second argument - * is negative infinity, then the result is the double value closest to - * 3*pi/4.</li> - * <li>If the first argument is negative infinity and the second argument - * is positive infinity, then the result is the double value closest to - * -pi/4.</li> - * <li>If both arguments are negative infinity, then the result is the - * double value closest to -3*pi/4.</li> - * - * </ul><p>This is accurate within 2 ulps, and is semi-monotonic. To get r, - * use sqrt(x*x+y*y). - * - * @param y the y position - * @param x the x position - * @return <em>theta</em> in the conversion of (x, y) to (r, theta) - * @see #atan(double) - */ - public static double atan2(double y, double x) { - return StrictMath.atan2(y, x); - } - - /** - * Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the - * argument is NaN, the result is NaN; if the argument is positive infinity, - * the result is positive infinity; and if the argument is negative - * infinity, the result is positive zero. This is accurate within 1 ulp, - * and is semi-monotonic. - * - * @param a the number to raise to the power - * @return the number raised to the power of <em>e</em> - * @see #log(double) - * @see #pow(double, double) - */ - public static double exp(double a) { - return StrictMath.exp(a); - } - - /** - * Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the - * argument is NaN or negative, the result is NaN; if the argument is - * positive infinity, the result is positive infinity; and if the argument - * is either zero, the result is negative infinity. This is accurate within - * 1 ulp, and is semi-monotonic. - * - * <p>Note that the way to get log<sub>b</sub>(a) is to do this: - * <code>ln(a) / ln(b)</code>. - * - * @param a the number to take the natural log of - * @return the natural log of <code>a</code> - * @see #exp(double) - */ - public static double log(double a) { - return StrictMath.log(a); - } - - /** - * Take a square root. If the argument is NaN or negative, the result is - * NaN; if the argument is positive infinity, the result is positive - * infinity; and if the result is either zero, the result is the same. - * This is accurate within the limits of doubles. - * - * <p>For other roots, use pow(a, 1 / rootNumber). - * - * @param a the numeric argument - * @return the square root of the argument - * @see #pow(double, double) - */ - public static double sqrt(double a) { - return StrictMath.sqrt(a); - } - - /** - * Raise a number to a power. Special cases:<ul> - * <li>If the second argument is positive or negative zero, then the result - * is 1.0.</li> - * <li>If the second argument is 1.0, then the result is the same as the - * first argument.</li> - * <li>If the second argument is NaN, then the result is NaN.</li> - * <li>If the first argument is NaN and the second argument is nonzero, - * then the result is NaN.</li> - * <li>If the absolute value of the first argument is greater than 1 and - * the second argument is positive infinity, or the absolute value of the - * first argument is less than 1 and the second argument is negative - * infinity, then the result is positive infinity.</li> - * <li>If the absolute value of the first argument is greater than 1 and - * the second argument is negative infinity, or the absolute value of the - * first argument is less than 1 and the second argument is positive - * infinity, then the result is positive zero.</li> - * <li>If the absolute value of the first argument equals 1 and the second - * argument is infinite, then the result is NaN.</li> - * <li>If the first argument is positive zero and the second argument is - * greater than zero, or the first argument is positive infinity and the - * second argument is less than zero, then the result is positive zero.</li> - * <li>If the first argument is positive zero and the second argument is - * less than zero, or the first argument is positive infinity and the - * second argument is greater than zero, then the result is positive - * infinity.</li> - * <li>If the first argument is negative zero and the second argument is - * greater than zero but not a finite odd integer, or the first argument is - * negative infinity and the second argument is less than zero but not a - * finite odd integer, then the result is positive zero.</li> - * <li>If the first argument is negative zero and the second argument is a - * positive finite odd integer, or the first argument is negative infinity - * and the second argument is a negative finite odd integer, then the result - * is negative zero.</li> - * <li>If the first argument is negative zero and the second argument is - * less than zero but not a finite odd integer, or the first argument is - * negative infinity and the second argument is greater than zero but not a - * finite odd integer, then the result is positive infinity.</li> - * <li>If the first argument is negative zero and the second argument is a - * negative finite odd integer, or the first argument is negative infinity - * and the second argument is a positive finite odd integer, then the result - * is negative infinity.</li> - * <li>If the first argument is less than zero and the second argument is a - * finite even integer, then the result is equal to the result of raising - * the absolute value of the first argument to the power of the second - * argument.</li> - * <li>If the first argument is less than zero and the second argument is a - * finite odd integer, then the result is equal to the negative of the - * result of raising the absolute value of the first argument to the power - * of the second argument.</li> - * <li>If the first argument is finite and less than zero and the second - * argument is finite and not an integer, then the result is NaN.</li> - * <li>If both arguments are integers, then the result is exactly equal to - * the mathematical result of raising the first argument to the power of - * the second argument if that result can in fact be represented exactly as - * a double value.</li> - * - * </ul><p>(In the foregoing descriptions, a floating-point value is - * considered to be an integer if and only if it is a fixed point of the - * method {@link #ceil(double)} or, equivalently, a fixed point of the - * method {@link #floor(double)}. A value is a fixed point of a one-argument - * method if and only if the result of applying the method to the value is - * equal to the value.) This is accurate within 1 ulp, and is semi-monotonic. - * - * @param a the number to raise - * @param b the power to raise it to - * @return a<sup>b</sup> - */ - public static double pow(double a, double b) { - return StrictMath.pow(a, b); - } - - /** - * Get the IEEE 754 floating point remainder on two numbers. This is the - * value of <code>x - y * <em>n</em></code>, where <em>n</em> is the closest - * double to <code>x / y</code> (ties go to the even n); for a zero - * remainder, the sign is that of <code>x</code>. If either argument is NaN, - * the first argument is infinite, or the second argument is zero, the result - * is NaN; if x is finite but y is infinite, the result is x. This is - * accurate within the limits of doubles. - * - * @param x the dividend (the top half) - * @param y the divisor (the bottom half) - * @return the IEEE 754-defined floating point remainder of x/y - * @see #rint(double) - */ - public static double IEEEremainder(double x, double y) { - return StrictMath.IEEEremainder(x, y); - } - - /** - * Take the nearest integer that is that is greater than or equal to the - * argument. If the argument is NaN, infinite, or zero, the result is the - * same; if the argument is between -1 and 0, the result is negative zero. - * Note that <code>Math.ceil(x) == -Math.floor(-x)</code>. - * - * @param a the value to act upon - * @return the nearest integer >= <code>a</code> - */ - public static double ceil(double a) { - return StrictMath.ceil(a); - } - - /** - * Take the nearest integer that is that is less than or equal to the - * argument. If the argument is NaN, infinite, or zero, the result is the - * same. Note that <code>Math.ceil(x) == -Math.floor(-x)</code>. - * - * @param a the value to act upon - * @return the nearest integer <= <code>a</code> - */ - public static double floor(double a) { - return StrictMath.floor(a); - } - - /** - * Take the nearest integer to the argument. If it is exactly between - * two integers, the even integer is taken. If the argument is NaN, - * infinite, or zero, the result is the same. - * - * @param a the value to act upon - * @return the nearest integer to <code>a</code> - */ - public static double rint(double a) { - return StrictMath.rint(a); - } - - /** - * <p> - * Take a cube root. If the argument is NaN, an infinity or zero, then - * the original value is returned. The returned result must be within 1 ulp - * of the exact result. For a finite value, <code>x</code>, the cube root - * of <code>-x</code> is equal to the negation of the cube root - * of <code>x</code>. - * </p> - * <p> - * For a square root, use <code>sqrt</code>. For other roots, use - * <code>pow(a, 1 / rootNumber)</code>. - * </p> - * - * @param a the numeric argument - * @return the cube root of the argument - * @see #sqrt(double) - * @see #pow(double, double) - */ - public static double cbrt(double a) { - return StrictMath.cbrt(a); - } - - /** - * <p> - * Returns the hyperbolic cosine of the given value. For a value, - * <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> + - * e<sup>-x</sup>)/2</code> - * with <code>e</code> being <a href="#E">Euler's number</a>. The returned - * result must be within 2.5 ulps of the exact result. - * </p> - * <p> - * If the supplied value is <code>NaN</code>, then the original value is - * returned. For either infinity, positive infinity is returned. - * The hyperbolic cosine of zero must be 1.0. - * </p> - * - * @param a the numeric argument - * @return the hyperbolic cosine of <code>a</code>. - * @since 1.5 - */ - public static double cosh(double a) { - return StrictMath.cosh(a); - } - - /** - * <p> - * Returns <code>e<sup>a</sup> - 1. For values close to 0, the - * result of <code>expm1(a) + 1</code> tend to be much closer to the - * exact result than simply <code>exp(x)</code>. The result must be within - * 1 ulp of the exact result, and results must be semi-monotonic. For finite - * inputs, the returned value must be greater than or equal to -1.0. Once - * a result enters within half a ulp of this limit, the limit is returned. - * </p> - * <p> - * For <code>NaN</code>, positive infinity and zero, the original value - * is returned. Negative infinity returns a result of -1.0 (the limit). - * </p> - * - * @param a the numeric argument - * @return <code>e<sup>a</sup> - 1</code> - * @since 1.5 - */ - public static double expm1(double a) { - return StrictMath.expm1(a); - } - - /** - * <p> - * Returns the hypotenuse, <code>a<sup>2</sup> + b<sup>2</sup></code>, - * without intermediate overflow or underflow. The returned result must be - * within 1 ulp of the exact result. If one parameter is held constant, - * then the result in the other parameter must be semi-monotonic. - * </p> - * <p> - * If either of the arguments is an infinity, then the returned result - * is positive infinity. Otherwise, if either argument is <code>NaN</code>, - * then <code>NaN</code> is returned. - * </p> - * - * @param a the first parameter. - * @param b the second parameter. - * @return the hypotenuse matching the supplied parameters. - * @since 1.5 - */ - public static double hypot(double a, double b) { - //todo fix it according to the documantation - return a*a + b*b; - } - - /** - * <p> - * Returns the base 10 logarithm of the supplied value. The returned - * result must within 1 ulp of the exact result, and the results must be - * semi-monotonic. - * </p> - * <p> - * Arguments of either <code>NaN</code> or less than zero return - * <code>NaN</code>. An argument of positive infinity returns positive - * infinity. Negative infinity is returned if either positive or negative - * zero is supplied. Where the argument is the result of - * <code>10<sup>n</sup</code>, then <code>n</code> is returned. - * </p> - * - * @param a the numeric argument. - * @return the base 10 logarithm of <code>a</code>. - * @since 1.5 - */ - public static double log10(double a) { - //todo fix it according to the documantation - return log(a)/log(10); - } - - /** - * <p> - * Returns the natural logarithm resulting from the sum of the argument, - * <code>a</code> and 1. For values close to 0, the - * result of <code>log1p(a)</code> tend to be much closer to the - * exact result than simply <code>log(1.0+a)</code>. The returned - * result must be within 1 ulp of the exact result, and the results must be - * semi-monotonic. - * </p> - * <p> - * Arguments of either <code>NaN</code> or less than -1 return - * <code>NaN</code>. An argument of positive infinity or zero - * returns the original argument. Negative infinity is returned from an - * argument of -1. - * </p> - * - * @param a the numeric argument. - * @return the natural logarithm of <code>a</code> + 1. - * @since 1.5 - */ - public static double log1p(double a) { - //todo fix it according to the documantation - return log(a + 1); - } - - /** - * <p> - * Returns the hyperbolic sine of the given value. For a value, - * <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> - - * e<sup>-x</sup>)/2</code> - * with <code>e</code> being <a href="#E">Euler's number</a>. The returned - * result must be within 2.5 ulps of the exact result. - * </p> - * <p> - * If the supplied value is <code>NaN</code>, an infinity or a zero, then the - * original value is returned. - * </p> - * - * @param a the numeric argument - * @return the hyperbolic sine of <code>a</code>. - * @since 1.5 - */ - public static double sinh(double a) { - return StrictMath.sinh(a); - } - - /** - * <p> - * Returns the hyperbolic tangent of the given value. For a value, - * <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> - - * e<sup>-x</sup>)/(e<sup>x</sup> + e<sup>-x</sup>)</code> - * (i.e. <code>sinh(a)/cosh(a)</code>) - * with <code>e</code> being <a href="#E">Euler's number</a>. The returned - * result must be within 2.5 ulps of the exact result. The absolute value - * of the exact result is always less than 1. Computed results are thus - * less than or equal to 1 for finite arguments, with results within - * half a ulp of either positive or negative 1 returning the appropriate - * limit value (i.e. as if the argument was an infinity). - * </p> - * <p> - * If the supplied value is <code>NaN</code> or zero, then the original - * value is returned. Positive infinity returns +1.0 and negative infinity - * returns -1.0. - * </p> - * - * @param a the numeric argument - * @return the hyperbolic tangent of <code>a</code>. - * @since 1.5 - */ - public static double tanh(double a) { - return StrictMath.tanh(a); - } -} Deleted: trunk/core/src/classpath/vm/java/lang/VMObject.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMObject.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMObject.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,106 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.lang; - -import org.jnode.vm.VmSystem; -import org.jnode.vm.scheduler.MonitorManager; - -/** - * Object is the ultimate superclass of every class (excepting interfaces). As - * such, it needs help from the VM. - * - * @author John Keiser - * @author Eric Blake <eb...@em...> - */ -final class VMObject { - - /** - * Gets the class of a given object. - * @param o - * @return - */ - public static Class getClass(Object o) { - return VmSystem.getClass(o); - } - - /** - * The VM is expected to make a field-for-field shallow copy of the - * argument. Thus, the copy has the same runtime type as the argument. Note, - * however, that the cloned object must still be finalizable, even if the - * original has already had finalize() invoked on it. - * - * @param c - * the Cloneable to clone - * @return the clone - */ - static Object clone(Cloneable c) { - return VmSystem.clone(c); - } - - /** - * Wakes up one of the threads that is waiting on this Object's monitor. - * Only the owner of a lock on the Object may call this method. The Thread - * to wake up is chosen arbitrarily. - * - * @param o the object doing the notify - * @throw IllegalMonitorStateException if this Thread does not own the - * lock on the Object - */ - static void notify(Object o) throws IllegalMonitorStateException { - MonitorManager.notify(o); - } - - /** - * Wakes up all of the threads waiting on this Object's monitor. Only the - * owner of the lock on this Object may call this method. - * - * @param o - * the object doing the notifyAll - * @throws IllegalMonitorStateException - * if this Thread does not own the lock on the Object - */ - static void notifyAll(Object o) throws IllegalMonitorStateException { - MonitorManager.notifyAll(o); - } - - /** - * Waits a specified amount of time for notify() or notifyAll() to be called - * on this Object. The VM does not have to pay attention to the ns argument, - * if it does not have that much granularity. - * - * @param o - * the object to suspend on - * @param ms - * milliseconds to wait (1,000 milliseconds = 1 second) - * @param ns - * nanoseconds to wait beyond ms (1,000,000 nanoseconds == 1 - * millisecond) - * @throws IllegalMonitorStateException - * if this Thread does not own the lock on the Object - * @throws InterruptedException - * if some other Thread interrupts this Thread - */ - static void wait(Object o, long ms, int ns) - throws IllegalMonitorStateException, InterruptedException { - MonitorManager.wait(o, ms); - } -} Deleted: trunk/core/src/classpath/vm/java/lang/VMString.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMString.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMString.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,75 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.lang; - -import java.lang.ref.WeakReference; -import java.util.WeakHashMap; -import org.jnode.vm.annotation.SharedStatics; - -/* - * This class is a reference version, mainly for compiling a class library jar. - * It is likely that VM implementers replace this with their own version that - * can communicate effectively with the VM. - */ - -/** - * Code relocated from java.lang.String by - * - * @author Dave Grove <gr...@us...> - */ -@SharedStatics -final class VMString { - - /** - * Holds the references for each intern()'d String. If all references to the - * string disappear, and the VM properly supports weak references, the - * String will be GC'd. - */ - private static final WeakHashMap<String, WeakReference<String>> internTable = new WeakHashMap<String, WeakReference<String>>(); - - /** - * Fetches this String from the intern hashtable. If two Strings are - * considered equal, by the equals() method, then intern() will return the - * same String instance. ie. if (s1.equals(s2)) then (s1.intern() == - * s2.intern()). All string literals and string-valued constant expressions - * are already interned. - * - * @param str - * the String to intern - * @return the interned String - */ - static String intern(String str) { - synchronized (internTable) { - final WeakReference<String> ref = internTable.get(str); - if (ref != null) { - final String s = ref.get(); - // If s is null, then no strong references exist to the String; - // the weak hash map will soon delete the key. - if (s != null) { - return s; - } - } - internTable.put(str, new WeakReference<String>(str)); - } - return str; - } -} Deleted: trunk/core/src/classpath/vm/java/lang/VMThrowable.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/VMThrowable.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/VMThrowable.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,100 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.lang; - -import org.jnode.vm.VmStackFrame; -import org.jnode.vm.classmgr.VmMethod; -import org.jnode.vm.classmgr.VmType; -import org.jnode.vm.scheduler.VmProcessor; -import org.jnode.vm.scheduler.VmThread; - -/** - * VM dependant state and support methods for Throwable. - * It is deliberately package local and final and should only be accessed - * by the Throwable class. - * <p> - * This is the GNU Classpath reference implementation, it should be adapted - * for a specific VM. The reference implementation does nothing. - * - * @author Mark Wielaard (ma...@kl...) - */ -final class VMThrowable -{ - /** - * VM private data. - */ - private transient Object vmdata; - private Object[] backtrace; - - /** - * Private contructor, create VMThrowables with fillInStackTrace(); - */ - private VMThrowable() { } - - /** - * Fill in the stack trace with the current execution stack. - * Called by <code>Throwable.fillInStackTrace()</code> to get the state of - * the VM. Can return null when the VM does not support caputing the VM - * execution state. - * - * @return a new VMThrowable containing the current execution stack trace. - * @see Throwable#fillInStackTrace() - */ - static VMThrowable fillInStackTrace(Throwable t) - { - VMThrowable vmt = new VMThrowable(); - vmt.backtrace = VmThread.getStackTrace(VmProcessor.current().getCurrentThread()); - return vmt; - - } - - /** - * Returns an <code>StackTraceElement</code> array based on the execution - * state of the VM as captured by <code>fillInStackTrace</code>. - * Called by <code>Throwable.getStackTrace()</code>. - * - * @return a non-null but possible zero length array of StackTraceElement. - * @see Throwable#getStackTrace() - */ - StackTraceElement[] getStackTrace(Throwable t) - { - return backTrace2stackTrace(backtrace); - } - - static StackTraceElement[] backTrace2stackTrace(Object[] backtrace) { - final VmStackFrame[] vm_trace = (VmStackFrame[]) backtrace; - final int length = vm_trace.length; - final StackTraceElement[] trace = new StackTraceElement[length]; - for(int i = length; i-- > 0; ){ - final VmStackFrame frame = vm_trace[i]; - final String location = frame.getLocationInfo(); - final int lineNumber = "?".equals(location) ? -1 : Integer.parseInt(location); - final VmMethod method = frame.getMethod(); - final VmType<?> vmClass = (method == null) ? null : method.getDeclaringClass(); - final String fname = (vmClass == null) ? null : vmClass.getSourceFile(); - final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); - final String mname = (method == null) ? "<unknown method>" : method.getName(); - trace[i] = new StackTraceElement(cname, mname, fname, method == null || method.isNative() ? -2 : lineNumber); - } - return trace; - } -} Deleted: trunk/core/src/classpath/vm/java/lang/reflect/VMArray.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/reflect/VMArray.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/classpath/vm/java/lang/reflect/VMArray.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -1,91 +0,0 @@ -/* java.lang.reflect.VMArray - VM class for array manipulation by reflection. - Copyright (C) 1998, 1999, 2001, 2003, 2005 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 java.lang.reflect; - -import gnu.classpath.Configuration; -import org.jnode.vm.classmgr.VmType; -import org.jnode.vm.classmgr.VmClassLoader; -import org.jnode.vm.classmgr.VmArrayClass; -import org.jnode.vm.Vm; -import java.security.AccessController; -import java.security.PrivilegedAction; - -class VMArray -{ - - static - { - if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary("javalangreflect"); - } - } - - /** - * Dynamically create an array of objects. - * - * @param type guaranteed to be a valid object type - * @param dim the length of the array - * @return the new array - * @throws NegativeArraySizeException if dim is negative - * @throws OutOfMemoryError if memory allocation fails - */ - static Object createObjectArray(final Class type, int dim) { - final VmType vmClass = AccessController.doPrivileged( - new PrivilegedAction<VmType>() { - public VmType run() { - return VmType.fromClass(type); - } - }); - - final String arrClsName = vmClass.getArrayClassName(); - final VmType arrCls; - try { - final VmClassLoader curLoader = vmClass.getLoader(); - arrCls = curLoader.loadClass(arrClsName, true); - if (arrCls == null) { - throw new NoClassDefFoundError(arrClsName); - } - } catch (ClassNotFoundException ex) { - throw new NoClassDefFoundError(arrClsName); - } - - return Vm.getHeapManager().newArray((VmArrayClass) arrCls, dim); - } -} Modified: trunk/core/src/mmtk-vm/org/mmtk/vm/Strings.java =================================================================== --- trunk/core/src/mmtk-vm/org/mmtk/vm/Strings.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/mmtk-vm/org/mmtk/vm/Strings.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -34,7 +34,7 @@ } public static float parseFloat(String value) { - return (float)VMDouble.parseDouble(value); + return (float)Double.parseDouble(value); } /** Modified: trunk/core/src/openjdk/java/java/lang/System.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/System.java 2009-01-04 14:07:46 UTC (rev 4827) +++ trunk/core/src/openjdk/java/java/lang/System.java 2009-01-04 16:31:52 UTC (rev 4828) @@ -27,10 +27,8 @@ import java.io.*; import java.util.Properties; import java.util.PropertyPermission; -import java.util.StringTokenizer; import java.security.AccessController; import java.security.PrivilegedAction; -import java.security.AllPermission; import java.nio.channels.Channel; import java.nio.channels.spi.SelectorProvider; import sun.nio.ch.Interruptible; @@ -39,6 +37,8 @@ import sun.security.util.SecurityConstants; import sun.reflect.annotation.AnnotationType; import gnu.classpath.SystemProperties; +import org.jnode.util.SystemInputStream; +import org.jnode.vm.VmSystem; /** * The <code>System</code> class contains several useful class fields @@ -71,8 +71,9 @@ * corresponds to keyboard input or another input source specified by * the host environment or user. */ - public final static InputStream in = VMSystem.makeStandardInputStream();//jnode nullInputStream(); + public final static InputStream in = SystemInputStream.getInstance();//jnode nullInputStream(); + /** * The "standard" output stream. This stream is already * open and ready to accept output data. Typically this stream @@ -98,8 +99,9 @@ * @see java.io.PrintStream#println(java.lang.Object) * @see java.io.PrintStream#println(java.lang.String) */ - public final static PrintStream out = VMSystem.makeStandardOutputStream();//jnode nullPrintStream(); + public final static PrintStream out = VmSystem.getSy... [truncated message content] |
From: <fd...@us...> - 2009-01-17 21:25:55
|
Revision: 4881 http://jnode.svn.sourceforge.net/jnode/?rev=4881&view=rev Author: fduminy Date: 2009-01-17 21:25:50 +0000 (Sat, 17 Jan 2009) Log Message: ----------- - bug fix from Peter Barth (StackException in floating point computations) - added test for the above bug Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java Added Paths: ----------- trunk/core/src/test/org/jnode/test/TestFPStackException.java Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java 2009-01-17 19:11:28 UTC (rev 4880) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java 2009-01-17 21:25:50 UTC (rev 4881) @@ -1,5 +1,4 @@ /* - * $Id$ * * JNode.org * Copyright (C) 2003-2006 JNode.org @@ -23,7 +22,6 @@ import java.util.HashMap; import java.util.Map; - import org.jnode.assembler.Label; import org.jnode.assembler.NativeStream; import org.jnode.assembler.x86.X86Assembler; @@ -1937,7 +1935,7 @@ if (isfloat) { result = ifac.createFPUStack(JvmType.FLOAT); os.writeFLD32(refr, fieldOffset); - vstack.fpuStack.push(result); + pushFloat(result); } else { final char fieldType = field.getSignature().charAt(0); final WordItem iw = L1AHelper.requestWordRegister(eContext, @@ -1970,7 +1968,7 @@ if (isfloat) { result = ifac.createFPUStack(JvmType.DOUBLE); os.writeFLD64(refr, fieldOffset); - vstack.fpuStack.push(result); + pushFloat(result); } else { final DoubleWordItem idw = L1AHelper .requestDoubleWordRegisters(eContext, type); @@ -2022,7 +2020,7 @@ L1AHelper.releaseRegister(eContext, tmp); } final Item result = ifac.createFPUStack(type); - vstack.fpuStack.push(result); + pushFloat(result); vstack.push(result); } else if (!fieldRef.isWide()) { final WordItem result = L1AHelper.requestWordRegister(eContext, @@ -4550,4 +4548,13 @@ } return _curInstrLabel; } + + private void pushFloat(Item floatItem) { + // TODO should we do the same check for all calls to vstack.fpuStack.push(Item) ? + if (!vstack.fpuStack.hasCapacity(1)) { + vstack.push(eContext); + } + + vstack.fpuStack.push(floatItem); + } } Added: trunk/core/src/test/org/jnode/test/TestFPStackException.java =================================================================== --- trunk/core/src/test/org/jnode/test/TestFPStackException.java (rev 0) +++ trunk/core/src/test/org/jnode/test/TestFPStackException.java 2009-01-17 21:25:50 UTC (rev 4881) @@ -0,0 +1,58 @@ +package org.jnode.test; + +public class TestFPStackException { + public static void main(String[] args) { + System.out.println("creating instances"); + Matrix m = new Matrix(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0); + Matrix m2 = new Matrix(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0); + + System.out.println("calling times(...)"); + + // without bug fix, here the jnode compiler will fail with a org.jnode.vm.bytecode.StackException + Matrix m3 = m.times(m2); + + System.out.println("end"); + } + + private static class Matrix { + private double m11, m12, m13, m14; + private double m21, m22, m23, m24; + private double m31, m32, m33, m34; + private double m41, m42, m43, m44; + + public Matrix(double e11, double e12, double e13, double e14, double e21, double e22, double e23, + double e24, double e31, double e32, double e33, double e34, double e41, double e42, + double e43, double e44) { + m11 = e11; + m12 = e12; + m13 = e13; + m14 = e14; + m21 = e21; + m22 = e22; + m23 = e23; + m24 = e24; + m31 = e31; + m32 = e32; + m33 = e33; + m34 = e34; + m41 = e41; + m42 = e42; + m43 = e43; + m44 = e44; + } + + public final Matrix times(Matrix a) { + return new Matrix(m11 * a.m11 + m12 * a.m21 + m13 * a.m31 + m14 * a.m41, m11 * a.m12 + m12 * + a.m22 + m13 * a.m32 + m14 * a.m42, m11 * a.m13 + m12 * a.m23 + m13 * a.m33 + m14 * + a.m43, m11 * a.m14 + m12 * a.m24 + m13 * a.m34 + m14 * a.m44, m21 * a.m11 + m22 * + a.m21 + m23 * a.m31 + m24 * a.m41, m21 * a.m12 + m22 * a.m22 + m23 * a.m32 + m24 * + a.m42, m21 * a.m13 + m22 * a.m23 + m23 * a.m33 + m24 * a.m43, m21 * a.m14 + m22 * + a.m24 + m23 * a.m34 + m24 * a.m44, m31 * a.m11 + m32 * a.m21 + m33 * a.m31 + m34 * + a.m41, m31 * a.m12 + m32 * a.m22 + m33 * a.m32 + m34 * a.m42, m31 * a.m13 + m32 * + a.m23 + m33 * a.m33 + m34 * a.m43, m31 * a.m14 + m32 * a.m24 + m33 * a.m34 + m34 * + a.m44, m41 * a.m11 + m42 * a.m21 + m43 * a.m31 + m44 * a.m41, m41 * a.m12 + m42 * + a.m22 + m43 * a.m32 + m44 * a.m42, m41 * a.m13 + m42 * a.m23 + m43 * a.m33 + m44 * + a.m43, m41 * a.m14 + m42 * a.m24 + m43 * a.m34 + m44 * a.m44); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-01 20:10:23
|
Revision: 4960 http://jnode.svn.sourceforge.net/jnode/?rev=4960&view=rev Author: lsantha Date: 2009-02-01 20:10:09 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Fixed headers. Modified Paths: -------------- trunk/core/src/classpath/ext/java/nio/channels/LinkChannel.java trunk/core/src/classpath/ext/java/util/prefs/TransientPreferences.java trunk/core/src/classpath/ext/javax/cache/Cache.java trunk/core/src/classpath/ext/javax/cache/CacheEntry.java trunk/core/src/classpath/ext/javax/cache/CacheException.java trunk/core/src/classpath/ext/javax/cache/CacheFactory.java trunk/core/src/classpath/ext/javax/cache/CacheListener.java trunk/core/src/classpath/ext/javax/cache/CacheLoader.java trunk/core/src/classpath/ext/javax/cache/CacheManager.java trunk/core/src/classpath/ext/javax/cache/CacheStatistics.java trunk/core/src/classpath/ext/javax/cache/EvictionStrategy.java trunk/core/src/classpath/ext/javax/isolate/AbstractLinkMessageHandler.java trunk/core/src/classpath/ext/javax/isolate/ClosedLinkException.java trunk/core/src/classpath/ext/javax/isolate/Isolate.java trunk/core/src/classpath/ext/javax/isolate/IsolatePermission.java trunk/core/src/classpath/ext/javax/isolate/IsolateStartupException.java trunk/core/src/classpath/ext/javax/isolate/IsolateStatus.java trunk/core/src/classpath/ext/javax/isolate/Link.java trunk/core/src/classpath/ext/javax/isolate/LinkMessage.java trunk/core/src/classpath/ext/javax/isolate/LinkMessageDispatcher.java trunk/core/src/classpath/ext/javax/isolate/LinkMessageHandler.java trunk/core/src/classpath/ext/javax/isolate/StreamBindings.java trunk/core/src/classpath/vm/gnu/classpath/Configuration.java trunk/core/src/classpath/vm/gnu/classpath/VMStackWalker.java trunk/core/src/classpath/vm/gnu/classpath/VMSystemProperties.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/JNodeSocketTransport.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMFrame.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMMethod.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMVirtualMachine.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMFrame.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMIdManager.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMMethod.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMVirtualMachine.java trunk/core/src/classpath/vm/gnu/java/lang/VMClassHelper.java trunk/core/src/classpath/vm/gnu/java/lang/VMInstrumentationImpl.java trunk/core/src/classpath/vm/gnu/java/nio/VMChannel.java trunk/core/src/classpath/vm/gnu/java/nio/VMPipe.java trunk/core/src/classpath/vm/gnu/java/nio/VMSelector.java trunk/core/src/classpath/vm/gnu/java/security/action/GetPolicyAction.java trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java trunk/core/src/classpath/vm/gnu/java/security/action/InvokeAction.java trunk/core/src/classpath/vm/gnu/java/security/action/SetPropertyAction.java trunk/core/src/classpath/vm/gnu/java/security/util/SimplePermissionCollection.java trunk/core/src/classpath/vm/java/awt/VMAwtAPI.java trunk/core/src/classpath/vm/java/awt/image/VMImageAPI.java trunk/core/src/classpath/vm/java/awt/image/VMImageUtils.java trunk/core/src/classpath/vm/java/io/VMFile.java trunk/core/src/classpath/vm/java/io/VMFileSystemAPI.java trunk/core/src/classpath/vm/java/io/VMIOUtils.java trunk/core/src/classpath/vm/java/io/VMObjectInputStream.java trunk/core/src/classpath/vm/java/io/VMObjectStreamClass.java trunk/core/src/classpath/vm/java/io/VMOpenMode.java trunk/core/src/classpath/vm/java/lang/ClassLoader.java trunk/core/src/classpath/vm/java/lang/Thread.java trunk/core/src/classpath/vm/java/lang/VMClassLoader.java trunk/core/src/classpath/vm/java/lang/VMProcess.java trunk/core/src/classpath/vm/java/lang/VMRuntime.java trunk/core/src/classpath/vm/java/lang/VMSecurityManager.java trunk/core/src/classpath/vm/java/lang/VMSystem.java trunk/core/src/classpath/vm/java/net/ExSocketOptions.java trunk/core/src/classpath/vm/java/net/VMInetAddress.java trunk/core/src/classpath/vm/java/net/VMNetAPI.java trunk/core/src/classpath/vm/java/net/VMNetAny.java trunk/core/src/classpath/vm/java/net/VMNetDevice.java trunk/core/src/classpath/vm/java/net/VMNetUtils.java trunk/core/src/classpath/vm/java/net/VMNetworkInterface.java trunk/core/src/classpath/vm/java/net/VMURLConnection.java trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java trunk/core/src/classpath/vm/java/security/VMSecureRandom.java trunk/core/src/classpath/vm/org/jnode/java/io/VMFileHandle.java trunk/core/src/core/org/jnode/assembler/BootImageNativeStream.java trunk/core/src/core/org/jnode/assembler/Label.java trunk/core/src/core/org/jnode/assembler/NativeStream.java trunk/core/src/core/org/jnode/assembler/ObjectResolver.java trunk/core/src/core/org/jnode/assembler/UnresolvedObjectRefException.java trunk/core/src/core/org/jnode/assembler/x86/InvalidOpcodeException.java trunk/core/src/core/org/jnode/assembler/x86/X86Assembler.java trunk/core/src/core/org/jnode/assembler/x86/X86BinaryAssembler.java trunk/core/src/core/org/jnode/assembler/x86/X86Constants.java trunk/core/src/core/org/jnode/assembler/x86/X86Operation.java trunk/core/src/core/org/jnode/assembler/x86/X86Register.java trunk/core/src/core/org/jnode/assembler/x86/X86TextAssembler.java trunk/core/src/core/org/jnode/assembler/x86/X86Utils.java trunk/core/src/core/org/jnode/boot/InitJarProcessor.java trunk/core/src/core/org/jnode/boot/Main.java trunk/core/src/core/org/jnode/boot/MemoryResourceInputStream.java trunk/core/src/core/org/jnode/boot/NoCloseInputStream.java trunk/core/src/core/org/jnode/debug/RemoteAppender.java trunk/core/src/core/org/jnode/debug/RemoteReceiver.java trunk/core/src/core/org/jnode/debug/UDPOutputStream.java trunk/core/src/core/org/jnode/debugger/DebugState.java trunk/core/src/core/org/jnode/debugger/Debugger.java trunk/core/src/core/org/jnode/debugger/DebuggerPlugin.java trunk/core/src/core/org/jnode/debugger/DebuggerUtils.java trunk/core/src/core/org/jnode/debugger/RootState.java trunk/core/src/core/org/jnode/debugger/ThreadListState.java trunk/core/src/core/org/jnode/debugger/ThreadState.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoder.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoderAdapter.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGException.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGImageReader.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGImageReaderSpi.java trunk/core/src/core/org/jnode/log4j/config/JNodeSystemAppender.java trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java trunk/core/src/core/org/jnode/log4j/config/UnsafeDebugAppender.java trunk/core/src/core/org/jnode/log4j/config/VirtualConsoleAppender.java trunk/core/src/core/org/jnode/naming/AbstractNameSpace.java trunk/core/src/core/org/jnode/naming/DefaultNameSpace.java trunk/core/src/core/org/jnode/naming/InitialNaming.java trunk/core/src/core/org/jnode/naming/NameSpace.java trunk/core/src/core/org/jnode/naming/NameSpaceListener.java trunk/core/src/core/org/jnode/plugin/AutoUnzipPlugin.java trunk/core/src/core/org/jnode/plugin/ConfigurationElement.java trunk/core/src/core/org/jnode/plugin/Extension.java trunk/core/src/core/org/jnode/plugin/ExtensionPoint.java trunk/core/src/core/org/jnode/plugin/ExtensionPointListener.java trunk/core/src/core/org/jnode/plugin/FragmentDescriptor.java trunk/core/src/core/org/jnode/plugin/Library.java trunk/core/src/core/org/jnode/plugin/Plugin.java trunk/core/src/core/org/jnode/plugin/PluginClassLoader.java trunk/core/src/core/org/jnode/plugin/PluginDescriptor.java trunk/core/src/core/org/jnode/plugin/PluginDescriptorListener.java trunk/core/src/core/org/jnode/plugin/PluginException.java trunk/core/src/core/org/jnode/plugin/PluginLoader.java trunk/core/src/core/org/jnode/plugin/PluginLoaderManager.java trunk/core/src/core/org/jnode/plugin/PluginManager.java trunk/core/src/core/org/jnode/plugin/PluginPrerequisite.java trunk/core/src/core/org/jnode/plugin/PluginReference.java trunk/core/src/core/org/jnode/plugin/PluginRegistry.java trunk/core/src/core/org/jnode/plugin/PluginSecurityConstants.java trunk/core/src/core/org/jnode/plugin/PluginUtils.java trunk/core/src/core/org/jnode/plugin/Runtime.java trunk/core/src/core/org/jnode/plugin/URLPluginLoader.java trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginLoaderManager.java trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java trunk/core/src/core/org/jnode/plugin/model/AbstractModelObject.java trunk/core/src/core/org/jnode/plugin/model/AttributeModel.java trunk/core/src/core/org/jnode/plugin/model/ConfigurationElementModel.java trunk/core/src/core/org/jnode/plugin/model/EmptyPlugin.java trunk/core/src/core/org/jnode/plugin/model/ExtensionModel.java trunk/core/src/core/org/jnode/plugin/model/ExtensionPointModel.java trunk/core/src/core/org/jnode/plugin/model/Factory.java trunk/core/src/core/org/jnode/plugin/model/FragmentDescriptorModel.java trunk/core/src/core/org/jnode/plugin/model/LibraryModel.java trunk/core/src/core/org/jnode/plugin/model/PluginClassLoaderImpl.java trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java trunk/core/src/core/org/jnode/plugin/model/PluginJar.java trunk/core/src/core/org/jnode/plugin/model/PluginModelObject.java trunk/core/src/core/org/jnode/plugin/model/PluginPrerequisiteModel.java trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java trunk/core/src/core/org/jnode/plugin/model/PluginsClassLoader.java trunk/core/src/core/org/jnode/plugin/model/RuntimeModel.java trunk/core/src/core/org/jnode/protocol/ProtocolHandlerFactoryPlugin.java trunk/core/src/core/org/jnode/protocol/plugin/Handler.java trunk/core/src/core/org/jnode/protocol/plugin/PluginURLConnection.java trunk/core/src/core/org/jnode/protocol/system/Handler.java trunk/core/src/core/org/jnode/protocol/system/SystemURLConnection.java trunk/core/src/core/org/jnode/security/JNodePermission.java trunk/core/src/core/org/jnode/security/JNodePolicy.java trunk/core/src/core/org/jnode/security/JNodeSecurityManager.java trunk/core/src/core/org/jnode/security/SecurityPlugin.java trunk/core/src/core/org/jnode/system/BootLog.java trunk/core/src/core/org/jnode/system/DMAException.java trunk/core/src/core/org/jnode/system/DMAManager.java trunk/core/src/core/org/jnode/system/DMAResource.java trunk/core/src/core/org/jnode/system/IOResource.java trunk/core/src/core/org/jnode/system/IRQHandler.java trunk/core/src/core/org/jnode/system/IRQResource.java trunk/core/src/core/org/jnode/system/MemoryResource.java trunk/core/src/core/org/jnode/system/MemoryScanner.java trunk/core/src/core/org/jnode/system/MultiMediaMemoryResource.java trunk/core/src/core/org/jnode/system/Resource.java trunk/core/src/core/org/jnode/system/ResourceManager.java trunk/core/src/core/org/jnode/system/ResourceNotFreeException.java trunk/core/src/core/org/jnode/system/ResourceOwner.java trunk/core/src/core/org/jnode/system/ResourcePermission.java trunk/core/src/core/org/jnode/system/SimpleResourceOwner.java trunk/core/src/core/org/jnode/system/event/FocusEvent.java trunk/core/src/core/org/jnode/system/event/FocusListener.java trunk/core/src/core/org/jnode/system/event/SystemEvent.java trunk/core/src/core/org/jnode/system/repository/Repository.java trunk/core/src/core/org/jnode/system/repository/RepositoryPlugin.java trunk/core/src/core/org/jnode/system/repository/RepositoryPluginLoader.java trunk/core/src/core/org/jnode/system/repository/SystemRepository.java trunk/core/src/core/org/jnode/system/repository/SystemRepositoryPlugin.java trunk/core/src/core/org/jnode/system/repository/plugins/PluginLoaderPlugin.java trunk/core/src/core/org/jnode/system/repository/spi/SystemRepositoryProvider.java trunk/core/src/core/org/jnode/system/x86/DMA.java trunk/core/src/core/org/jnode/system/x86/DMAConstants.java trunk/core/src/core/org/jnode/system/x86/DMAPlugin.java trunk/core/src/core/org/jnode/system/x86/X86DMAChannel.java trunk/core/src/core/org/jnode/util/AccessControllerUtils.java trunk/core/src/core/org/jnode/util/BCDUtils.java trunk/core/src/core/org/jnode/util/BeanUtils.java trunk/core/src/core/org/jnode/util/BigEndian.java trunk/core/src/core/org/jnode/util/BinaryScaleFactor.java trunk/core/src/core/org/jnode/util/BooleanUtils.java trunk/core/src/core/org/jnode/util/BootableArrayList.java trunk/core/src/core/org/jnode/util/BootableHashMap.java trunk/core/src/core/org/jnode/util/ByteBufferInputStream.java trunk/core/src/core/org/jnode/util/ByteBufferUtils.java trunk/core/src/core/org/jnode/util/ByteQueue.java trunk/core/src/core/org/jnode/util/ByteQueueProcessor.java trunk/core/src/core/org/jnode/util/ByteQueueProcessorThread.java trunk/core/src/core/org/jnode/util/ChannelInputStream.java trunk/core/src/core/org/jnode/util/ChannelOutputStream.java trunk/core/src/core/org/jnode/util/Command.java trunk/core/src/core/org/jnode/util/ConsoleStream.java trunk/core/src/core/org/jnode/util/Counter.java trunk/core/src/core/org/jnode/util/CounterGroup.java trunk/core/src/core/org/jnode/util/DecimalScaleFactor.java trunk/core/src/core/org/jnode/util/EmptyInputStream.java trunk/core/src/core/org/jnode/util/FileUtils.java trunk/core/src/core/org/jnode/util/IOUtils.java trunk/core/src/core/org/jnode/util/JarBuffer.java trunk/core/src/core/org/jnode/util/JarConstants.java trunk/core/src/core/org/jnode/util/LittleEndian.java trunk/core/src/core/org/jnode/util/NumberUtils.java trunk/core/src/core/org/jnode/util/ObjectArrayIterator.java trunk/core/src/core/org/jnode/util/ObjectUtils.java trunk/core/src/core/org/jnode/util/OsUtils.java trunk/core/src/core/org/jnode/util/ProxyStream.java trunk/core/src/core/org/jnode/util/ProxyStreamException.java trunk/core/src/core/org/jnode/util/Queue.java trunk/core/src/core/org/jnode/util/QueueProcessor.java trunk/core/src/core/org/jnode/util/QueueProcessorThread.java trunk/core/src/core/org/jnode/util/ReaderInputStream.java trunk/core/src/core/org/jnode/util/ScaleFactor.java trunk/core/src/core/org/jnode/util/SizeUnit.java trunk/core/src/core/org/jnode/util/Statistic.java trunk/core/src/core/org/jnode/util/Statistics.java trunk/core/src/core/org/jnode/util/StopWatch.java trunk/core/src/core/org/jnode/util/SynchronizedCounter.java trunk/core/src/core/org/jnode/util/SystemInputStream.java trunk/core/src/core/org/jnode/util/TimeUtils.java trunk/core/src/core/org/jnode/util/TimeoutException.java trunk/core/src/core/org/jnode/util/Token.java trunk/core/src/core/org/jnode/util/WriterOutputStream.java trunk/core/src/core/org/jnode/vm/AllocationBitmap.java trunk/core/src/core/org/jnode/vm/BootableObject.java trunk/core/src/core/org/jnode/vm/CpuID.java trunk/core/src/core/org/jnode/vm/HeapHelperImpl.java trunk/core/src/core/org/jnode/vm/IOContext.java trunk/core/src/core/org/jnode/vm/IOResourceImpl.java trunk/core/src/core/org/jnode/vm/JvmType.java trunk/core/src/core/org/jnode/vm/LoadCompileService.java trunk/core/src/core/org/jnode/vm/LoadCompileThread.java trunk/core/src/core/org/jnode/vm/MathSupport.java trunk/core/src/core/org/jnode/vm/MemoryBlockManager.java trunk/core/src/core/org/jnode/vm/MemoryMapEntry.java trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java trunk/core/src/core/org/jnode/vm/MemoryScannerImpl.java trunk/core/src/core/org/jnode/vm/MultiMediaMemoryResourceImpl.java trunk/core/src/core/org/jnode/vm/ObjectVisitor.java trunk/core/src/core/org/jnode/vm/RTCService.java trunk/core/src/core/org/jnode/vm/Region.java trunk/core/src/core/org/jnode/vm/ResourceLoader.java trunk/core/src/core/org/jnode/vm/ResourceManagerImpl.java trunk/core/src/core/org/jnode/vm/SoftByteCodes.java trunk/core/src/core/org/jnode/vm/Unsafe.java trunk/core/src/core/org/jnode/vm/VirtualMemoryRegion.java trunk/core/src/core/org/jnode/vm/Vm.java trunk/core/src/core/org/jnode/vm/VmAbstractClassLoader.java trunk/core/src/core/org/jnode/vm/VmAccessControlContext.java trunk/core/src/core/org/jnode/vm/VmAccessController.java trunk/core/src/core/org/jnode/vm/VmAddress.java trunk/core/src/core/org/jnode/vm/VmArchitecture.java trunk/core/src/core/org/jnode/vm/VmChannel.java trunk/core/src/core/org/jnode/vm/VmExit.java trunk/core/src/core/org/jnode/vm/VmIOContext.java trunk/core/src/core/org/jnode/vm/VmJavaClassLoader.java trunk/core/src/core/org/jnode/vm/VmJavaMultiMediaSupport.java trunk/core/src/core/org/jnode/vm/VmMagic.java trunk/core/src/core/org/jnode/vm/VmMultiMediaSupport.java trunk/core/src/core/org/jnode/vm/VmProcess.java trunk/core/src/core/org/jnode/vm/VmProcessClassLoader.java trunk/core/src/core/org/jnode/vm/VmReflection.java trunk/core/src/core/org/jnode/vm/VmStackFrame.java trunk/core/src/core/org/jnode/vm/VmStackFrameEnumerator.java trunk/core/src/core/org/jnode/vm/VmStackReader.java trunk/core/src/core/org/jnode/vm/VmSystem.java trunk/core/src/core/org/jnode/vm/VmSystemClassLoader.java trunk/core/src/core/org/jnode/vm/VmSystemObject.java trunk/core/src/core/org/jnode/vm/VmUtils.java trunk/core/src/core/org/jnode/vm/annotation/AllowedPackages.java trunk/core/src/core/org/jnode/vm/annotation/CheckPermission.java trunk/core/src/core/org/jnode/vm/annotation/DoPrivileged.java trunk/core/src/core/org/jnode/vm/annotation/Inline.java trunk/core/src/core/org/jnode/vm/annotation/Internal.java trunk/core/src/core/org/jnode/vm/annotation/KernelSpace.java trunk/core/src/core/org/jnode/vm/annotation/LoadStatics.java trunk/core/src/core/org/jnode/vm/annotation/MagicPermission.java trunk/core/src/core/org/jnode/vm/annotation/NoFieldAlignments.java trunk/core/src/core/org/jnode/vm/annotation/NoInline.java trunk/core/src/core/org/jnode/vm/annotation/NoReadBarrier.java trunk/core/src/core/org/jnode/vm/annotation/NoWriteBarrier.java trunk/core/src/core/org/jnode/vm/annotation/PrivilegedActionPragma.java trunk/core/src/core/org/jnode/vm/annotation/SharedStatics.java trunk/core/src/core/org/jnode/vm/annotation/Uninterruptible.java trunk/core/src/core/org/jnode/vm/bytecode/BasicBlock.java trunk/core/src/core/org/jnode/vm/bytecode/BasicBlockFinder.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeFlags.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeParser.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeViewer.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeVisitorSupport.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeWriter.java trunk/core/src/core/org/jnode/vm/bytecode/ControlFlowGraph.java trunk/core/src/core/org/jnode/vm/bytecode/DelegatingBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/bytecode/StackException.java trunk/core/src/core/org/jnode/vm/bytecode/TypeStack.java trunk/core/src/core/org/jnode/vm/classmgr/AbstractCode.java trunk/core/src/core/org/jnode/vm/classmgr/AbstractExceptionHandler.java trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java trunk/core/src/core/org/jnode/vm/classmgr/CompiledCodeList.java trunk/core/src/core/org/jnode/vm/classmgr/IMTBuilder.java trunk/core/src/core/org/jnode/vm/classmgr/MethodPragmaFlags.java trunk/core/src/core/org/jnode/vm/classmgr/Modifier.java trunk/core/src/core/org/jnode/vm/classmgr/NotResolvedYetException.java trunk/core/src/core/org/jnode/vm/classmgr/ObjectFlags.java trunk/core/src/core/org/jnode/vm/classmgr/ObjectLayout.java trunk/core/src/core/org/jnode/vm/classmgr/SelectorMap.java trunk/core/src/core/org/jnode/vm/classmgr/Signature.java trunk/core/src/core/org/jnode/vm/classmgr/TIBBuilder.java trunk/core/src/core/org/jnode/vm/classmgr/TIBLayout.java trunk/core/src/core/org/jnode/vm/classmgr/TypePragmaFlags.java trunk/core/src/core/org/jnode/vm/classmgr/TypeSizeInfo.java trunk/core/src/core/org/jnode/vm/classmgr/VmAddressMap.java trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotatedElement.java trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java trunk/core/src/core/org/jnode/vm/classmgr/VmArray.java trunk/core/src/core/org/jnode/vm/classmgr/VmArrayClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmByteCode.java trunk/core/src/core/org/jnode/vm/classmgr/VmCP.java trunk/core/src/core/org/jnode/vm/classmgr/VmClassLoader.java trunk/core/src/core/org/jnode/vm/classmgr/VmClassType.java trunk/core/src/core/org/jnode/vm/classmgr/VmCompiledCode.java trunk/core/src/core/org/jnode/vm/classmgr/VmCompiledExceptionHandler.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstDouble.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstFieldRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstFloat.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstIMethodRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstInt.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstLong.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstMemberRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstMethodRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstObject.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstString.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java trunk/core/src/core/org/jnode/vm/classmgr/VmExceptions.java trunk/core/src/core/org/jnode/vm/classmgr/VmField.java trunk/core/src/core/org/jnode/vm/classmgr/VmImplementedInterface.java trunk/core/src/core/org/jnode/vm/classmgr/VmInstanceField.java trunk/core/src/core/org/jnode/vm/classmgr/VmInstanceMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmInterfaceClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmInterpretedExceptionHandler.java trunk/core/src/core/org/jnode/vm/classmgr/VmIsolatedStatics.java trunk/core/src/core/org/jnode/vm/classmgr/VmIsolatedStaticsEntry.java trunk/core/src/core/org/jnode/vm/classmgr/VmLineNumberMap.java trunk/core/src/core/org/jnode/vm/classmgr/VmLocalVariable.java trunk/core/src/core/org/jnode/vm/classmgr/VmLocalVariableTable.java trunk/core/src/core/org/jnode/vm/classmgr/VmMember.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethodCode.java trunk/core/src/core/org/jnode/vm/classmgr/VmNormalClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmObject.java trunk/core/src/core/org/jnode/vm/classmgr/VmPrimitiveClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmResolvableConstObject.java trunk/core/src/core/org/jnode/vm/classmgr/VmSharedStatics.java trunk/core/src/core/org/jnode/vm/classmgr/VmSharedStaticsEntry.java trunk/core/src/core/org/jnode/vm/classmgr/VmSpecialMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticField.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmStatics.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticsAllocator.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticsBase.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticsIterator.java trunk/core/src/core/org/jnode/vm/classmgr/VmType.java trunk/core/src/core/org/jnode/vm/classmgr/VmTypeState.java trunk/core/src/core/org/jnode/vm/classmgr/VmUTF8Convert.java trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java trunk/core/src/core/org/jnode/vm/compiler/CompileError.java trunk/core/src/core/org/jnode/vm/compiler/CompiledExceptionHandler.java trunk/core/src/core/org/jnode/vm/compiler/CompiledIMT.java trunk/core/src/core/org/jnode/vm/compiler/CompiledMethod.java trunk/core/src/core/org/jnode/vm/compiler/CompilerBytecodeParser.java trunk/core/src/core/org/jnode/vm/compiler/CompilerBytecodeViewer.java trunk/core/src/core/org/jnode/vm/compiler/CompilerBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/DelegatingCompilerBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/EntryPoints.java trunk/core/src/core/org/jnode/vm/compiler/GCMapIterator.java trunk/core/src/core/org/jnode/vm/compiler/IMTCompiler.java trunk/core/src/core/org/jnode/vm/compiler/IllegalModeException.java trunk/core/src/core/org/jnode/vm/compiler/InlineBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/NativeCodeCompiler.java trunk/core/src/core/org/jnode/vm/compiler/OptimizingBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/VerifyingCompilerBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/ir/AddressingMode.java trunk/core/src/core/org/jnode/vm/compiler/ir/CodeGenerator.java trunk/core/src/core/org/jnode/vm/compiler/ir/Constant.java trunk/core/src/core/org/jnode/vm/compiler/ir/DoubleConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/FloatConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRBasicBlock.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRBasicBlockFinder.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRControlFlowGraph.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRGenerator.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRTest.java trunk/core/src/core/org/jnode/vm/compiler/ir/IntConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/LinearScanAllocator.java trunk/core/src/core/org/jnode/vm/compiler/ir/LiveRange.java trunk/core/src/core/org/jnode/vm/compiler/ir/LocalVariable.java trunk/core/src/core/org/jnode/vm/compiler/ir/Location.java trunk/core/src/core/org/jnode/vm/compiler/ir/LongConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/MethodArgument.java trunk/core/src/core/org/jnode/vm/compiler/ir/NativeTest.java trunk/core/src/core/org/jnode/vm/compiler/ir/Operand.java trunk/core/src/core/org/jnode/vm/compiler/ir/PhiOperand.java trunk/core/src/core/org/jnode/vm/compiler/ir/PrimitiveTest.java trunk/core/src/core/org/jnode/vm/compiler/ir/ReferenceConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/RegisterLocation.java trunk/core/src/core/org/jnode/vm/compiler/ir/RegisterPool.java trunk/core/src/core/org/jnode/vm/compiler/ir/SSAStack.java trunk/core/src/core/org/jnode/vm/compiler/ir/StackLocation.java trunk/core/src/core/org/jnode/vm/compiler/ir/StackVariable.java trunk/core/src/core/org/jnode/vm/compiler/ir/Variable.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/AssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BinaryOperation.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BinaryQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BranchCondition.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BranchQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/ConditionalBranchQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/ConstantRefAssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/PhiAssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/Quad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/UnaryOperation.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/UnaryQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/UnconditionalBranchQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/VarReturnQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/VariableRefAssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/VoidReturnQuad.java trunk/core/src/core/org/jnode/vm/isolate/DataLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/IsolateLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/IsolateStatusImpl.java trunk/core/src/core/org/jnode/vm/isolate/IsolateThread.java trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java trunk/core/src/core/org/jnode/vm/isolate/LinkImpl.java trunk/core/src/core/org/jnode/vm/isolate/LinkLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/LinkMessageFactory.java trunk/core/src/core/org/jnode/vm/isolate/LinkMessageImpl.java trunk/core/src/core/org/jnode/vm/isolate/ObjectLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/StatusLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/StringLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolateLocal.java trunk/core/src/core/org/jnode/vm/isolate/VmLink.java trunk/core/src/core/org/jnode/vm/isolate/VmStreamBindings.java trunk/core/src/core/org/jnode/vm/memmgr/GCStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/HeapHelper.java trunk/core/src/core/org/jnode/vm/memmgr/HeapStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/VmHeapManager.java trunk/core/src/core/org/jnode/vm/memmgr/VmWriteBarrier.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefGCStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefaultHeapManager.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefaultWriteBarrier.java trunk/core/src/core/org/jnode/vm/memmgr/def/FinalizerThread.java trunk/core/src/core/org/jnode/vm/memmgr/def/FinalizerVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCManager.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCMarkVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCSetWhiteVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCStack.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCSweepVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCThread.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCVerifyVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/HeapStatisticsVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/VmAbstractHeap.java trunk/core/src/core/org/jnode/vm/memmgr/def/VmBootHeap.java trunk/core/src/core/org/jnode/vm/memmgr/def/VmDefaultHeap.java trunk/core/src/core/org/jnode/vm/performance/PerformanceCounterEvent.java trunk/core/src/core/org/jnode/vm/performance/PerformanceCounters.java trunk/core/src/core/org/jnode/vm/performance/PresetEvent.java trunk/core/src/core/org/jnode/vm/scheduler/IRQManager.java trunk/core/src/core/org/jnode/vm/scheduler/IRQThread.java trunk/core/src/core/org/jnode/vm/scheduler/IdleThread.java trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java trunk/core/src/core/org/jnode/vm/scheduler/ProcessorLock.java trunk/core/src/core/org/jnode/vm/scheduler/SpinLock.java trunk/core/src/core/org/jnode/vm/scheduler/SystemThread.java trunk/core/src/core/org/jnode/vm/scheduler/VmProcessor.java trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java trunk/core/src/core/org/jnode/vm/scheduler/VmThreadQueue.java trunk/core/src/core/org/jnode/vm/scheduler/VmThreadQueueEntry.java trunk/core/src/core/org/jnode/vm/scheduler/VmThreadVisitor.java trunk/core/src/core/org/jnode/vm/x86/GDT.java trunk/core/src/core/org/jnode/vm/x86/IOAPIC.java trunk/core/src/core/org/jnode/vm/x86/IOAPICRedirectionEntry.java trunk/core/src/core/org/jnode/vm/x86/LocalAPIC.java trunk/core/src/core/org/jnode/vm/x86/MMXMultiMediaSupport.java trunk/core/src/core/org/jnode/vm/x86/MPBusEntry.java trunk/core/src/core/org/jnode/vm/x86/MPConfigTable.java trunk/core/src/core/org/jnode/vm/x86/MPEntry.java trunk/core/src/core/org/jnode/vm/x86/MPFloatingPointerStructure.java trunk/core/src/core/org/jnode/vm/x86/MPIOAPICEntry.java trunk/core/src/core/org/jnode/vm/x86/MPIOInterruptAssignmentEntry.java trunk/core/src/core/org/jnode/vm/x86/MPInterruptAssignmentEntry.java trunk/core/src/core/org/jnode/vm/x86/MPLocalInterruptAssignmentEntry.java trunk/core/src/core/org/jnode/vm/x86/MPProcessorEntry.java trunk/core/src/core/org/jnode/vm/x86/MSR.java trunk/core/src/core/org/jnode/vm/x86/PIC8259A.java trunk/core/src/core/org/jnode/vm/x86/TSS32.java trunk/core/src/core/org/jnode/vm/x86/UnsafeX86.java trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture.java trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture32.java trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture64.java trunk/core/src/core/org/jnode/vm/x86/VmX86Processor.java trunk/core/src/core/org/jnode/vm/x86/VmX86Processor32.java trunk/core/src/core/org/jnode/vm/x86/VmX86Processor64.java trunk/core/src/core/org/jnode/vm/x86/VmX86StackReader.java trunk/core/src/core/org/jnode/vm/x86/VmX86Thread.java trunk/core/src/core/org/jnode/vm/x86/VmX86Thread32.java trunk/core/src/core/org/jnode/vm/x86/VmX86Thread64.java trunk/core/src/core/org/jnode/vm/x86/X86Cpu.java trunk/core/src/core/org/jnode/vm/x86/X86CpuID.java trunk/core/src/core/org/jnode/vm/x86/X86IRQManager.java trunk/core/src/core/org/jnode/vm/x86/X86MemoryMapEntry.java trunk/core/src/core/org/jnode/vm/x86/X86Vendor.java trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86Compiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86StackManager.java trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86CompiledIMT.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86CompilerConstants.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86CompilerHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86IMTCompiler32.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86IMTCompiler64.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86JumpTable.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/DoubleItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/DoubleWordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/EmitterContext.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompilerFPU.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompilerSSE.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPUHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPUStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FloatItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/InlinedMethodInfo.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/IntItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/Item.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/ItemStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/ItemVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/L1AHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/LongItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/RefItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/RegisterVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/VirtualStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/WordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86GCMapIterator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86Level1ACompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86RegisterPool.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86StackFrame.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/DoubleItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/DoubleWordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/EmitterContext.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompilerFPU.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompilerSSE.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPUHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPUStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FloatItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/InlinedMethodInfo.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/IntItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/Item.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/ItemFactory.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/ItemStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/ItemVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/L1AHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/LongItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/RefItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/RegisterVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/VirtualStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/WordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86GCMapIterator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86Level1BCompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86RegisterPool.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86StackFrame.java trunk/core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l2/X86CodeGenerator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l2/X86RegisterPool.java trunk/core/src/core/org/jnode/vm/x86/compiler/stub/EmptyGCMapIterator.java trunk/core/src/core/org/jnode/vm/x86/compiler/stub/X86StubCompiler.java trunk/core/src/core/org/jnode/vm/x86/performance/Athlon64PerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/DualMSRPerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/P4FamilyPerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/P6PerformanceCouters.java trunk/core/src/core/org/jnode/vm/x86/performance/Pentium4PerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/X86PerformanceCounters.java trunk/core/src/core/org/jnode/work/Work.java trunk/core/src/core/org/jnode/work/WorkManager.java trunk/core/src/core/org/jnode/work/WorkPlugin.java trunk/core/src/core/org/jnode/work/WorkUtils.java trunk/core/src/driver/org/jnode/driver/AbstractDeviceManager.java trunk/core/src/driver/org/jnode/driver/ApiNotFoundException.java trunk/core/src/driver/org/jnode/driver/Bus.java trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java trunk/core/src/driver/org/jnode/driver/Device.java trunk/core/src/driver/org/jnode/driver/DeviceAPI.java trunk/core/src/driver/org/jnode/driver/DeviceAlreadyConnectedException.java trunk/core/src/driver/org/jnode/driver/DeviceAlreadyRegisteredException.java trunk/core/src/driver/org/jnode/driver/DeviceException.java trunk/core/src/driver/org/jnode/driver/DeviceFinder.java trunk/core/src/driver/org/jnode/driver/DeviceFinderPlugin.java trunk/core/src/driver/org/jnode/driver/DeviceInfoAPI.java trunk/core/src/driver/org/jnode/driver/DeviceListener.java trunk/core/src/driver/org/jnode/driver/DeviceManager.java trunk/core/src/driver/org/jnode/driver/DeviceManagerListener.java trunk/core/src/driver/org/jnode/driver/DeviceNotFoundException.java trunk/core/src/driver/org/jnode/driver/DeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/DeviceUtils.java trunk/core/src/driver/org/jnode/driver/Driver.java trunk/core/src/driver/org/jnode/driver/DriverException.java trunk/core/src/driver/org/jnode/driver/DriverPermission.java trunk/core/src/driver/org/jnode/driver/DriverPlugin.java trunk/core/src/driver/org/jnode/driver/InvalidDriverException.java trunk/core/src/driver/org/jnode/driver/RemovableDeviceAPI.java trunk/core/src/driver/org/jnode/driver/bus/firewire/FireWireBus.java trunk/core/src/driver/org/jnode/driver/bus/firewire/FireWireDevice.java trunk/core/src/driver/org/jnode/driver/bus/firewire/FireWireDriver.java trunk/core/src/driver/org/jnode/driver/bus/pci/AGPCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/AbstractPCIDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/pci/Capability.java trunk/core/src/driver/org/jnode/driver/bus/pci/CompactHotSwapCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/DeviceDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/pci/MSICapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIBaseAddress.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIBus.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIBusAPI.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIClassToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIConstants.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDescriptors.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDevice.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDeviceConfig.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDriver.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIException.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIFinder.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIHeaderType0.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIHeaderType1.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIHeaderType2.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIRomAddress.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCI_IDs.java trunk/core/src/driver/org/jnode/driver/bus/pci/PMCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/SlotIDCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/VPDCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/VendorDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/pcmcia/CardBusBus.java trunk/core/src/driver/org/jnode/driver/bus/pcmcia/CardBusDevice.java trunk/core/src/driver/org/jnode/driver/bus/pcmcia/CardBusDriver.java trunk/core/src/driver/org/jnode/driver/bus/smbus/DIMM.java trunk/core/src/driver/org/jnode/driver/bus/smbus/DIMMDriver.java trunk/core/src/driver/org/jnode/driver/bus/smbus/SMBus.java trunk/core/src/driver/org/jnode/driver/bus/smbus/SMBusControler.java trunk/core/src/driver/org/jnode/driver/bus/smbus/SMBusDevice.java trunk/core/src/driver/org/jnode/driver/bus/usb/AbstractDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/AbstractDeviceItem.java trunk/core/src/driver/org/jnode/driver/bus/usb/AbstractHostControllerDriver.java trunk/core/src/driver/org/jnode/driver/bus/usb/ConfigurationDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/DeviceDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/EndPointDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/InterfaceDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/SetupPacket.java trunk/core/src/driver/org/jnode/driver/bus/usb/StringDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/StringDescriptorZero.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBBus.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBConfiguration.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBConstants.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBControlPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBDataPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBDevice.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBEndPoint.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBException.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBHostControllerAPI.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBHubAPI.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBHubMonitor.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBInterface.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBPacket.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBPipeListener.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/HubDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/PortStatus.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/USBHubConstants.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/USBHubDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/USBHubDriver.java trunk/core/src/driver/org/jnode/driver/bus/usb/spi/AbstractUSBControlRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/spi/AbstractUSBDataRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/spi/AbstractUSBRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/AbstractStructure.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/AbstractTreeStructure.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/FrameList.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/QueueHead.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/Schedule.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/TransferDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIConstants.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIControlPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIControlRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCICore.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDataPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDataRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDriver.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIIO.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIPipeManager.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIRootHub.java trunk/core/src/driver/org/jnode/driver/character/ChannelAlreadyOwnedException.java trunk/core/src/driver/org/jnode/driver/character/CharacterDeviceAPI.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i440BXDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI_SMBusControler.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ISABridge.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_USBController.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82443BX_HostPCIBridge.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82443BX_PCIPCIBridge.java trunk/core/src/driver/org/jnode/driver/chipset/via/Via82C686.java trunk/core/src/driver/org/jnode/driver/chipset/via/Via8363_0.java trunk/core/src/driver/org/jnode/driver/chipset/via/ViaDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/chipset/via/ViaQuirks.java trunk/core/src/driver/org/jnode/driver/console/ActiveTextConsole.java trunk/core/src/driver/org/jnode/driver/console/CompletionInfo.java trunk/core/src/driver/org/jnode/driver/console/Console.java trunk/core/src/driver/org/jnode/driver/console/ConsoleEvent.java trunk/core/src/driver/org/jnode/driver/console/ConsoleException.java trunk/core/src/driver/org/jnode/driver/console/ConsoleListener.java trunk/core/src/driver/org/jnode/driver/console/ConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/InputCompleter.java trunk/core/src/driver/org/jnode/driver/console/InputHistory.java trunk/core/src/driver/org/jnode/driver/console/KeyEventBindings.java trunk/core/src/driver/org/jnode/driver/console/ScrollableTextConsole.java trunk/core/src/driver/org/jnode/driver/console/TextConsole.java trunk/core/src/driver/org/jnode/driver/console/VirtualKey.java trunk/core/src/driver/org/jnode/driver/console/VirtualTextConsole.java trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsole.java trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/spi/ConsoleWriter.java trunk/core/src/driver/org/jnode/driver/console/textscreen/ConsoleKeyEventBindings.java trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReader.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReaderAction.java trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsolePlugin.java trunk/core/src/driver/org/jnode/driver/input/AbstractInputDriver.java trunk/core/src/driver/org/jnode/driver/input/AbstractKeyboardDriver.java trunk/core/src/driver/org/jnode/driver/input/AbstractKeyboardInterpreter.java trunk/core/src/driver/org/jnode/driver/input/AbstractPointerDriver.java trunk/core/src/driver/org/jnode/driver/input/DeadKeyException.java trunk/core/src/driver/org/jnode/driver/input/Key.java trunk/core/src/driver/org/jnode/driver/input/KeyboardAPI.java trunk/core/src/driver/org/jnode/driver/input/KeyboardAPIAdapter.java trunk/core/src/driver/org/jnode/driver/input/KeyboardAdapter.java trunk/core/src/driver/org/jnode/driver/input/KeyboardConstants.java trunk/core/src/driver/org/jnode/driver/input/KeyboardEvent.java trunk/core/src/driver/org/jnode/driver/input/KeyboardInputPlugin.java trunk/core/src/driver/org/jnode/driver/input/KeyboardInterpreter.java trunk/core/src/driver/org/jnode/driver/input/KeyboardInterpreterException.java trunk/core/src/driver/org/jnode/driver/input/KeyboardLayoutManager.java trunk/core/src/driver/org/jnode/driver/input/KeyboardListener.java trunk/core/src/driver/org/jnode/driver/input/Keys.java trunk/core/src/driver/org/jnode/driver/input/LogitechProtocol.java trunk/core/src/driver/org/jnode/driver/input/LogitechWheelMouseProtocol.java trunk/core/src/driver/org/jnode/driver/input/MissingKeyboardInterpreterClassException.java trunk/core/src/driver/org/jnode/driver/input/MouseInterpreter.java trunk/core/src/driver/org/jnode/driver/input/MouseProtocolHandler.java trunk/core/src/driver/org/jnode/driver/input/PointerAPI.java trunk/core/src/driver/org/jnode/driver/input/PointerAPIAdapter.java trunk/core/src/driver/org/jnode/driver/input/PointerEvent.java trunk/core/src/driver/org/jnode/driver/input/PointerInterpreter.java trunk/core/src/driver/org/jnode/driver/input/PointerListener.java trunk/core/src/driver/org/jnode/driver/input/SystemListener.java trunk/core/src/driver/org/jnode/driver/input/SystemTriggerAPI.java trunk/core/src/driver/org/jnode/driver/input/SystemTriggerListener.java trunk/core/src/driver/org/jnode/driver/input/UnsupportedKeyException.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_BE_fr.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_CH_fr.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_DE.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_DK.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_DV.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_ES.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_FR.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_FR_fr.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_GB_en.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU_101.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU_hu.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU_hu_101.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_IT.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_IT_it.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_NO.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_RU.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_SE.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_US_en.java trunk/core/src/driver/org/jnode/driver/serial/SerialPortAPI.java trunk/core/src/driver/org/jnode/driver/serial/SerialPortDriver.java trunk/core/src/driver/org/jnode/driver/serial/SerialPortFinder.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiAPI.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiDriver.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiSystemTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/DifferentiatedSystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/ExtendedSystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/FirmwareAcpiControlStructure.java trunk/core/src/driver/org/jnode/driver/system/acpi/FixedAcpiDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/GenericAddress.java trunk/core/src/driver/org/jnode/driver/system/acpi/RSDP.java trunk/core/src/driver/org/jnode/driver/system/acpi/RootSystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/SystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/Aml.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/AmlOpcode.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/NameString.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/ParseNode.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/Parser.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/AcpiInteger.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/AcpiNamedObject.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/AcpiObject.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/Buffer.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/ByteField.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/Device.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/NameSpace.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/Scope.java trunk/core/src/driver/org/jnode/driver/system/cmos/CMOSConstants.java trunk/core/src/driver/org/jnode/driver/system/cmos/CMOSService.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/CMOS.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/CMOSPlugin.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/RTC.java trunk/core/src/driver/org/jnode/driver/system/firmware/AcpiDevice.java trunk/core/src/driver/org/jnode/driver/system/firmware/AcpiRSDPInfo.java trunk/core/src/driver/org/jnode/driver/system/firmware/FirmwareAPI.java trunk/core/src/driver/org/jnode/driver/system/firmware/bios/BiosDriver.java trunk/core/src/driver/org/jnode/driver/system/firmware/bios/BiosFinder.java trunk/core/src/driver/org/jnode/driver/system/pnp/PnP.java trunk/core/src/driver/org/jnode/driver/system/ram/RAMControler.java trunk/core/src/driver/org/jnode/driver/system/ram/RAMModuleCollection.java trunk/core/src/driver/org/jnode/driver/system/ram/RAMModuleInfo.java trunk/core/src/driver/org/jnode/driver/textscreen/ScrollableTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/TextScreenManager.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenManager.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenPlugin.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenUtils.java trunk/core/src/driver/org/jnode/driver/virtual/VirtualDevice.java trunk/core/src/driver/org/jnode/driver/virtual/VirtualDeviceDriver.java trunk/core/src/driver/org/jnode/driver/virtual/VirtualDeviceFactory.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/BaseMmtkGCStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/BaseMmtkHeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/GenRCStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/HeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/Plan.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/PlanConstants.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/HeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/MarkSweepStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/Plan.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/PlanConstants.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/HeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/NoGCStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/Plan.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/PlanConstants.java trunk/core/src/test/org/jnode/test/AllTests.java trunk/core/src/test/org/jnode/test/AnnotationTest.java trunk/core/src/test/org/jnode/test/ArrayBoundsTest.java trunk/core/src/test/org/jnode/... [truncated message content] |
From: <kon...@us...> - 2009-02-02 00:10:26
|
Revision: 4968 http://jnode.svn.sourceforge.net/jnode/?rev=4968&view=rev Author: konkubinaten Date: 2009-02-02 00:10:20 +0000 (Mon, 02 Feb 2009) Log Message: ----------- revert headers of files that were accidentially modified Modified Paths: -------------- trunk/core/src/classpath/vm/gnu/classpath/VMStackWalker.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMFrame.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMIdManager.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMMethod.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMVirtualMachine.java trunk/core/src/classpath/vm/gnu/java/lang/VMInstrumentationImpl.java trunk/core/src/classpath/vm/gnu/java/nio/VMChannel.java trunk/core/src/classpath/vm/java/lang/Thread.java trunk/core/src/classpath/vm/java/lang/VMProcess.java trunk/core/src/classpath/vm/java/lang/VMSystem.java trunk/core/src/openjdk/vm/java/lang/NativeStrictMath.java trunk/core/src/openjdk/vm/java/lang/ProcessEnvironment.java trunk/core/src/openjdk/vm/java/lang/ProcessImpl.java trunk/core/src/openjdk/vm/java/lang/Terminator.java trunk/core/src/openjdk/vm/java/lang/UNIXProcess.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_be.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_bg.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_ca.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_cs.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_da.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_de.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_el.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_el_CY.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_en.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_en_GB.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_en_IE.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_en_MT.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_es.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_es_ES.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_es_US.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_et.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_fi.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_fr.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_fr_CA.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_hr.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_hu.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_in_ID.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_is.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_it.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_lt.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_lv.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_mk.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_ms_MY.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_mt.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_mt_MT.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_nl.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_no.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_pl.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_pt.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_pt_PT.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_ro.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_ru.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_sk.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_sl.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_sq.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_sr.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_sv.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_tr.java trunk/core/src/openjdk/vm/sun/util/resources/CalendarData_uk.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_be_BY.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_bg_BG.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_ca_ES.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_cs_CZ.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_da_DK.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_de_AT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_de_CH.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_de_DE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_de_GR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_de_LU.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_el_CY.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_el_GR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_AU.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_CA.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_GB.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_IE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_IN.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_MT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_NZ.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_PH.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_SG.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_US.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_en_ZA.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_AR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_BO.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_CL.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_CO.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_CR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_DO.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_EC.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_ES.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_GT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_HN.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_MX.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_NI.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_PA.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_PE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_PR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_PY.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_SV.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_US.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_UY.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_es_VE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_et_EE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_fi_FI.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_fr_BE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_fr_CA.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_fr_CH.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_fr_FR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_fr_LU.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_ga_IE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_hr_HR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_hu_HU.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_in_ID.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_is_IS.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_it_CH.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_it_IT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_lt_LT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_lv_LV.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_mk_MK.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_ms_MY.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_mt_MT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_nl_BE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_nl_NL.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_no_NO.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_pl_PL.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_pt_BR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_pt_PT.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_ro_RO.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_ru_RU.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sk_SK.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sl_SI.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sq_AL.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sr_BA.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sr_CS.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sr_ME.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_sv_SE.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_tr_TR.java trunk/core/src/openjdk/vm/sun/util/resources/CurrencyNames_uk_UA.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_be.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_bg.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_ca.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_cs.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_da.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_de.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_el.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_el_CY.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_en.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_en_MT.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_en_PH.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_en_SG.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_es.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_es_US.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_et.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_fi.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_fr.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_ga.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_hr.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_hu.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_in.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_is.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_it.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_lt.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_lv.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_mk.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_ms.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_mt.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_nl.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_no.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_pl.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_pt.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_pt_BR.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_pt_PT.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_ro.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_ru.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_sk.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_sl.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_sq.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_sr.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_sv.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_tr.java trunk/core/src/openjdk/vm/sun/util/resources/LocaleNames_uk.java Modified: trunk/core/src/classpath/vm/gnu/classpath/VMStackWalker.java =================================================================== --- trunk/core/src/classpath/vm/gnu/classpath/VMStackWalker.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/classpath/VMStackWalker.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,24 +1,40 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ +/* VMStackWalker.java -- Reference implementation of VM hooks for stack access + Copyright (C) 2005, 2006 Free Software Foundation +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.classpath; import org.jnode.vm.VmSystem; Modified: trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMFrame.java =================================================================== --- trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMFrame.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMFrame.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,24 +1,42 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - +/* VMFrame.java -- Reference implementation of VM hooks for JDWP Frame access. + Copyright (C) 2005, 2006 Free Software Foundation + +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 +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.classpath.jdwp; import gnu.classpath.jdwp.util.Location; Modified: trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMIdManager.java =================================================================== --- trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMIdManager.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMIdManager.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,24 +1,44 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - +/* VMIdManager.java -- A reference/example implementation of a manager for + JDWP object/reference type IDs + + Copyright (C) 2005, 2006 Free Software Foundation + +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 +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.classpath.jdwp; import gnu.classpath.jdwp.exception.InvalidClassException; Modified: trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMMethod.java =================================================================== --- trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMMethod.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMMethod.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,24 +1,42 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - +/* VMMethod.java -- a method in a virtual machine + Copyright (C) 2006 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 +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.classpath.jdwp; import java.io.DataOutputStream; Modified: trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMVirtualMachine.java =================================================================== --- trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMVirtualMachine.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/classpath/jdwp/VMVirtualMachine.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,24 +1,44 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - +/* VMVirtualMachine.java -- A reference implementation of a JDWP virtual + machine + + Copyright (C) 2005, 2006 Free Software Foundation + +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 +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.classpath.jdwp; import gnu.classpath.jdwp.event.EventRequest; Modified: trunk/core/src/classpath/vm/gnu/java/lang/VMInstrumentationImpl.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/lang/VMInstrumentationImpl.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/java/lang/VMInstrumentationImpl.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,24 +1,42 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - +/* VMInstrumentationImpl.java -- interface for the GNU implementation + of InstrumentationImpl + Copyright (C) 2005 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.java.lang; import java.lang.instrument.ClassDefinition; Modified: trunk/core/src/classpath/vm/gnu/java/nio/VMChannel.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/nio/VMChannel.java 2009-02-01 22:13:30 UTC (rev 4967) +++ trunk/core/src/classpath/vm/gnu/java/nio/VMChannel.java 2009-02-02 00:10:20 UTC (rev 4968) @@ -1,669 +1,686 @@ -/* - * $Id: header.txt 2224 2006-01-01 12:49:03Z epr $ - * - * JNode.org - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package gnu.java.nio; - -import gnu.classpath.Configuration; - -import java.io.IOException; -import java.net.Inet4Address; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.net.SocketException; -import java.nio.ByteBuffer; -import java.nio.MappedByteBuffer; - -import org.jnode.vm.VmChannel; - -/** - * Native interface to support configuring of channel to run in a non-blocking - * manner and support scatter/gather io operations. - * - * @author Michael Barker <mi...@mi...> - * - */ -public final class VMChannel -{ - /** - * Our reference implementation uses an integer to store the native - * file descriptor. Implementations without such support - */ - private final State nfd; - - private Kind kind; - - public VMChannel() - { - // XXX consider adding security check here, so only Classpath - // code may create instances. - this.nfd = new State(); - kind = Kind.OTHER; - } - - /** - * This constructor is used by the POSIX reference implementation; - * other virtual machines need not support it. - * - * <strong>Important:</strong> do not call this in library code that is - * not specific to Classpath's reference implementation. - * - * @param native_fd The native file descriptor integer. - * @throws IOException - */ - VMChannel(final int native_fd) throws IOException - { - this(); - this.nfd.setNativeFD(native_fd); - } - - public State getState() - { - return nfd; - } - - static - { - // load the shared library needed for native methods. - if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary ("javanio"); - } - try - { - // so fare this will throw an IOException - VmChannel.initIDs(); - } - catch (IOException e) - { - } - } - - public static VMChannel getStdin() throws IOException - { - return new VMChannel(VmChannel.stdin_fd()); - } - - public static VMChannel getStdout() throws IOException - { - return new VMChannel(VmChannel.stdout_fd()); - } - - public static VMChannel getStderr() throws IOException - { - return new VMChannel(VmChannel.stderr_fd()); - } - - - /** - * Set the file descriptor to have the required blocking - * setting. - * - * @param blocking The blocking flag to set. - */ - public void setBlocking(boolean blocking) throws IOException - { - VmChannel.setBlocking(nfd.getNativeFD(), blocking); - } - - - public int available() throws IOException - { - return VmChannel.available(nfd.getNativeFD()); - } - - - /** - * Reads a byte buffer directly using the supplied file descriptor. - * - * @param dst Direct Byte Buffer to read to. - * @return Number of bytes read. - * @throws IOException If an error occurs or dst is not a direct buffers. - */ - public int read(ByteBuffer dst) - throws IOException - { - return VmChannel.read(nfd.getNativeFD(), dst); - } - - /** - * Read a single byte. - * - * @return The byte read, or -1 on end of file. - * @throws IOException - */ - public int read() throws IOException - { - return VmChannel.read(nfd.getNativeFD()); - } - - - /** - * Reads into byte buffers directly using the supplied file descriptor. - * Assumes that the buffer list contains DirectBuffers. Will perform a - * scattering read. - * - * @param dsts An array direct byte buffers. - * @param offset Index of the first buffer to read to. - * @param length The number of buffers to read to. - * @return Number of bytes read. - * @throws IOException If an error occurs or the dsts are not direct buffers. - */ - public long readScattering(ByteBuffer[] dsts, int offset, int length) - throws IOException - { - if (offset + length > dsts.length) - throw new IndexOutOfBoundsException("offset + length > dsts.length"); - - return VmChannel.readScattering(nfd.getNativeFD(), dsts, offset, length); - } - - - /** - * Receive a datagram on this channel, returning the host address - * that sent the datagram. - * - * @param dst Where to store the datagram. - * @return The host address that sent the datagram. - * @throws IOException - */ - public SocketAddress receive(ByteBuffer dst) throws IOException - { - if (kind != Kind.SOCK_DGRAM) - throw new SocketException("not a datagram socket"); - ByteBuffer hostPort = ByteBuffer.allocateDirect(18); - int hostlen = VmChannel.receive(nfd.getNativeFD(), dst, hostPort); - if (hostlen == 0) - return null; - if (hostlen == 4) // IPv4 - { - byte[] addr = new byte[4]; - hostPort.get(addr); - int port = hostPort.getShort() & 0xFFFF; - return new InetSocketAddress(Inet4Address.getByAddress(addr), port); - } - if (hostlen == 16) // IPv6 - { - byte[] addr = new byte[16]; - hostPort.get(addr); - int port = hostPort.getShort() & 0xFFFF; - return new InetSocketAddress(Inet6Address.getByAddress(addr), port); - } - - throw new SocketException("host address received with invalid length: " - + hostlen); - } - - /** - * Writes from a direct byte bufer using the supplied file descriptor. - * Assumes the buffer is a DirectBuffer. - * - * @param src The source buffer. - * @return Number of bytes written. - * @throws IOException - */ - public int write(ByteBuffer src) throws IOException - { - return VmChannel.write(nfd.getNativeFD(), src); - } - - - /** - * Writes from byte buffers directly using the supplied file descriptor. - * Assumes the that buffer list constains DirectBuffers. Will perform - * as gathering write. - * - * @param fd - * @param srcs - * @param offset - * @param length - * @return Number of bytes written. - * @throws IOException - */ - public long writeGathering(ByteBuffer[] srcs, int offset, int length) - throws IOException - { - if (offset + length > srcs.length) - throw new IndexOutOfBoundsException("offset + length > srcs.length"); - - // A gathering write is limited to 16 buffers; when writing, ensure - // that we have at least one buffer with something in it in the 16 - // buffer window starting at offset. - while (!srcs[offset].hasRemaining() && offset < srcs.length) - offset++; - - // There are no buffers with anything to write. - if (offset == srcs.length) - return 0; - - // If we advanced `offset' so far that we don't have `length' - // buffers left, reset length to only the remaining buffers. - if (length > srcs.length - offset) - length = srcs.length - offset; - - return VmChannel.writeGathering(nfd.getNativeFD(), srcs, offset, length); - } - - - /** - * Send a datagram to the given address. - * - * @param src The source buffer. - * @param dst The destination address. - * @return The number of bytes written. - * @throws IOException - */ - public int send(ByteBuffer src, InetSocketAddress dst) - throws IOException - { - InetAddress addr = dst.getAddress(); - if (addr == null) - throw new NullPointerException(); - if (addr instanceof Inet4Address) - return VmChannel.send(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort()); - else if (addr instanceof Inet6Address) - return VmChannel.send6(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort()); - else - throw new SocketException("unrecognized inet address type"); - } - - /** - * Write a single byte. - * - * @param b The byte to write. - * @throws IOException - */ - public void write(int b) throws IOException - { - VmChannel.write(nfd.getNativeFD(), b); - } - - - // Network (socket) specific methods. - - /** - * Create a new socket. This method will initialize the native file - * descriptor state of this instance. - * - * @param stream Whether or not to create a streaming socket, or a datagram - * socket. - * @throws IOException If creating a new socket fails, or if this - * channel already has its native descriptor initialized. - */ - public void initSocket(boolean stream) throws IOException - { - if (nfd.isValid()) - throw new IOException("native FD already initialized"); - if (stream) - kind = Kind.SOCK_STREAM; - else - kind = Kind.SOCK_DGRAM; - nfd.setNativeFD(VmChannel.socket(stream)); - } - - - /** - * Connect the underlying socket file descriptor to the remote host. - * - * @param saddr The address to connect to. - * @param timeout The connect timeout to use for blocking connects. - * @return True if the connection succeeded; false if the file descriptor - * is in non-blocking mode and the connection did not immediately - * succeed. - * @throws IOException If an error occurs while connecting. - */ - public boolean connect(InetSocketAddress saddr, int timeout) - throws SocketException - { - int fd; - - InetAddress addr = saddr.getAddress(); - - // Translates an IOException into a SocketException to conform - // to the throws clause. - try - { - fd = nfd.getNativeFD(); - } - catch (IOException ioe) - { - throw new SocketException(ioe.getMessage()); - } - - if (addr instanceof Inet4Address) - return VmChannel.connect(fd, addr.getAddress(), saddr.getPort(), - timeout); - if (addr instanceof Inet6Address) - return VmChannel.connect6(fd, addr.getAddress(), saddr.getPort(), - timeout); - throw new SocketException("unsupported internet address"); - } - - /** - * Disconnect this channel, if it is a datagram socket. Disconnecting - * a datagram channel will disassociate it from any address, so the - * socket will remain open, but can send and receive datagrams from - * any address. - * - * @throws IOException If disconnecting this channel fails, or if this - * channel is not a datagram channel. - */ - public void disconnect() throws IOException - { - if (kind != Kind.SOCK_DGRAM) - throw new IOException("can only disconnect datagram channels"); - VmChannel.disconnect(nfd.getNativeFD()); - } - - - public InetSocketAddress getLocalAddress() throws IOException - { - if (!nfd.isValid()) - return null; - ByteBuffer name = ByteBuffer.allocateDirect(18); - int namelen = VmChannel.getsockname(nfd.getNativeFD(), name); - if (namelen == 0) // not bound - return null; // XXX return some wildcard? - if (namelen == 4) - { - byte[] addr = new byte[4]; - name.get(addr); - int port = name.getShort() & 0xFFFF; - return new InetSocketAddress(Inet4Address.getByAddress(addr), port); - } - if (namelen == 16) - { - byte[] addr = new byte[16]; - name.get(addr); - int port = name.getShort() & 0xFFFF; - return new InetSocketAddress(Inet6Address.getByAddress(addr), port); - } - throw new SocketException("invalid address length"); - } - - /** - * Returns the socket address of the remote peer this channel is connected - * to, or null if this channel is not yet connected. - * - * @return The peer address. - * @throws IOException - */ - public InetSocketAddress getPeerAddress() throws IOException - { - if (!nfd.isValid()) - return null; - ByteBuffer name = ByteBuffer.allocateDirect(18); - int namelen = VmChannel.getpeername (nfd.getNativeFD(), name); - if (namelen == 0) // not connected yet - return null; - if (namelen == 4) // IPv4 - { - byte[] addr = new byte[4]; - name.get(addr); - int port = name.getShort() & 0xFFFF; - return new InetSocketAddress(Inet4Address.getByAddress(addr), port); - } - else if (namelen == 16) // IPv6 - { - byte[] addr = new byte[16]; - name.get(addr); - int port = name.getShort() & 0xFFFF; - return new InetSocketAddress(Inet6Address.getByAddress(addr), port); - } - throw new SocketException("invalid address length"); - } - - - /** - * Accept an incoming connection, returning a new VMChannel, or null - * if the channel is nonblocking and no connection is pending. - * - * @return The accepted connection, or null. - * @throws IOException If an IO error occurs. - */ - public VMChannel accept() throws IOException - { - int new_fd = VmChannel.accept(nfd.getNativeFD()); - if (new_fd == -1) // non-blocking accept had no pending connection - return null; - return new VMChannel(new_fd); - } - - // File-specific methods. - - /** - * Open a file at PATH, initializing the native state to operate on - * that open file. - * - * @param path The absolute file path. - * @throws IOException If the file cannot be opened, or if this - * channel was previously initialized. - */ - public void openFile(String path, int mode) throws IOException - { - if (nfd.isValid() || nfd.isClosed()) - throw new IOException("can't reinitialize this channel"); - int fd = VmChannel.open(path, mode); - nfd.setNativeFD(fd); - kind = Kind.FILE; - } - - - public long position() throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - return VmChannel.position(nfd.getNativeFD()); - } - - - public void seek(long pos) throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - VmChannel.seek(nfd.getNativeFD(), pos); - } - - - public void truncate(long length) throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - VmChannel.truncate(nfd.getNativeFD(), length); - } - - - public boolean lock(long pos, long len, boolean shared, boolean wait) - throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - return VmChannel.lock(nfd.getNativeFD(), pos, len, shared, wait); - } - - - public void unlock(long pos, long len) throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - VmChannel.unlock(nfd.getNativeFD(), pos, len); - } - - - public long size() throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - return VmChannel.size(nfd.getNativeFD()); - } - - public MappedByteBuffer map(char mode, long position, int size) - throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - return VmChannel.map(nfd.getNativeFD(), mode, position, size); - } - - - public boolean flush(boolean metadata) throws IOException - { - if (kind != Kind.FILE) - throw new IOException("not a file"); - return VmChannel.flush(nfd.getNativeFD(), metadata); - } - - // Close. - - /** - * Close this socket. The socket is also automatically closed when this - * object is finalized. - * - * @throws IOException If closing the socket fails, or if this object has - * no open socket. - */ - public void close() throws IOException - { - nfd.close(); - } - - - /** - * <p>Provides a simple mean for the JNI code to find out whether the - * current thread was interrupted by a call to Thread.interrupt().</p> - * - * @return - */ - static boolean isThreadInterrupted() - { - return Thread.currentThread().isInterrupted(); - } - - // Inner classes. - - /** - * A wrapper for a native file descriptor integer. This tracks the state - * of an open file descriptor, and ensures that - * - * This class need not be fully supported by virtual machines; if a - * virtual machine does not use integer file descriptors, or does and - * wishes to hide that, then the methods of this class may be stubbed out. - * - * System-specific classes that depend on access to native file descriptor - * integers SHOULD declare this fact. - */ - public final class State - { - private int native_fd; - private boolean valid; - private boolean closed; - - State() - { - native_fd = -1; - valid = false; - closed = false; - } - - public boolean isValid() - { - return valid; - } - - public boolean isClosed() - { - return closed; - } - - public int getNativeFD() throws IOException - { - if (!valid) - throw new IOException("invalid file descriptor"); - return native_fd; - } - - void setNativeFD(final int native_fd) throws IOException - { - if (valid) - throw new IOException("file descriptor already initialized"); - this.native_fd = native_fd; - valid = true; - } - - public void close() throws IOException - { - if (!valid) - throw new IOException("invalid file descriptor"); - try - { - VmChannel.close(native_fd); - } - finally - { - valid = false; - closed = true; - } - } - - public String toString() - { - if (closed) - return "<<closed>>"; - if (!valid) - return "<<invalid>>"; - return String.valueOf(native_fd); - } - - protected void finalize() throws Throwable - { - try - { - if (valid) - close(); - } - finally - { - super.finalize(); - } - } - } - - /** - * An enumeration of possible kinds of channel. - */ - static class Kind // XXX enum - { - /** A streaming (TCP) socket. */ - static final Kind SOCK_STREAM = new Kind(); - - /** A datagram (UDP) socket. */ - static final Kind SOCK_DGRAM = new Kind(); - - /** A file. */ - static final Kind FILE = new Kind(); - - /** Something else; not a socket or file. */ - static final Kind OTHER = new Kind(); - - private Kind() { } - } -} +/* VMChannel.java -- Native interface suppling channel operations. + Copyright (C) 2006 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.java.nio; + +import gnu.classpath.Configuration; + +import java.io.IOException; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.SocketException; +import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; + +import org.jnode.vm.VmChannel; + +/** + * Native interface to support configuring of channel to run in a non-blocking + * manner and support scatter/gather io operations. + * + * @author Michael Barker <mi...@mi...> + * + */ +public final class VMChannel +{ + /** + * Our reference implementation uses an integer to store the native + * file descriptor. Implementations without such support + */ + private final State nfd; + + private Kind kind; + + public VMChannel() + { + // XXX consider adding security check here, so only Classpath + // code may create instances. + this.nfd = new State(); + kind = Kind.OTHER; + } + + /** + * This constructor is used by the POSIX reference implementation; + * other virtual machines need not support it. + * + * <strong>Important:</strong> do not call this in library code that is + * not specific to Classpath's reference implementation. + * + * @param native_fd The native file descriptor integer. + * @throws IOException + */ + VMChannel(final int native_fd) throws IOException + { + this(); + this.nfd.setNativeFD(native_fd); + } + + public State getState() + { + return nfd; + } + + static + { + // load the shared library needed for native methods. + if (Configuration.INIT_LOAD_LIBRARY) + { + System.loadLibrary ("javanio"); + } + try + { + // so fare this will throw an IOException + VmChannel.initIDs(); + } + catch (IOException e) + { + } + } + + public static VMChannel getStdin() throws IOException + { + return new VMChannel(VmChannel.stdin_fd()); + } + + public static VMChannel getStdout() throws IOException + { + return new VMChannel(VmChannel.stdout_fd()); + } + + public static VMChannel getStderr() throws IOException + { + return new VMChannel(VmChannel.stderr_fd()); + } + + + /** + * Set the file descriptor to have the required blocking + * setting. + * + * @param blocking The blocking flag to set. + */ + public void setBlocking(boolean blocking) throws IOException + { + VmChannel.setBlocking(nfd.getNativeFD(), blocking); + } + + + public int available() throws IOException + { + return VmChannel.available(nfd.getNativeFD()); + } + + + /** + * Reads a byte buffer directly using the supplied file descriptor. + * + * @param dst Direct Byte Buffer to read to. + * @return Number of bytes read. + * @throws IOException If an error occurs or dst is not a direct buffers. + */ + public int read(ByteBuffer dst) + throws IOException + { + return VmChannel.read(nfd.getNativeFD(), dst); + } + + /** + * Read a single byte. + * + * @return The byte read, or -1 on end of file. + * @throws IOException + */ + public int read() throws IOException + { + return VmChannel.read(nfd.getNativeFD()); + } + + + /** + * Reads into byte buffers directly using the supplied file descriptor. + * Assumes that the buffer list contains DirectBuffers. Will perform a + * scattering read. + * + * @param dsts An array direct byte buffers. + * @param offset Index of the first buffer to read to. + * @param length The number of buffers to read to. + * @return Number of bytes read. + * @throws IOException If an error occurs or the dsts are not direct buffers. + */ + public long readScattering(ByteBuffer[] dsts, int offset, int length) + throws IOException + { + if (offset + length > dsts.length) + throw new IndexOutOfBoundsException("offset + length > dsts.length"); + + return VmChannel.readScattering(nfd.getNativeFD(), dsts, offset, length); + } + + + /** + * Receive a datagram on this channel, returning the host address + * that sent the datagram. + * + * @param dst Where to store the datagram. + * @return The host address that sent the datagram. + * @throws IOException + */ + public SocketAddress receive(ByteBuffer dst) throws IOException + { + if (kind != Kind.SOCK_DGRAM) + throw new SocketException("not a datagram socket"); + ByteBuffer hostPort = ByteBuffer.allocateDirect(18); + int hostlen = VmChannel.receive(nfd.getNativeFD(), dst, hostPort); + if (hostlen == 0) + return null; + if (hostlen == 4) // IPv4 + { + byte[] addr = new byte[4]; + hostPort.get(addr); + int port = hostPort.getShort() & 0xFFFF; + return new InetSocketAddress(Inet4Address.getByAddress(addr), port); + } + if (hostlen == 16) // IPv6 + { + byte[] addr = new byte[16]; + hostPort.get(addr); + int port = hostPort.getShort() & 0xFFFF; + return new InetSocketAddress(Inet6Address.getByAddress(addr), port); + } + + throw new SocketException("host address received with invalid length: " + + hostlen); + } + + /** + * Writes from a direct byte bufer using the supplied file descriptor. + * Assumes the buffer is a DirectBuffer. + * + * @param src The source buffer. + * @return Number of bytes written. + * @throws IOException + */ + public int write(ByteBuffer src) throws IOException + { + return VmChannel.write(nfd.getNativeFD(), src); + } + + + /** + * Writes from byte buffers directly using the supplied file descriptor. + * Assumes the that buffer list constains DirectBuffers. Will perform + * as gathering write. + * + * @param fd + * @param srcs + * @param offset + * @param length + * @return Number of bytes written. + * @throws IOException + */ + public long writeGathering(ByteBuffer[] srcs, int offset, int length) + throws IOException + { + if (offset + length > srcs.length) + throw new IndexOutOfBoundsException("offset + length > srcs.length"); + + // A gathering write is limited to 16 buffers; when writing, ensure + // that we have at least one buffer with something in it in the 16 + // buffer window starting at offset. + while (!srcs[offset].hasRemaining() && offset < srcs.length) + offset++; + + // There are no buffers with anything to write. + if (offset == srcs.length) + return 0; + + // If we advanced `offset' so far that we don't have `length' + // buffers left, reset length to only the remaining buffers. + if (length > srcs.length - offset) + length = srcs.length - offset; + + return VmChannel.writeGathering(nfd.getNativeFD(), srcs, offset, length); + } + + + /** + * Send a datagram to the given address. + * + * @param src The source buffer. + * @param dst The destination address. + * @return The number of bytes written. + * @throws IOException + */ + public int send(ByteBuffer src, InetSocketAddress dst) + throws IOException + { + InetAddress addr = dst.getAddress(); + if (addr == null) + throw new NullPointerException(); + if (addr instanceof Inet4Address) + return VmChannel.send(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort()); + e... [truncated message content] |
From: <ls...@us...> - 2009-02-02 07:53:09
|
Revision: 4973 http://jnode.svn.sourceforge.net/jnode/?rev=4973&view=rev Author: lsantha Date: 2009-02-02 07:52:47 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Fixed header. Modified Paths: -------------- trunk/core/src/classpath/ext/java/nio/channels/LinkChannel.java trunk/core/src/classpath/ext/java/util/prefs/TransientPreferences.java trunk/core/src/classpath/ext/javax/cache/Cache.java trunk/core/src/classpath/ext/javax/cache/CacheEntry.java trunk/core/src/classpath/ext/javax/cache/CacheException.java trunk/core/src/classpath/ext/javax/cache/CacheFactory.java trunk/core/src/classpath/ext/javax/cache/CacheListener.java trunk/core/src/classpath/ext/javax/cache/CacheLoader.java trunk/core/src/classpath/ext/javax/cache/CacheManager.java trunk/core/src/classpath/ext/javax/cache/CacheStatistics.java trunk/core/src/classpath/ext/javax/cache/EvictionStrategy.java trunk/core/src/classpath/ext/javax/isolate/AbstractLinkMessageHandler.java trunk/core/src/classpath/ext/javax/isolate/ClosedLinkException.java trunk/core/src/classpath/ext/javax/isolate/Isolate.java trunk/core/src/classpath/ext/javax/isolate/IsolatePermission.java trunk/core/src/classpath/ext/javax/isolate/IsolateStartupException.java trunk/core/src/classpath/ext/javax/isolate/IsolateStatus.java trunk/core/src/classpath/ext/javax/isolate/Link.java trunk/core/src/classpath/ext/javax/isolate/LinkMessage.java trunk/core/src/classpath/ext/javax/isolate/LinkMessageDispatcher.java trunk/core/src/classpath/ext/javax/isolate/LinkMessageHandler.java trunk/core/src/classpath/ext/javax/isolate/StreamBindings.java trunk/core/src/classpath/vm/gnu/classpath/Configuration.java trunk/core/src/classpath/vm/gnu/classpath/VMSystemProperties.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/JNodeSocketTransport.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMFrame.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMMethod.java trunk/core/src/classpath/vm/gnu/classpath/jdwp/NativeVMVirtualMachine.java trunk/core/src/classpath/vm/gnu/java/lang/VMClassHelper.java trunk/core/src/classpath/vm/gnu/java/nio/VMPipe.java trunk/core/src/classpath/vm/gnu/java/nio/VMSelector.java trunk/core/src/classpath/vm/gnu/java/security/action/GetPolicyAction.java trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java trunk/core/src/classpath/vm/gnu/java/security/action/InvokeAction.java trunk/core/src/classpath/vm/gnu/java/security/action/SetPropertyAction.java trunk/core/src/classpath/vm/gnu/java/security/util/SimplePermissionCollection.java trunk/core/src/classpath/vm/java/awt/VMAwtAPI.java trunk/core/src/classpath/vm/java/awt/image/VMImageAPI.java trunk/core/src/classpath/vm/java/awt/image/VMImageUtils.java trunk/core/src/classpath/vm/java/io/VMFile.java trunk/core/src/classpath/vm/java/io/VMFileSystemAPI.java trunk/core/src/classpath/vm/java/io/VMIOUtils.java trunk/core/src/classpath/vm/java/io/VMObjectInputStream.java trunk/core/src/classpath/vm/java/io/VMObjectStreamClass.java trunk/core/src/classpath/vm/java/io/VMOpenMode.java trunk/core/src/classpath/vm/java/lang/ClassLoader.java trunk/core/src/classpath/vm/java/lang/VMClassLoader.java trunk/core/src/classpath/vm/java/lang/VMRuntime.java trunk/core/src/classpath/vm/java/lang/VMSecurityManager.java trunk/core/src/classpath/vm/java/net/ExSocketOptions.java trunk/core/src/classpath/vm/java/net/VMInetAddress.java trunk/core/src/classpath/vm/java/net/VMNetAPI.java trunk/core/src/classpath/vm/java/net/VMNetAny.java trunk/core/src/classpath/vm/java/net/VMNetDevice.java trunk/core/src/classpath/vm/java/net/VMNetUtils.java trunk/core/src/classpath/vm/java/net/VMNetworkInterface.java trunk/core/src/classpath/vm/java/net/VMURLConnection.java trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java trunk/core/src/classpath/vm/java/security/VMSecureRandom.java trunk/core/src/classpath/vm/org/jnode/java/io/VMFileHandle.java trunk/core/src/core/org/jnode/assembler/BootImageNativeStream.java trunk/core/src/core/org/jnode/assembler/Label.java trunk/core/src/core/org/jnode/assembler/NativeStream.java trunk/core/src/core/org/jnode/assembler/ObjectResolver.java trunk/core/src/core/org/jnode/assembler/UnresolvedObjectRefException.java trunk/core/src/core/org/jnode/assembler/x86/InvalidOpcodeException.java trunk/core/src/core/org/jnode/assembler/x86/X86Assembler.java trunk/core/src/core/org/jnode/assembler/x86/X86BinaryAssembler.java trunk/core/src/core/org/jnode/assembler/x86/X86Constants.java trunk/core/src/core/org/jnode/assembler/x86/X86Operation.java trunk/core/src/core/org/jnode/assembler/x86/X86Register.java trunk/core/src/core/org/jnode/assembler/x86/X86TextAssembler.java trunk/core/src/core/org/jnode/assembler/x86/X86Utils.java trunk/core/src/core/org/jnode/boot/InitJarProcessor.java trunk/core/src/core/org/jnode/boot/Main.java trunk/core/src/core/org/jnode/boot/MemoryResourceInputStream.java trunk/core/src/core/org/jnode/boot/NoCloseInputStream.java trunk/core/src/core/org/jnode/debug/RemoteAppender.java trunk/core/src/core/org/jnode/debug/RemoteReceiver.java trunk/core/src/core/org/jnode/debug/UDPOutputStream.java trunk/core/src/core/org/jnode/debugger/DebugState.java trunk/core/src/core/org/jnode/debugger/Debugger.java trunk/core/src/core/org/jnode/debugger/DebuggerPlugin.java trunk/core/src/core/org/jnode/debugger/DebuggerUtils.java trunk/core/src/core/org/jnode/debugger/RootState.java trunk/core/src/core/org/jnode/debugger/ThreadListState.java trunk/core/src/core/org/jnode/debugger/ThreadState.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoder.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoderAdapter.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGException.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGImageReader.java trunk/core/src/core/org/jnode/imageio/jpeg/JPEGImageReaderSpi.java trunk/core/src/core/org/jnode/log4j/config/JNodeSystemAppender.java trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java trunk/core/src/core/org/jnode/log4j/config/UnsafeDebugAppender.java trunk/core/src/core/org/jnode/log4j/config/VirtualConsoleAppender.java trunk/core/src/core/org/jnode/naming/AbstractNameSpace.java trunk/core/src/core/org/jnode/naming/DefaultNameSpace.java trunk/core/src/core/org/jnode/naming/InitialNaming.java trunk/core/src/core/org/jnode/naming/NameSpace.java trunk/core/src/core/org/jnode/naming/NameSpaceListener.java trunk/core/src/core/org/jnode/plugin/AutoUnzipPlugin.java trunk/core/src/core/org/jnode/plugin/ConfigurationElement.java trunk/core/src/core/org/jnode/plugin/Extension.java trunk/core/src/core/org/jnode/plugin/ExtensionPoint.java trunk/core/src/core/org/jnode/plugin/ExtensionPointListener.java trunk/core/src/core/org/jnode/plugin/FragmentDescriptor.java trunk/core/src/core/org/jnode/plugin/Library.java trunk/core/src/core/org/jnode/plugin/Plugin.java trunk/core/src/core/org/jnode/plugin/PluginClassLoader.java trunk/core/src/core/org/jnode/plugin/PluginDescriptor.java trunk/core/src/core/org/jnode/plugin/PluginDescriptorListener.java trunk/core/src/core/org/jnode/plugin/PluginException.java trunk/core/src/core/org/jnode/plugin/PluginLoader.java trunk/core/src/core/org/jnode/plugin/PluginLoaderManager.java trunk/core/src/core/org/jnode/plugin/PluginManager.java trunk/core/src/core/org/jnode/plugin/PluginPrerequisite.java trunk/core/src/core/org/jnode/plugin/PluginReference.java trunk/core/src/core/org/jnode/plugin/PluginRegistry.java trunk/core/src/core/org/jnode/plugin/PluginSecurityConstants.java trunk/core/src/core/org/jnode/plugin/PluginUtils.java trunk/core/src/core/org/jnode/plugin/Runtime.java trunk/core/src/core/org/jnode/plugin/URLPluginLoader.java trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginLoaderManager.java trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java trunk/core/src/core/org/jnode/plugin/model/AbstractModelObject.java trunk/core/src/core/org/jnode/plugin/model/AttributeModel.java trunk/core/src/core/org/jnode/plugin/model/ConfigurationElementModel.java trunk/core/src/core/org/jnode/plugin/model/EmptyPlugin.java trunk/core/src/core/org/jnode/plugin/model/ExtensionModel.java trunk/core/src/core/org/jnode/plugin/model/ExtensionPointModel.java trunk/core/src/core/org/jnode/plugin/model/Factory.java trunk/core/src/core/org/jnode/plugin/model/FragmentDescriptorModel.java trunk/core/src/core/org/jnode/plugin/model/LibraryModel.java trunk/core/src/core/org/jnode/plugin/model/PluginClassLoaderImpl.java trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java trunk/core/src/core/org/jnode/plugin/model/PluginJar.java trunk/core/src/core/org/jnode/plugin/model/PluginModelObject.java trunk/core/src/core/org/jnode/plugin/model/PluginPrerequisiteModel.java trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java trunk/core/src/core/org/jnode/plugin/model/PluginsClassLoader.java trunk/core/src/core/org/jnode/plugin/model/RuntimeModel.java trunk/core/src/core/org/jnode/protocol/ProtocolHandlerFactoryPlugin.java trunk/core/src/core/org/jnode/protocol/plugin/Handler.java trunk/core/src/core/org/jnode/protocol/plugin/PluginURLConnection.java trunk/core/src/core/org/jnode/protocol/system/Handler.java trunk/core/src/core/org/jnode/protocol/system/SystemURLConnection.java trunk/core/src/core/org/jnode/security/JNodePermission.java trunk/core/src/core/org/jnode/security/JNodePolicy.java trunk/core/src/core/org/jnode/security/JNodeSecurityManager.java trunk/core/src/core/org/jnode/security/SecurityPlugin.java trunk/core/src/core/org/jnode/system/BootLog.java trunk/core/src/core/org/jnode/system/DMAException.java trunk/core/src/core/org/jnode/system/DMAManager.java trunk/core/src/core/org/jnode/system/DMAResource.java trunk/core/src/core/org/jnode/system/IOResource.java trunk/core/src/core/org/jnode/system/IRQHandler.java trunk/core/src/core/org/jnode/system/IRQResource.java trunk/core/src/core/org/jnode/system/MemoryResource.java trunk/core/src/core/org/jnode/system/MemoryScanner.java trunk/core/src/core/org/jnode/system/MultiMediaMemoryResource.java trunk/core/src/core/org/jnode/system/Resource.java trunk/core/src/core/org/jnode/system/ResourceManager.java trunk/core/src/core/org/jnode/system/ResourceNotFreeException.java trunk/core/src/core/org/jnode/system/ResourceOwner.java trunk/core/src/core/org/jnode/system/ResourcePermission.java trunk/core/src/core/org/jnode/system/SimpleResourceOwner.java trunk/core/src/core/org/jnode/system/event/FocusEvent.java trunk/core/src/core/org/jnode/system/event/FocusListener.java trunk/core/src/core/org/jnode/system/event/SystemEvent.java trunk/core/src/core/org/jnode/system/repository/Repository.java trunk/core/src/core/org/jnode/system/repository/RepositoryPlugin.java trunk/core/src/core/org/jnode/system/repository/RepositoryPluginLoader.java trunk/core/src/core/org/jnode/system/repository/SystemRepository.java trunk/core/src/core/org/jnode/system/repository/SystemRepositoryPlugin.java trunk/core/src/core/org/jnode/system/repository/plugins/PluginLoaderPlugin.java trunk/core/src/core/org/jnode/system/repository/spi/SystemRepositoryProvider.java trunk/core/src/core/org/jnode/system/x86/DMA.java trunk/core/src/core/org/jnode/system/x86/DMAConstants.java trunk/core/src/core/org/jnode/system/x86/DMAPlugin.java trunk/core/src/core/org/jnode/system/x86/X86DMAChannel.java trunk/core/src/core/org/jnode/util/AccessControllerUtils.java trunk/core/src/core/org/jnode/util/BCDUtils.java trunk/core/src/core/org/jnode/util/BeanUtils.java trunk/core/src/core/org/jnode/util/BigEndian.java trunk/core/src/core/org/jnode/util/BinaryScaleFactor.java trunk/core/src/core/org/jnode/util/BooleanUtils.java trunk/core/src/core/org/jnode/util/BootableArrayList.java trunk/core/src/core/org/jnode/util/BootableHashMap.java trunk/core/src/core/org/jnode/util/ByteBufferInputStream.java trunk/core/src/core/org/jnode/util/ByteBufferUtils.java trunk/core/src/core/org/jnode/util/ByteQueue.java trunk/core/src/core/org/jnode/util/ByteQueueProcessor.java trunk/core/src/core/org/jnode/util/ByteQueueProcessorThread.java trunk/core/src/core/org/jnode/util/ChannelInputStream.java trunk/core/src/core/org/jnode/util/ChannelOutputStream.java trunk/core/src/core/org/jnode/util/Command.java trunk/core/src/core/org/jnode/util/ConsoleStream.java trunk/core/src/core/org/jnode/util/Counter.java trunk/core/src/core/org/jnode/util/CounterGroup.java trunk/core/src/core/org/jnode/util/DecimalScaleFactor.java trunk/core/src/core/org/jnode/util/EmptyInputStream.java trunk/core/src/core/org/jnode/util/FileUtils.java trunk/core/src/core/org/jnode/util/IOUtils.java trunk/core/src/core/org/jnode/util/JarBuffer.java trunk/core/src/core/org/jnode/util/JarConstants.java trunk/core/src/core/org/jnode/util/LittleEndian.java trunk/core/src/core/org/jnode/util/NumberUtils.java trunk/core/src/core/org/jnode/util/ObjectArrayIterator.java trunk/core/src/core/org/jnode/util/ObjectUtils.java trunk/core/src/core/org/jnode/util/OsUtils.java trunk/core/src/core/org/jnode/util/ProxyStream.java trunk/core/src/core/org/jnode/util/ProxyStreamException.java trunk/core/src/core/org/jnode/util/Queue.java trunk/core/src/core/org/jnode/util/QueueProcessor.java trunk/core/src/core/org/jnode/util/QueueProcessorThread.java trunk/core/src/core/org/jnode/util/ReaderInputStream.java trunk/core/src/core/org/jnode/util/ScaleFactor.java trunk/core/src/core/org/jnode/util/SizeUnit.java trunk/core/src/core/org/jnode/util/Statistic.java trunk/core/src/core/org/jnode/util/Statistics.java trunk/core/src/core/org/jnode/util/StopWatch.java trunk/core/src/core/org/jnode/util/SynchronizedCounter.java trunk/core/src/core/org/jnode/util/SystemInputStream.java trunk/core/src/core/org/jnode/util/TimeUtils.java trunk/core/src/core/org/jnode/util/TimeoutException.java trunk/core/src/core/org/jnode/util/Token.java trunk/core/src/core/org/jnode/util/WriterOutputStream.java trunk/core/src/core/org/jnode/vm/AllocationBitmap.java trunk/core/src/core/org/jnode/vm/BootableObject.java trunk/core/src/core/org/jnode/vm/CpuID.java trunk/core/src/core/org/jnode/vm/HeapHelperImpl.java trunk/core/src/core/org/jnode/vm/IOContext.java trunk/core/src/core/org/jnode/vm/IOResourceImpl.java trunk/core/src/core/org/jnode/vm/JvmType.java trunk/core/src/core/org/jnode/vm/LoadCompileService.java trunk/core/src/core/org/jnode/vm/LoadCompileThread.java trunk/core/src/core/org/jnode/vm/MathSupport.java trunk/core/src/core/org/jnode/vm/MemoryBlockManager.java trunk/core/src/core/org/jnode/vm/MemoryMapEntry.java trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java trunk/core/src/core/org/jnode/vm/MemoryScannerImpl.java trunk/core/src/core/org/jnode/vm/MultiMediaMemoryResourceImpl.java trunk/core/src/core/org/jnode/vm/ObjectVisitor.java trunk/core/src/core/org/jnode/vm/RTCService.java trunk/core/src/core/org/jnode/vm/Region.java trunk/core/src/core/org/jnode/vm/ResourceLoader.java trunk/core/src/core/org/jnode/vm/ResourceManagerImpl.java trunk/core/src/core/org/jnode/vm/SoftByteCodes.java trunk/core/src/core/org/jnode/vm/Unsafe.java trunk/core/src/core/org/jnode/vm/VirtualMemoryRegion.java trunk/core/src/core/org/jnode/vm/Vm.java trunk/core/src/core/org/jnode/vm/VmAbstractClassLoader.java trunk/core/src/core/org/jnode/vm/VmAccessControlContext.java trunk/core/src/core/org/jnode/vm/VmAccessController.java trunk/core/src/core/org/jnode/vm/VmAddress.java trunk/core/src/core/org/jnode/vm/VmArchitecture.java trunk/core/src/core/org/jnode/vm/VmChannel.java trunk/core/src/core/org/jnode/vm/VmExit.java trunk/core/src/core/org/jnode/vm/VmIOContext.java trunk/core/src/core/org/jnode/vm/VmJavaClassLoader.java trunk/core/src/core/org/jnode/vm/VmJavaMultiMediaSupport.java trunk/core/src/core/org/jnode/vm/VmMagic.java trunk/core/src/core/org/jnode/vm/VmMultiMediaSupport.java trunk/core/src/core/org/jnode/vm/VmProcess.java trunk/core/src/core/org/jnode/vm/VmProcessClassLoader.java trunk/core/src/core/org/jnode/vm/VmReflection.java trunk/core/src/core/org/jnode/vm/VmStackFrame.java trunk/core/src/core/org/jnode/vm/VmStackFrameEnumerator.java trunk/core/src/core/org/jnode/vm/VmStackReader.java trunk/core/src/core/org/jnode/vm/VmSystem.java trunk/core/src/core/org/jnode/vm/VmSystemClassLoader.java trunk/core/src/core/org/jnode/vm/VmSystemObject.java trunk/core/src/core/org/jnode/vm/VmUtils.java trunk/core/src/core/org/jnode/vm/annotation/AllowedPackages.java trunk/core/src/core/org/jnode/vm/annotation/CheckPermission.java trunk/core/src/core/org/jnode/vm/annotation/DoPrivileged.java trunk/core/src/core/org/jnode/vm/annotation/Inline.java trunk/core/src/core/org/jnode/vm/annotation/Internal.java trunk/core/src/core/org/jnode/vm/annotation/KernelSpace.java trunk/core/src/core/org/jnode/vm/annotation/LoadStatics.java trunk/core/src/core/org/jnode/vm/annotation/MagicPermission.java trunk/core/src/core/org/jnode/vm/annotation/NoFieldAlignments.java trunk/core/src/core/org/jnode/vm/annotation/NoInline.java trunk/core/src/core/org/jnode/vm/annotation/NoReadBarrier.java trunk/core/src/core/org/jnode/vm/annotation/NoWriteBarrier.java trunk/core/src/core/org/jnode/vm/annotation/PrivilegedActionPragma.java trunk/core/src/core/org/jnode/vm/annotation/SharedStatics.java trunk/core/src/core/org/jnode/vm/annotation/Uninterruptible.java trunk/core/src/core/org/jnode/vm/bytecode/BasicBlock.java trunk/core/src/core/org/jnode/vm/bytecode/BasicBlockFinder.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeFlags.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeParser.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeViewer.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeVisitorSupport.java trunk/core/src/core/org/jnode/vm/bytecode/BytecodeWriter.java trunk/core/src/core/org/jnode/vm/bytecode/ControlFlowGraph.java trunk/core/src/core/org/jnode/vm/bytecode/DelegatingBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/bytecode/StackException.java trunk/core/src/core/org/jnode/vm/bytecode/TypeStack.java trunk/core/src/core/org/jnode/vm/classmgr/AbstractCode.java trunk/core/src/core/org/jnode/vm/classmgr/AbstractExceptionHandler.java trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java trunk/core/src/core/org/jnode/vm/classmgr/CompiledCodeList.java trunk/core/src/core/org/jnode/vm/classmgr/IMTBuilder.java trunk/core/src/core/org/jnode/vm/classmgr/MethodPragmaFlags.java trunk/core/src/core/org/jnode/vm/classmgr/Modifier.java trunk/core/src/core/org/jnode/vm/classmgr/NotResolvedYetException.java trunk/core/src/core/org/jnode/vm/classmgr/ObjectFlags.java trunk/core/src/core/org/jnode/vm/classmgr/ObjectLayout.java trunk/core/src/core/org/jnode/vm/classmgr/SelectorMap.java trunk/core/src/core/org/jnode/vm/classmgr/Signature.java trunk/core/src/core/org/jnode/vm/classmgr/TIBBuilder.java trunk/core/src/core/org/jnode/vm/classmgr/TIBLayout.java trunk/core/src/core/org/jnode/vm/classmgr/TypePragmaFlags.java trunk/core/src/core/org/jnode/vm/classmgr/TypeSizeInfo.java trunk/core/src/core/org/jnode/vm/classmgr/VmAddressMap.java trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotatedElement.java trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java trunk/core/src/core/org/jnode/vm/classmgr/VmArray.java trunk/core/src/core/org/jnode/vm/classmgr/VmArrayClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmByteCode.java trunk/core/src/core/org/jnode/vm/classmgr/VmCP.java trunk/core/src/core/org/jnode/vm/classmgr/VmClassLoader.java trunk/core/src/core/org/jnode/vm/classmgr/VmClassType.java trunk/core/src/core/org/jnode/vm/classmgr/VmCompiledCode.java trunk/core/src/core/org/jnode/vm/classmgr/VmCompiledExceptionHandler.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstDouble.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstFieldRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstFloat.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstIMethodRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstInt.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstLong.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstMemberRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstMethodRef.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstObject.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstString.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java trunk/core/src/core/org/jnode/vm/classmgr/VmExceptions.java trunk/core/src/core/org/jnode/vm/classmgr/VmField.java trunk/core/src/core/org/jnode/vm/classmgr/VmImplementedInterface.java trunk/core/src/core/org/jnode/vm/classmgr/VmInstanceField.java trunk/core/src/core/org/jnode/vm/classmgr/VmInstanceMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmInterfaceClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmInterpretedExceptionHandler.java trunk/core/src/core/org/jnode/vm/classmgr/VmIsolatedStatics.java trunk/core/src/core/org/jnode/vm/classmgr/VmIsolatedStaticsEntry.java trunk/core/src/core/org/jnode/vm/classmgr/VmLineNumberMap.java trunk/core/src/core/org/jnode/vm/classmgr/VmLocalVariable.java trunk/core/src/core/org/jnode/vm/classmgr/VmLocalVariableTable.java trunk/core/src/core/org/jnode/vm/classmgr/VmMember.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethodCode.java trunk/core/src/core/org/jnode/vm/classmgr/VmNormalClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmObject.java trunk/core/src/core/org/jnode/vm/classmgr/VmPrimitiveClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmResolvableConstObject.java trunk/core/src/core/org/jnode/vm/classmgr/VmSharedStatics.java trunk/core/src/core/org/jnode/vm/classmgr/VmSharedStaticsEntry.java trunk/core/src/core/org/jnode/vm/classmgr/VmSpecialMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticField.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmStatics.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticsAllocator.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticsBase.java trunk/core/src/core/org/jnode/vm/classmgr/VmStaticsIterator.java trunk/core/src/core/org/jnode/vm/classmgr/VmType.java trunk/core/src/core/org/jnode/vm/classmgr/VmTypeState.java trunk/core/src/core/org/jnode/vm/classmgr/VmUTF8Convert.java trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java trunk/core/src/core/org/jnode/vm/compiler/CompileError.java trunk/core/src/core/org/jnode/vm/compiler/CompiledExceptionHandler.java trunk/core/src/core/org/jnode/vm/compiler/CompiledIMT.java trunk/core/src/core/org/jnode/vm/compiler/CompiledMethod.java trunk/core/src/core/org/jnode/vm/compiler/CompilerBytecodeParser.java trunk/core/src/core/org/jnode/vm/compiler/CompilerBytecodeViewer.java trunk/core/src/core/org/jnode/vm/compiler/CompilerBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/DelegatingCompilerBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/EntryPoints.java trunk/core/src/core/org/jnode/vm/compiler/GCMapIterator.java trunk/core/src/core/org/jnode/vm/compiler/IMTCompiler.java trunk/core/src/core/org/jnode/vm/compiler/IllegalModeException.java trunk/core/src/core/org/jnode/vm/compiler/InlineBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/NativeCodeCompiler.java trunk/core/src/core/org/jnode/vm/compiler/OptimizingBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/VerifyingCompilerBytecodeVisitor.java trunk/core/src/core/org/jnode/vm/compiler/ir/AddressingMode.java trunk/core/src/core/org/jnode/vm/compiler/ir/CodeGenerator.java trunk/core/src/core/org/jnode/vm/compiler/ir/Constant.java trunk/core/src/core/org/jnode/vm/compiler/ir/DoubleConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/FloatConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRBasicBlock.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRBasicBlockFinder.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRControlFlowGraph.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRGenerator.java trunk/core/src/core/org/jnode/vm/compiler/ir/IRTest.java trunk/core/src/core/org/jnode/vm/compiler/ir/IntConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/LinearScanAllocator.java trunk/core/src/core/org/jnode/vm/compiler/ir/LiveRange.java trunk/core/src/core/org/jnode/vm/compiler/ir/LocalVariable.java trunk/core/src/core/org/jnode/vm/compiler/ir/Location.java trunk/core/src/core/org/jnode/vm/compiler/ir/LongConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/MethodArgument.java trunk/core/src/core/org/jnode/vm/compiler/ir/NativeTest.java trunk/core/src/core/org/jnode/vm/compiler/ir/Operand.java trunk/core/src/core/org/jnode/vm/compiler/ir/PhiOperand.java trunk/core/src/core/org/jnode/vm/compiler/ir/PrimitiveTest.java trunk/core/src/core/org/jnode/vm/compiler/ir/ReferenceConstant.java trunk/core/src/core/org/jnode/vm/compiler/ir/RegisterLocation.java trunk/core/src/core/org/jnode/vm/compiler/ir/RegisterPool.java trunk/core/src/core/org/jnode/vm/compiler/ir/SSAStack.java trunk/core/src/core/org/jnode/vm/compiler/ir/StackLocation.java trunk/core/src/core/org/jnode/vm/compiler/ir/StackVariable.java trunk/core/src/core/org/jnode/vm/compiler/ir/Variable.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/AssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BinaryOperation.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BinaryQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BranchCondition.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/BranchQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/ConditionalBranchQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/ConstantRefAssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/PhiAssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/Quad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/UnaryOperation.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/UnaryQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/UnconditionalBranchQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/VarReturnQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/VariableRefAssignQuad.java trunk/core/src/core/org/jnode/vm/compiler/ir/quad/VoidReturnQuad.java trunk/core/src/core/org/jnode/vm/isolate/DataLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/IsolateLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/IsolateStatusImpl.java trunk/core/src/core/org/jnode/vm/isolate/IsolateThread.java trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java trunk/core/src/core/org/jnode/vm/isolate/LinkImpl.java trunk/core/src/core/org/jnode/vm/isolate/LinkLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/LinkMessageFactory.java trunk/core/src/core/org/jnode/vm/isolate/LinkMessageImpl.java trunk/core/src/core/org/jnode/vm/isolate/ObjectLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/StatusLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/StringLinkMessage.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolateLocal.java trunk/core/src/core/org/jnode/vm/isolate/VmLink.java trunk/core/src/core/org/jnode/vm/isolate/VmStreamBindings.java trunk/core/src/core/org/jnode/vm/memmgr/GCStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/HeapHelper.java trunk/core/src/core/org/jnode/vm/memmgr/HeapStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/VmHeapManager.java trunk/core/src/core/org/jnode/vm/memmgr/VmWriteBarrier.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefGCStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefaultHeapManager.java trunk/core/src/core/org/jnode/vm/memmgr/def/DefaultWriteBarrier.java trunk/core/src/core/org/jnode/vm/memmgr/def/FinalizerThread.java trunk/core/src/core/org/jnode/vm/memmgr/def/FinalizerVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCManager.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCMarkVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCSetWhiteVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCStack.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCSweepVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCThread.java trunk/core/src/core/org/jnode/vm/memmgr/def/GCVerifyVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/HeapStatisticsVisitor.java trunk/core/src/core/org/jnode/vm/memmgr/def/VmAbstractHeap.java trunk/core/src/core/org/jnode/vm/memmgr/def/VmBootHeap.java trunk/core/src/core/org/jnode/vm/memmgr/def/VmDefaultHeap.java trunk/core/src/core/org/jnode/vm/performance/PerformanceCounterEvent.java trunk/core/src/core/org/jnode/vm/performance/PerformanceCounters.java trunk/core/src/core/org/jnode/vm/performance/PresetEvent.java trunk/core/src/core/org/jnode/vm/scheduler/IRQManager.java trunk/core/src/core/org/jnode/vm/scheduler/IRQThread.java trunk/core/src/core/org/jnode/vm/scheduler/IdleThread.java trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java trunk/core/src/core/org/jnode/vm/scheduler/ProcessorLock.java trunk/core/src/core/org/jnode/vm/scheduler/SpinLock.java trunk/core/src/core/org/jnode/vm/scheduler/SystemThread.java trunk/core/src/core/org/jnode/vm/scheduler/VmProcessor.java trunk/core/src/core/org/jnode/vm/scheduler/VmScheduler.java trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java trunk/core/src/core/org/jnode/vm/scheduler/VmThreadQueue.java trunk/core/src/core/org/jnode/vm/scheduler/VmThreadQueueEntry.java trunk/core/src/core/org/jnode/vm/scheduler/VmThreadVisitor.java trunk/core/src/core/org/jnode/vm/x86/GDT.java trunk/core/src/core/org/jnode/vm/x86/IOAPIC.java trunk/core/src/core/org/jnode/vm/x86/IOAPICRedirectionEntry.java trunk/core/src/core/org/jnode/vm/x86/LocalAPIC.java trunk/core/src/core/org/jnode/vm/x86/MMXMultiMediaSupport.java trunk/core/src/core/org/jnode/vm/x86/MPBusEntry.java trunk/core/src/core/org/jnode/vm/x86/MPConfigTable.java trunk/core/src/core/org/jnode/vm/x86/MPEntry.java trunk/core/src/core/org/jnode/vm/x86/MPFloatingPointerStructure.java trunk/core/src/core/org/jnode/vm/x86/MPIOAPICEntry.java trunk/core/src/core/org/jnode/vm/x86/MPIOInterruptAssignmentEntry.java trunk/core/src/core/org/jnode/vm/x86/MPInterruptAssignmentEntry.java trunk/core/src/core/org/jnode/vm/x86/MPLocalInterruptAssignmentEntry.java trunk/core/src/core/org/jnode/vm/x86/MPProcessorEntry.java trunk/core/src/core/org/jnode/vm/x86/MSR.java trunk/core/src/core/org/jnode/vm/x86/PIC8259A.java trunk/core/src/core/org/jnode/vm/x86/TSS32.java trunk/core/src/core/org/jnode/vm/x86/UnsafeX86.java trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture.java trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture32.java trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture64.java trunk/core/src/core/org/jnode/vm/x86/VmX86Processor.java trunk/core/src/core/org/jnode/vm/x86/VmX86Processor32.java trunk/core/src/core/org/jnode/vm/x86/VmX86Processor64.java trunk/core/src/core/org/jnode/vm/x86/VmX86StackReader.java trunk/core/src/core/org/jnode/vm/x86/VmX86Thread.java trunk/core/src/core/org/jnode/vm/x86/VmX86Thread32.java trunk/core/src/core/org/jnode/vm/x86/VmX86Thread64.java trunk/core/src/core/org/jnode/vm/x86/X86Cpu.java trunk/core/src/core/org/jnode/vm/x86/X86CpuID.java trunk/core/src/core/org/jnode/vm/x86/X86IRQManager.java trunk/core/src/core/org/jnode/vm/x86/X86MemoryMapEntry.java trunk/core/src/core/org/jnode/vm/x86/X86Vendor.java trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86Compiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86StackManager.java trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86CompiledIMT.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86CompilerConstants.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86CompilerHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86IMTCompiler32.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86IMTCompiler64.java trunk/core/src/core/org/jnode/vm/x86/compiler/X86JumpTable.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/DoubleItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/DoubleWordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/EmitterContext.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompilerFPU.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompilerSSE.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPUHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPUStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FloatItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/InlinedMethodInfo.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/IntItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/Item.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/ItemStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/ItemVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/L1AHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/LongItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/RefItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/RegisterVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/VirtualStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/WordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86GCMapIterator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86Level1ACompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86RegisterPool.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86StackFrame.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/DoubleItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/DoubleWordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/EmitterContext.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompilerFPU.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompilerSSE.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPUHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPUStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FloatItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/InlinedMethodInfo.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/IntItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/Item.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/ItemFactory.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/ItemStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/ItemVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/L1AHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/LongItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/RefItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/RegisterVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/VirtualStack.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/WordItem.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86GCMapIterator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86Level1BCompiler.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86RegisterPool.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86StackFrame.java trunk/core/src/core/org/jnode/vm/x86/compiler/l2/GenericX86CodeGenerator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l2/X86CodeGenerator.java trunk/core/src/core/org/jnode/vm/x86/compiler/l2/X86RegisterPool.java trunk/core/src/core/org/jnode/vm/x86/compiler/stub/EmptyGCMapIterator.java trunk/core/src/core/org/jnode/vm/x86/compiler/stub/X86StubCompiler.java trunk/core/src/core/org/jnode/vm/x86/performance/Athlon64PerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/DualMSRPerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/P4FamilyPerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/P6PerformanceCouters.java trunk/core/src/core/org/jnode/vm/x86/performance/Pentium4PerformanceCounters.java trunk/core/src/core/org/jnode/vm/x86/performance/X86PerformanceCounters.java trunk/core/src/core/org/jnode/work/Work.java trunk/core/src/core/org/jnode/work/WorkManager.java trunk/core/src/core/org/jnode/work/WorkPlugin.java trunk/core/src/core/org/jnode/work/WorkUtils.java trunk/core/src/driver/org/jnode/driver/AbstractDeviceManager.java trunk/core/src/driver/org/jnode/driver/ApiNotFoundException.java trunk/core/src/driver/org/jnode/driver/Bus.java trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java trunk/core/src/driver/org/jnode/driver/Device.java trunk/core/src/driver/org/jnode/driver/DeviceAPI.java trunk/core/src/driver/org/jnode/driver/DeviceAlreadyConnectedException.java trunk/core/src/driver/org/jnode/driver/DeviceAlreadyRegisteredException.java trunk/core/src/driver/org/jnode/driver/DeviceException.java trunk/core/src/driver/org/jnode/driver/DeviceFinder.java trunk/core/src/driver/org/jnode/driver/DeviceFinderPlugin.java trunk/core/src/driver/org/jnode/driver/DeviceInfoAPI.java trunk/core/src/driver/org/jnode/driver/DeviceListener.java trunk/core/src/driver/org/jnode/driver/DeviceManager.java trunk/core/src/driver/org/jnode/driver/DeviceManagerListener.java trunk/core/src/driver/org/jnode/driver/DeviceNotFoundException.java trunk/core/src/driver/org/jnode/driver/DeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/DeviceUtils.java trunk/core/src/driver/org/jnode/driver/Driver.java trunk/core/src/driver/org/jnode/driver/DriverException.java trunk/core/src/driver/org/jnode/driver/DriverPermission.java trunk/core/src/driver/org/jnode/driver/DriverPlugin.java trunk/core/src/driver/org/jnode/driver/InvalidDriverException.java trunk/core/src/driver/org/jnode/driver/RemovableDeviceAPI.java trunk/core/src/driver/org/jnode/driver/bus/firewire/FireWireBus.java trunk/core/src/driver/org/jnode/driver/bus/firewire/FireWireDevice.java trunk/core/src/driver/org/jnode/driver/bus/firewire/FireWireDriver.java trunk/core/src/driver/org/jnode/driver/bus/pci/AGPCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/AbstractPCIDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/pci/Capability.java trunk/core/src/driver/org/jnode/driver/bus/pci/CompactHotSwapCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/DeviceDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/pci/MSICapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIBaseAddress.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIBus.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIBusAPI.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIClassToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIConstants.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDescriptors.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDevice.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDeviceConfig.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIDriver.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIException.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIFinder.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIHeaderType0.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIHeaderType1.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIHeaderType2.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCIRomAddress.java trunk/core/src/driver/org/jnode/driver/bus/pci/PCI_IDs.java trunk/core/src/driver/org/jnode/driver/bus/pci/PMCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/SlotIDCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/VPDCapability.java trunk/core/src/driver/org/jnode/driver/bus/pci/VendorDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/pcmcia/CardBusBus.java trunk/core/src/driver/org/jnode/driver/bus/pcmcia/CardBusDevice.java trunk/core/src/driver/org/jnode/driver/bus/pcmcia/CardBusDriver.java trunk/core/src/driver/org/jnode/driver/bus/smbus/DIMM.java trunk/core/src/driver/org/jnode/driver/bus/smbus/DIMMDriver.java trunk/core/src/driver/org/jnode/driver/bus/smbus/SMBus.java trunk/core/src/driver/org/jnode/driver/bus/smbus/SMBusControler.java trunk/core/src/driver/org/jnode/driver/bus/smbus/SMBusDevice.java trunk/core/src/driver/org/jnode/driver/bus/usb/AbstractDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/AbstractDeviceItem.java trunk/core/src/driver/org/jnode/driver/bus/usb/AbstractHostControllerDriver.java trunk/core/src/driver/org/jnode/driver/bus/usb/ConfigurationDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/DeviceDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/EndPointDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/InterfaceDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/SetupPacket.java trunk/core/src/driver/org/jnode/driver/bus/usb/StringDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/StringDescriptorZero.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBBus.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBConfiguration.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBConstants.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBControlPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBDataPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBDevice.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBEndPoint.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBException.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBHostControllerAPI.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBHubAPI.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBHubMonitor.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBInterface.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBPacket.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBPipeListener.java trunk/core/src/driver/org/jnode/driver/bus/usb/USBRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/HubDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/PortStatus.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/USBHubConstants.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/USBHubDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/bus/usb/hub/USBHubDriver.java trunk/core/src/driver/org/jnode/driver/bus/usb/spi/AbstractUSBControlRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/spi/AbstractUSBDataRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/spi/AbstractUSBRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/AbstractStructure.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/AbstractTreeStructure.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/FrameList.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/QueueHead.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/Schedule.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/TransferDescriptor.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIConstants.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIControlPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIControlRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCICore.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDataPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDataRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDriver.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIIO.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIPipe.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIPipeManager.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIRequest.java trunk/core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIRootHub.java trunk/core/src/driver/org/jnode/driver/character/ChannelAlreadyOwnedException.java trunk/core/src/driver/org/jnode/driver/character/CharacterDeviceAPI.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i440BXDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI_SMBusControler.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ISABridge.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_USBController.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82443BX_HostPCIBridge.java trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82443BX_PCIPCIBridge.java trunk/core/src/driver/org/jnode/driver/chipset/via/Via82C686.java trunk/core/src/driver/org/jnode/driver/chipset/via/Via8363_0.java trunk/core/src/driver/org/jnode/driver/chipset/via/ViaDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/chipset/via/ViaQuirks.java trunk/core/src/driver/org/jnode/driver/console/ActiveTextConsole.java trunk/core/src/driver/org/jnode/driver/console/CompletionInfo.java trunk/core/src/driver/org/jnode/driver/console/Console.java trunk/core/src/driver/org/jnode/driver/console/ConsoleEvent.java trunk/core/src/driver/org/jnode/driver/console/ConsoleException.java trunk/core/src/driver/org/jnode/driver/console/ConsoleListener.java trunk/core/src/driver/org/jnode/driver/console/ConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/InputCompleter.java trunk/core/src/driver/org/jnode/driver/console/InputHistory.java trunk/core/src/driver/org/jnode/driver/console/KeyEventBindings.java trunk/core/src/driver/org/jnode/driver/console/ScrollableTextConsole.java trunk/core/src/driver/org/jnode/driver/console/TextConsole.java trunk/core/src/driver/org/jnode/driver/console/VirtualKey.java trunk/core/src/driver/org/jnode/driver/console/VirtualTextConsole.java trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsole.java trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/spi/ConsoleWriter.java trunk/core/src/driver/org/jnode/driver/console/textscreen/ConsoleKeyEventBindings.java trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReader.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReaderAction.java trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsolePlugin.java trunk/core/src/driver/org/jnode/driver/input/AbstractInputDriver.java trunk/core/src/driver/org/jnode/driver/input/AbstractKeyboardDriver.java trunk/core/src/driver/org/jnode/driver/input/AbstractKeyboardInterpreter.java trunk/core/src/driver/org/jnode/driver/input/AbstractPointerDriver.java trunk/core/src/driver/org/jnode/driver/input/DeadKeyException.java trunk/core/src/driver/org/jnode/driver/input/Key.java trunk/core/src/driver/org/jnode/driver/input/KeyboardAPI.java trunk/core/src/driver/org/jnode/driver/input/KeyboardAPIAdapter.java trunk/core/src/driver/org/jnode/driver/input/KeyboardAdapter.java trunk/core/src/driver/org/jnode/driver/input/KeyboardConstants.java trunk/core/src/driver/org/jnode/driver/input/KeyboardEvent.java trunk/core/src/driver/org/jnode/driver/input/KeyboardInputPlugin.java trunk/core/src/driver/org/jnode/driver/input/KeyboardInterpreter.java trunk/core/src/driver/org/jnode/driver/input/KeyboardInterpreterException.java trunk/core/src/driver/org/jnode/driver/input/KeyboardLayoutManager.java trunk/core/src/driver/org/jnode/driver/input/KeyboardListener.java trunk/core/src/driver/org/jnode/driver/input/Keys.java trunk/core/src/driver/org/jnode/driver/input/LogitechProtocol.java trunk/core/src/driver/org/jnode/driver/input/LogitechWheelMouseProtocol.java trunk/core/src/driver/org/jnode/driver/input/MissingKeyboardInterpreterClassException.java trunk/core/src/driver/org/jnode/driver/input/MouseInterpreter.java trunk/core/src/driver/org/jnode/driver/input/MouseProtocolHandler.java trunk/core/src/driver/org/jnode/driver/input/PointerAPI.java trunk/core/src/driver/org/jnode/driver/input/PointerAPIAdapter.java trunk/core/src/driver/org/jnode/driver/input/PointerEvent.java trunk/core/src/driver/org/jnode/driver/input/PointerInterpreter.java trunk/core/src/driver/org/jnode/driver/input/PointerListener.java trunk/core/src/driver/org/jnode/driver/input/SystemListener.java trunk/core/src/driver/org/jnode/driver/input/SystemTriggerAPI.java trunk/core/src/driver/org/jnode/driver/input/SystemTriggerListener.java trunk/core/src/driver/org/jnode/driver/input/UnsupportedKeyException.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_BE_fr.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_CH_fr.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_DE.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_DK.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_DV.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_ES.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_FR.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_FR_fr.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_GB_en.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU_101.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU_hu.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_HU_hu_101.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_IT.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_IT_it.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_NO.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_RU.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_SE.java trunk/core/src/driver/org/jnode/driver/input/l10n/KeyboardInterpreter_US_en.java trunk/core/src/driver/org/jnode/driver/serial/SerialPortAPI.java trunk/core/src/driver/org/jnode/driver/serial/SerialPortDriver.java trunk/core/src/driver/org/jnode/driver/serial/SerialPortFinder.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiAPI.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiDeviceToDriverMapper.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiDriver.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiSystemTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/AcpiTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/DifferentiatedSystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/ExtendedSystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/FirmwareAcpiControlStructure.java trunk/core/src/driver/org/jnode/driver/system/acpi/FixedAcpiDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/GenericAddress.java trunk/core/src/driver/org/jnode/driver/system/acpi/RSDP.java trunk/core/src/driver/org/jnode/driver/system/acpi/RootSystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/SystemDescriptionTable.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/Aml.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/AmlOpcode.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/NameString.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/ParseNode.java trunk/core/src/driver/org/jnode/driver/system/acpi/aml/Parser.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/AcpiInteger.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/AcpiNamedObject.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/AcpiObject.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/Buffer.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/ByteField.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/Device.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/NameSpace.java trunk/core/src/driver/org/jnode/driver/system/acpi/vm/Scope.java trunk/core/src/driver/org/jnode/driver/system/cmos/CMOSConstants.java trunk/core/src/driver/org/jnode/driver/system/cmos/CMOSService.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/CMOS.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/CMOSPlugin.java trunk/core/src/driver/org/jnode/driver/system/cmos/def/RTC.java trunk/core/src/driver/org/jnode/driver/system/firmware/AcpiDevice.java trunk/core/src/driver/org/jnode/driver/system/firmware/AcpiRSDPInfo.java trunk/core/src/driver/org/jnode/driver/system/firmware/FirmwareAPI.java trunk/core/src/driver/org/jnode/driver/system/firmware/bios/BiosDriver.java trunk/core/src/driver/org/jnode/driver/system/firmware/bios/BiosFinder.java trunk/core/src/driver/org/jnode/driver/system/pnp/PnP.java trunk/core/src/driver/org/jnode/driver/system/ram/RAMControler.java trunk/core/src/driver/org/jnode/driver/system/ram/RAMModuleCollection.java trunk/core/src/driver/org/jnode/driver/system/ram/RAMModuleInfo.java trunk/core/src/driver/org/jnode/driver/textscreen/ScrollableTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/TextScreenManager.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenManager.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenPlugin.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenUtils.java trunk/core/src/driver/org/jnode/driver/virtual/VirtualDevice.java trunk/core/src/driver/org/jnode/driver/virtual/VirtualDeviceDriver.java trunk/core/src/driver/org/jnode/driver/virtual/VirtualDeviceFactory.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/BaseMmtkGCStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/BaseMmtkHeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/GenRCStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/HeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/Plan.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/genrc/PlanConstants.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/HeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/MarkSweepStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/Plan.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/ms/PlanConstants.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/HeapManager.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/NoGCStatistics.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/Plan.java trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/nogc/PlanConstants.java trunk/core/src/openjdk/vm/com/sun/java/util/jar/pack/NativeNativeUnpack.java trunk/core/src/openjdk/vm/com/sun/java/util/jar/pack/Pack200Command.java trunk/core/src/openjdk/vm/com/sun/java/util/jar/pack/Unpack200Command.java trunk/core/src/openjdk/vm/java/awt/NativeAWTEvent.java trunk/core/src/openjdk/vm/java/awt/NativeButton.java trunk/core/src/openjdk/vm/java/awt/NativeCheckbox.java trunk/core/src/openjdk/vm/java/awt/NativeCheckboxMenuItem.java trunk/core/src/openjdk/vm/java/awt/NativeColor.java trunk/core/src/openjdk/vm/java/awt/NativeComponent.java trunk/core/src/openjdk/vm/java/awt/NativeContainer.java trunk/core/src/openjdk/vm/java/awt/NativeDialog.java trunk/core/src/openjdk/vm/java/awt/NativeDimension.java trunk/core/src/openjdk/vm/java/awt/NativeEvent.java trunk/core... [truncated message content] |
From: <ls...@us...> - 2009-02-14 20:30:02
|
Revision: 5025 http://jnode.svn.sourceforge.net/jnode/?rev=5025&view=rev Author: lsantha Date: 2009-02-14 20:29:54 +0000 (Sat, 14 Feb 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/core/src/classpath/java/java/net/Socket.java Added Paths: ----------- trunk/core/src/openjdk/com/com/sun/crypto/ trunk/core/src/openjdk/com/com/sun/crypto/provider/ trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/AESConstants.java trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCrypt.java trunk/core/src/openjdk/com/com/sun/crypto/provider/AESKeyGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/AESParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/AESWrapCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/ARCFOURCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/BlockCipherParamsCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/BlowfishCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/BlowfishConstants.java trunk/core/src/openjdk/com/com/sun/crypto/provider/BlowfishCrypt.java trunk/core/src/openjdk/com/com/sun/crypto/provider/BlowfishKeyGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/BlowfishParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/CipherBlockChaining.java trunk/core/src/openjdk/com/com/sun/crypto/provider/CipherCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/CipherFeedback.java trunk/core/src/openjdk/com/com/sun/crypto/provider/CipherTextStealing.java trunk/core/src/openjdk/com/com/sun/crypto/provider/CipherWithWrappingSpi.java trunk/core/src/openjdk/com/com/sun/crypto/provider/ConstructKeys.java trunk/core/src/openjdk/com/com/sun/crypto/provider/CounterMode.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESConstants.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESCrypt.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESKey.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESKeyFactory.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESKeyGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeCrypt.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeKey.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeKeyFactory.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeKeyGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DESedeWrapCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHKeyAgreement.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHKeyFactory.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHKeyPairGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHParameterGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHPrivateKey.java trunk/core/src/openjdk/com/com/sun/crypto/provider/DHPublicKey.java trunk/core/src/openjdk/com/com/sun/crypto/provider/ElectronicCodeBook.java trunk/core/src/openjdk/com/com/sun/crypto/provider/EncryptedPrivateKeyInfo.java trunk/core/src/openjdk/com/com/sun/crypto/provider/FeedbackCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/HmacCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/HmacMD5.java trunk/core/src/openjdk/com/com/sun/crypto/provider/HmacMD5KeyGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/HmacPKCS12PBESHA1.java trunk/core/src/openjdk/com/com/sun/crypto/provider/HmacSHA1.java trunk/core/src/openjdk/com/com/sun/crypto/provider/HmacSHA1KeyGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/ISO10126Padding.java trunk/core/src/openjdk/com/com/sun/crypto/provider/JarVerifier.java trunk/core/src/openjdk/com/com/sun/crypto/provider/JceKeyStore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/KeyGeneratorCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/KeyProtector.java trunk/core/src/openjdk/com/com/sun/crypto/provider/OAEPParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/OutputFeedback.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBECipherCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBEKey.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBEKeyFactory.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBEParameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBEWithMD5AndDESCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBEWithMD5AndTripleDESCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBKDF2HmacSHA1Factory.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PBKDF2KeyImpl.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PCBC.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PKCS12PBECipherCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PKCS5Padding.java trunk/core/src/openjdk/com/com/sun/crypto/provider/Padding.java trunk/core/src/openjdk/com/com/sun/crypto/provider/PrivateKeyInfo.java trunk/core/src/openjdk/com/com/sun/crypto/provider/RC2Cipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/RC2Crypt.java trunk/core/src/openjdk/com/com/sun/crypto/provider/RC2Parameters.java trunk/core/src/openjdk/com/com/sun/crypto/provider/RSACipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/SslMacCore.java trunk/core/src/openjdk/com/com/sun/crypto/provider/SunJCE.java trunk/core/src/openjdk/com/com/sun/crypto/provider/SymmetricCipher.java trunk/core/src/openjdk/com/com/sun/crypto/provider/TlsKeyMaterialGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/TlsMasterSecretGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/TlsPrfGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/TlsRsaPremasterSecretGenerator.java trunk/core/src/openjdk/com/com/sun/crypto/provider/ai.java trunk/core/src/openjdk/com/com/sun/net/ssl/internal/ssl/Provider.java trunk/core/src/openjdk/javax/javax/crypto/BadPaddingException.java trunk/core/src/openjdk/javax/javax/crypto/Cipher.java trunk/core/src/openjdk/javax/javax/crypto/CipherInputStream.java trunk/core/src/openjdk/javax/javax/crypto/CipherOutputStream.java trunk/core/src/openjdk/javax/javax/crypto/CipherSpi.java trunk/core/src/openjdk/javax/javax/crypto/CryptoAllPermission.java trunk/core/src/openjdk/javax/javax/crypto/CryptoPermission.java trunk/core/src/openjdk/javax/javax/crypto/CryptoPermissions.java trunk/core/src/openjdk/javax/javax/crypto/CryptoPolicyParser.java trunk/core/src/openjdk/javax/javax/crypto/EncryptedPrivateKeyInfo.java trunk/core/src/openjdk/javax/javax/crypto/ExemptionMechanism.java trunk/core/src/openjdk/javax/javax/crypto/ExemptionMechanismException.java trunk/core/src/openjdk/javax/javax/crypto/ExemptionMechanismSpi.java trunk/core/src/openjdk/javax/javax/crypto/IllegalBlockSizeException.java trunk/core/src/openjdk/javax/javax/crypto/JarVerifier.java trunk/core/src/openjdk/javax/javax/crypto/JceSecurity.java trunk/core/src/openjdk/javax/javax/crypto/JceSecurityManager.java trunk/core/src/openjdk/javax/javax/crypto/KeyAgreement.java trunk/core/src/openjdk/javax/javax/crypto/KeyAgreementSpi.java trunk/core/src/openjdk/javax/javax/crypto/KeyGenerator.java trunk/core/src/openjdk/javax/javax/crypto/KeyGeneratorSpi.java trunk/core/src/openjdk/javax/javax/crypto/Mac.java trunk/core/src/openjdk/javax/javax/crypto/MacSpi.java trunk/core/src/openjdk/javax/javax/crypto/NoSuchPaddingException.java trunk/core/src/openjdk/javax/javax/crypto/NullCipher.java trunk/core/src/openjdk/javax/javax/crypto/NullCipherSpi.java trunk/core/src/openjdk/javax/javax/crypto/SealedObject.java trunk/core/src/openjdk/javax/javax/crypto/SecretKey.java trunk/core/src/openjdk/javax/javax/crypto/SecretKeyFactory.java trunk/core/src/openjdk/javax/javax/crypto/SecretKeyFactorySpi.java trunk/core/src/openjdk/javax/javax/crypto/ShortBufferException.java trunk/core/src/openjdk/javax/javax/crypto/interfaces/ trunk/core/src/openjdk/javax/javax/crypto/interfaces/DHKey.java trunk/core/src/openjdk/javax/javax/crypto/interfaces/DHPrivateKey.java trunk/core/src/openjdk/javax/javax/crypto/interfaces/DHPublicKey.java trunk/core/src/openjdk/javax/javax/crypto/interfaces/PBEKey.java trunk/core/src/openjdk/javax/javax/crypto/interfaces/package.html trunk/core/src/openjdk/javax/javax/crypto/package.html trunk/core/src/openjdk/javax/javax/crypto/spec/DESKeySpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/DESedeKeySpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/DHGenParameterSpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/DHParameterSpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/DHPrivateKeySpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/DHPublicKeySpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/IvParameterSpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/PBEKeySpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/PBEParameterSpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/RC2ParameterSpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/RC5ParameterSpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/SecretKeySpec.java trunk/core/src/openjdk/javax/javax/crypto/spec/package.html trunk/core/src/openjdk/sun/sun/nio/ch/DirectBuffer.java Removed Paths: ------------- trunk/core/src/classpath/javax/javax/crypto/ Modified: trunk/core/src/classpath/java/java/net/Socket.java =================================================================== --- trunk/core/src/classpath/java/java/net/Socket.java 2009-02-14 20:24:42 UTC (rev 5024) +++ trunk/core/src/classpath/java/java/net/Socket.java 2009-02-14 20:29:54 UTC (rev 5025) @@ -1270,4 +1270,9 @@ { return outputShutdown; } + + //jnode openjdk + public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) { + //TODO implement it + } } Added: trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCipher.java =================================================================== --- trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCipher.java (rev 0) +++ trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCipher.java 2009-02-14 20:29:54 UTC (rev 5025) @@ -0,0 +1,431 @@ +/* + * Copyright 2002-2007 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package com.sun.crypto.provider; + +import java.security.*; +import java.security.spec.*; +import javax.crypto.*; +import javax.crypto.spec.*; +import javax.crypto.BadPaddingException; + +/** + * This class implements the AES algorithm in its various modes + * (<code>ECB</code>, <code>CFB</code>, <code>OFB</code>, <code>CBC</code>, + * <code>PCBC</code>) and padding schemes (<code>PKCS5Padding</code>, + * <code>NoPadding</code>, <code>ISO10126Padding</code>). + * + * @author Valerie Peng + * + * + * @see AESCrypt + * @see CipherBlockChaining + * @see ElectronicCodeBook + * @see CipherFeedback + * @see OutputFeedback + */ + +public final class AESCipher extends CipherSpi { + /* + * internal CipherCore object which does the real work. + */ + private CipherCore core = null; + + /** + * Creates an instance of AES cipher with default ECB mode and + * PKCS5Padding. + * + * @exception SecurityException if this constructor fails to verify + * its own integrity + */ + public AESCipher() { + SunJCE.ensureIntegrity(getClass()); + core = new CipherCore(new AESCrypt(), AESConstants.AES_BLOCK_SIZE); + } + + /** + * Sets the mode of this cipher. + * + * @param mode the cipher mode + * + * @exception NoSuchAlgorithmException if the requested cipher mode does + * not exist + */ + protected void engineSetMode(String mode) + throws NoSuchAlgorithmException { + core.setMode(mode); + } + + /** + * Sets the padding mechanism of this cipher. + * + * @param padding the padding mechanism + * + * @exception NoSuchPaddingException if the requested padding mechanism + * does not exist + */ + protected void engineSetPadding(String paddingScheme) + throws NoSuchPaddingException { + core.setPadding(paddingScheme); + } + + /** + * Returns the block size (in bytes). + * + * @return the block size (in bytes), or 0 if the underlying algorithm is + * not a block cipher + */ + protected int engineGetBlockSize() { + return AESConstants.AES_BLOCK_SIZE; + } + + /** + * Returns the length in bytes that an output buffer would need to be in + * order to hold the result of the next <code>update</code> or + * <code>doFinal</code> operation, given the input length + * <code>inputLen</code> (in bytes). + * + * <p>This call takes into account any unprocessed (buffered) data from a + * previous <code>update</code> call, and padding. + * + * <p>The actual output length of the next <code>update</code> or + * <code>doFinal</code> call may be smaller than the length returned by + * this method. + * + * @param inputLen the input length (in bytes) + * + * @return the required output buffer size (in bytes) + */ + protected int engineGetOutputSize(int inputLen) { + return core.getOutputSize(inputLen); + } + + /** + * Returns the initialization vector (IV) in a new buffer. + * + * <p>This is useful in the case where a random IV has been created + * (see <a href = "#init">init</a>), + * or in the context of password-based encryption or + * decryption, where the IV is derived from a user-provided password. + * + * @return the initialization vector in a new buffer, or null if the + * underlying algorithm does not use an IV, or if the IV has not yet + * been set. + */ + protected byte[] engineGetIV() { + return core.getIV(); + } + + /** + * Returns the parameters used with this cipher. + * + * <p>The returned parameters may be the same that were used to initialize + * this cipher, or may contain the default set of parameters or a set of + * randomly generated parameters used by the underlying cipher + * implementation (provided that the underlying cipher implementation + * uses a default set of parameters or creates new parameters if it needs + * parameters but was not initialized with any). + * + * @return the parameters used with this cipher, or null if this cipher + * does not use any parameters. + */ + protected AlgorithmParameters engineGetParameters() { + return core.getParameters("AES"); + } + + /** + * Initializes this cipher with a key and a source of randomness. + * + * <p>The cipher is initialized for one of the following four operations: + * encryption, decryption, key wrapping or key unwrapping, depending on + * the value of <code>opmode</code>. + * + * <p>If this cipher requires an initialization vector (IV), it will get + * it from <code>random</code>. + * This behaviour should only be used in encryption or key wrapping + * mode, however. + * When initializing a cipher that requires an IV for decryption or + * key unwrapping, the IV + * (same IV that was used for encryption or key wrapping) must be provided + * explicitly as a + * parameter, in order to get the correct result. + * + * <p>This method also cleans existing buffer and other related state + * information. + * + * @param opmode the operation mode of this cipher (this is one of + * the following: + * <code>ENCRYPT_MODE</code>, <code>DECRYPT_MODE</code>, + * <code>WRAP_MODE</code> or <code>UNWRAP_MODE</code>) + * @param key the secret key + * @param random the source of randomness + * + * @exception InvalidKeyException if the given key is inappropriate for + * initializing this cipher + */ + protected void engineInit(int opmode, Key key, SecureRandom random) + throws InvalidKeyException { + core.init(opmode, key, random); + } + + /** + * Initializes this cipher with a key, a set of + * algorithm parameters, and a source of randomness. + * + * <p>The cipher is initialized for one of the following four operations: + * encryption, decryption, key wrapping or key unwrapping, depending on + * the value of <code>opmode</code>. + * + * <p>If this cipher (including its underlying feedback or padding scheme) + * requires any random bytes, it will get them from <code>random</code>. + * + * @param opmode the operation mode of this cipher (this is one of + * the following: + * <code>ENCRYPT_MODE</code>, <code>DECRYPT_MODE</code>, + * <code>WRAP_MODE</code> or <code>UNWRAP_MODE</code>) + * @param key the encryption key + * @param params the algorithm parameters + * @param random the source of randomness + * + * @exception InvalidKeyException if the given key is inappropriate for + * initializing this cipher + * @exception InvalidAlgorithmParameterException if the given algorithm + * parameters are inappropriate for this cipher + */ + protected void engineInit(int opmode, Key key, + AlgorithmParameterSpec params, + SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { + core.init(opmode, key, params, random); + } + + protected void engineInit(int opmode, Key key, + AlgorithmParameters params, + SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { + core.init(opmode, key, params, random); + } + + /** + * Continues a multiple-part encryption or decryption operation + * (depending on how this cipher was initialized), processing another data + * part. + * + * <p>The first <code>inputLen</code> bytes in the <code>input</code> + * buffer, starting at <code>inputOffset</code>, are processed, and the + * result is stored in a new buffer. + * + * @param input the input buffer + * @param inputOffset the offset in <code>input</code> where the input + * starts + * @param inputLen the input length + * + * @return the new buffer with the result + * + * @exception IllegalStateException if this cipher is in a wrong state + * (e.g., has not been initialized) + */ + protected byte[] engineUpdate(byte[] input, int inputOffset, + int inputLen) { + return core.update(input, inputOffset, inputLen); + } + + /** + * Continues a multiple-part encryption or decryption operation + * (depending on how this cipher was initialized), processing another data + * part. + * + * <p>The first <code>inputLen</code> bytes in the <code>input</code> + * buffer, starting at <code>inputOffset</code>, are processed, and the + * result is stored in the <code>output</code> buffer, starting at + * <code>outputOffset</code>. + * + * @param input the input buffer + * @param inputOffset the offset in <code>input</code> where the input + * starts + * @param inputLen the input length + * @param output the buffer for the result + * @param outputOffset the offset in <code>output</code> where the result + * is stored + * + * @return the number of bytes stored in <code>output</code> + * + * @exception ShortBufferException if the given output buffer is too small + * to hold the result + */ + protected int engineUpdate(byte[] input, int inputOffset, int inputLen, + byte[] output, int outputOffset) + throws ShortBufferException { + return core.update(input, inputOffset, inputLen, output, + outputOffset); + } + + /** + * Encrypts or decrypts data in a single-part operation, + * or finishes a multiple-part operation. + * The data is encrypted or decrypted, depending on how this cipher was + * initialized. + * + * <p>The first <code>inputLen</code> bytes in the <code>input</code> + * buffer, starting at <code>inputOffset</code>, and any input bytes that + * may have been buffered during a previous <code>update</code> operation, + * are processed, with padding (if requested) being applied. + * The result is stored in a new buffer. + * + * <p>The cipher is reset to its initial state (uninitialized) after this + * call. + * + * @param input the input buffer + * @param inputOffset the offset in <code>input</code> where the input + * starts + * @param inputLen the input length + * + * @return the new buffer with the result + * + * @exception IllegalBlockSizeException if this cipher is a block cipher, + * no padding has been requested (only in encryption mode), and the total + * input length of the data processed by this cipher is not a multiple of + * block size + * @exception BadPaddingException if this cipher is in decryption mode, + * and (un)padding has been requested, but the decrypted data is not + * bounded by the appropriate padding bytes + */ + protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) + throws IllegalBlockSizeException, BadPaddingException { + return core.doFinal(input, inputOffset, inputLen); + } + + /** + * Encrypts or decrypts data in a single-part operation, + * or finishes a multiple-part operation. + * The data is encrypted or decrypted, depending on how this cipher was + * initialized. + * + * <p>The first <code>inputLen</code> bytes in the <code>input</code> + * buffer, starting at <code>inputOffset</code>, and any input bytes that + * may have been buffered during a previous <code>update</code> operation, + * are processed, with padding (if requested) being applied. + * The result is stored in the <code>output</code> buffer, starting at + * <code>outputOffset</code>. + * + * <p>The cipher is reset to its initial state (uninitialized) after this + * call. + * + * @param input the input buffer + * @param inputOffset the offset in <code>input</code> where the input + * starts + * @param inputLen the input length + * @param output the buffer for the result + * @param outputOffset the offset in <code>output</code> where the result + * is stored + * + * @return the number of bytes stored in <code>output</code> + * + * @exception IllegalBlockSizeException if this cipher is a block cipher, + * no padding has been requested (only in encryption mode), and the total + * input length of the data processed by this cipher is not a multiple of + * block size + * @exception ShortBufferException if the given output buffer is too small + * to hold the result + * @exception BadPaddingException if this cipher is in decryption mode, + * and (un)padding has been requested, but the decrypted data is not + * bounded by the appropriate padding bytes + */ + protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, + byte[] output, int outputOffset) + throws IllegalBlockSizeException, ShortBufferException, + BadPaddingException { + return core.doFinal(input, inputOffset, inputLen, output, + outputOffset); + } + + /** + * Returns the key size of the given key object. + * + * @param key the key object. + * + * @return the key size of the given key object. + * + * @exception InvalidKeyException if <code>key</code> is invalid. + */ + protected int engineGetKeySize(Key key) throws InvalidKeyException { + byte[] encoded = key.getEncoded(); + if (!AESCrypt.isKeySizeValid(encoded.length)) { + throw new InvalidKeyException("Invalid AES key length: " + + encoded.length + " bytes"); + } + return encoded.length * 8; + } + + /** + * Wrap a key. + * + * @param key the key to be wrapped. + * + * @return the wrapped key. + * + * @exception IllegalBlockSizeException if this cipher is a block + * cipher, no padding has been requested, and the length of the + * encoding of the key to be wrapped is not a + * multiple of the block size. + * + * @exception InvalidKeyException if it is impossible or unsafe to + * wrap the key with this cipher (e.g., a hardware protected key is + * being passed to a software only cipher). + */ + protected byte[] engineWrap(Key key) + throws IllegalBlockSizeException, InvalidKeyException { + return core.wrap(key); + } + + /** + * Unwrap a previously wrapped key. + * + * @param wrappedKey the key to be unwrapped. + * + * @param wrappedKeyAlgorithm the algorithm the wrapped key is for. + * + * @param wrappedKeyType the type of the wrapped key. + * This is one of <code>Cipher.SECRET_KEY</code>, + * <code>Cipher.PRIVATE_KEY</code>, or <code>Cipher.PUBLIC_KEY</code>. + * + * @return the unwrapped key. + * + * @exception NoSuchAlgorithmException if no installed providers + * can create keys of type <code>wrappedKeyType</code> for the + * <code>wrappedKeyAlgorithm</code>. + * + * @exception InvalidKeyException if <code>wrappedKey</code> does not + * represent a wrapped key of type <code>wrappedKeyType</code> for + * the <code>wrappedKeyAlgorithm</code>. + */ + protected Key engineUnwrap(byte[] wrappedKey, + String wrappedKeyAlgorithm, + int wrappedKeyType) + throws InvalidKeyException, NoSuchAlgorithmException { + return core.unwrap(wrappedKey, wrappedKeyAlgorithm, + wrappedKeyType); + } +} Added: trunk/core/src/openjdk/com/com/sun/crypto/provider/AESConstants.java =================================================================== --- trunk/core/src/openjdk/com/com/sun/crypto/provider/AESConstants.java (rev 0) +++ trunk/core/src/openjdk/com/com/sun/crypto/provider/AESConstants.java 2009-02-14 20:29:54 UTC (rev 5025) @@ -0,0 +1,46 @@ +/* + * Copyright 2002-2007 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package com.sun.crypto.provider; + +/** + * This class defines the constants used by the AES implementation. + * + * @author Valerie Peng + * + * + * @see AESCipher + */ + +interface AESConstants { + + // AES block size in bytes. + int AES_BLOCK_SIZE = 16; + + // Valid AES key sizes in bytes. + // NOTE: The values need to be listed in an *increasing* order + // since DHKeyAgreement depends on this fact. + int[] AES_KEYSIZES = { 16, 24, 32 }; +} Added: trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCrypt.java =================================================================== --- trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCrypt.java (rev 0) +++ trunk/core/src/openjdk/com/com/sun/crypto/provider/AESCrypt.java 2009-02-14 20:29:54 UTC (rev 5025) @@ -0,0 +1,658 @@ +/* + * Copyright 2002-2007 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* $Id: Rijndael.java,v 1.6 2000/02/10 01:31:41 gelderen Exp $ + * + * Copyright (C) 1995-2000 The Cryptix Foundation Limited. + * All rights reserved. + * + * Use, modification, copying and distribution of this softwareas is subject + * the terms and conditions of the Cryptix General Licence. You should have + * received a copy of the Cryptix General Licence along with this library; + * if not, you can download a copy from http://www.cryptix.org/ . + */ + +package com.sun.crypto.provider; + +import java.security.InvalidKeyException; + +/** + * Rijndael --pronounced Reindaal-- is a symmetric cipher with a 128-bit + * block size and variable key-size (128-, 192- and 256-bit). + * <p> + * Rijndael was designed by <a href="mailto:ri...@es...">Vincent + * Rijmen</a> and <a href="mailto:Joa...@vi...">Joan Daemen</a>. + */ +final class AESCrypt extends SymmetricCipher implements AESConstants +{ + private boolean ROUNDS_12 = false; + private boolean ROUNDS_14 = false; + + /** Session and Sub keys */ + private Object[] sessionK = null; + private int[] K = null; + + /** (ROUNDS-1) * 4 */ + private int limit = 0; + + AESCrypt() { + // empty + } + + /** + * Returns this cipher's block size. + * + * @return this cipher's block size + */ + int getBlockSize() { + return AES_BLOCK_SIZE; + } + + void init(boolean decrypting, String algorithm, byte[] key) + throws InvalidKeyException { + if (!algorithm.equalsIgnoreCase("AES") + && !algorithm.equalsIgnoreCase("Rijndael")) { + throw new InvalidKeyException + ("Wrong algorithm: AES or Rijndael required"); + } + if (!isKeySizeValid(key.length)) { + throw new InvalidKeyException("Invalid AES key length: " + + key.length + " bytes"); + } + + // generate session key and reset sub key. + sessionK = makeKey(key); + setSubKey(decrypting); + } + + private void setSubKey(boolean decrypting) { + int[][] Kd = (int[][]) sessionK[decrypting ? 1 : 0]; + int rounds = Kd.length; + this.K = new int[rounds*4]; + for(int i=0; i<rounds; i++) { + for(int j=0; j<4; j++) { + K[i*4 + j] = Kd[i][j]; + } + } + + if (decrypting) { + int j0 = K[K.length-4]; + int j1 = K[K.length-3]; + int j2 = K[K.length-2]; + int j3 = K[K.length-1]; + + for (int i=this.K.length-1; i>3; i--) { + this.K[i] = this.K[i-4]; + } + K[0] = j0; + K[1] = j1; + K[2] = j2; + K[3] = j3; + } + + ROUNDS_12 = (rounds>=13); + ROUNDS_14 = (rounds==15); + + rounds--; + limit=rounds*4; + } + + private static int[] + alog = new int[256], + log = new int[256]; + + private static final byte[] + S = new byte[256], + Si = new byte[256]; + + private static final int[] + T1 = new int[256], + T2 = new int[256], + T3 = new int[256], + T4 = new int[256], + T5 = new int[256], + T6 = new int[256], + T7 = new int[256], + T8 = new int[256]; + + private static final int[] + U1 = new int[256], + U2 = new int[256], + U3 = new int[256], + U4 = new int[256]; + + private static final byte[] rcon = new byte[30]; + + + // Static code - to intialise S-boxes and T-boxes + static + { + int ROOT = 0x11B; + int i, j = 0; + + // + // produce log and alog tables, needed for multiplying in the + // field GF(2^m) (generator = 3) + // + alog[0] = 1; + for (i = 1; i < 256; i++) + { + j = (alog[i-1] << 1) ^ alog[i-1]; + if ((j & 0x100) != 0) { + j ^= ROOT; + } + alog[i] = j; + } + for (i = 1; i < 255; i++) { + log[alog[i]] = i; + } + byte[][] A = new byte[][] + { + {1, 1, 1, 1, 1, 0, 0, 0}, + {0, 1, 1, 1, 1, 1, 0, 0}, + {0, 0, 1, 1, 1, 1, 1, 0}, + {0, 0, 0, 1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1, 1, 1, 1}, + {1, 1, 0, 0, 0, 1, 1, 1}, + {1, 1, 1, 0, 0, 0, 1, 1}, + {1, 1, 1, 1, 0, 0, 0, 1} + }; + byte[] B = new byte[] { 0, 1, 1, 0, 0, 0, 1, 1}; + + // + // substitution box based on F^{-1}(x) + // + int t; + byte[][] box = new byte[256][8]; + box[1][7] = 1; + for (i = 2; i < 256; i++) { + j = alog[255 - log[i]]; + for (t = 0; t < 8; t++) { + box[i][t] = (byte)((j >>> (7 - t)) & 0x01); + } + } + // + // affine transform: box[i] <- B + A*box[i] + // + byte[][] cox = new byte[256][8]; + for (i = 0; i < 256; i++) { + for (t = 0; t < 8; t++) { + cox[i][t] = B[t]; + for (j = 0; j < 8; j++) { + cox[i][t] ^= A[t][j] * box[i][j]; + } + } + } + // + // S-boxes and inverse S-boxes + // + for (i = 0; i < 256; i++) { + S[i] = (byte)(cox[i][0] << 7); + for (t = 1; t < 8; t++) { + S[i] ^= cox[i][t] << (7-t); + } + Si[S[i] & 0xFF] = (byte) i; + } + // + // T-boxes + // + byte[][] G = new byte[][] { + {2, 1, 1, 3}, + {3, 2, 1, 1}, + {1, 3, 2, 1}, + {1, 1, 3, 2} + }; + byte[][] AA = new byte[4][8]; + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) AA[i][j] = G[i][j]; + AA[i][i+4] = 1; + } + byte pivot, tmp; + byte[][] iG = new byte[4][4]; + for (i = 0; i < 4; i++) { + pivot = AA[i][i]; + if (pivot == 0) { + t = i + 1; + while ((AA[t][i] == 0) && (t < 4)) { + t++; + } + if (t == 4) { + throw new RuntimeException("G matrix is not invertible"); + } + else { + for (j = 0; j < 8; j++) { + tmp = AA[i][j]; + AA[i][j] = AA[t][j]; + AA[t][j] = (byte) tmp; + } + pivot = AA[i][i]; + } + } + for (j = 0; j < 8; j++) { + if (AA[i][j] != 0) { + AA[i][j] = (byte) + alog[(255 + log[AA[i][j] & 0xFF] - log[pivot & 0xFF]) % 255]; + } + } + for (t = 0; t < 4; t++) { + if (i != t) { + for (j = i+1; j < 8; j++) { + AA[t][j] ^= mul(AA[i][j], AA[t][i]); + } + AA[t][i] = 0; + } + } + } + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + iG[i][j] = AA[i][j + 4]; + } + } + + int s; + for (t = 0; t < 256; t++) { + s = S[t]; + T1[t] = mul4(s, G[0]); + T2[t] = mul4(s, G[1]); + T3[t] = mul4(s, G[2]); + T4[t] = mul4(s, G[3]); + + s = Si[t]; + T5[t] = mul4(s, iG[0]); + T6[t] = mul4(s, iG[1]); + T7[t] = mul4(s, iG[2]); + T8[t] = mul4(s, iG[3]); + + U1[t] = mul4(t, iG[0]); + U2[t] = mul4(t, iG[1]); + U3[t] = mul4(t, iG[2]); + U4[t] = mul4(t, iG[3]); + } + // + // round constants + // + rcon[0] = 1; + int r = 1; + for (t = 1; t < 30; t++) { + r = mul(2, r); + rcon[t] = (byte) r; + } + log = null; + alog = null; + } + + // multiply two elements of GF(2^m) + private static final int mul (int a, int b) { + return (a != 0 && b != 0) ? + alog[(log[a & 0xFF] + log[b & 0xFF]) % 255] : + 0; + } + + // convenience method used in generating Transposition boxes + private static final int mul4 (int a, byte[] b) { + if (a == 0) return 0; + a = log[a & 0xFF]; + int a0 = (b[0] != 0) ? alog[(a + log[b[0] & 0xFF]) % 255] & 0xFF : 0; + int a1 = (b[1] != 0) ? alog[(a + log[b[1] & 0xFF]) % 255] & 0xFF : 0; + int a2 = (b[2] != 0) ? alog[(a + log[b[2] & 0xFF]) % 255] & 0xFF : 0; + int a3 = (b[3] != 0) ? alog[(a + log[b[3] & 0xFF]) % 255] & 0xFF : 0; + return a0 << 24 | a1 << 16 | a2 << 8 | a3; + } + + // check if the specified length (in bytes) is a valid keysize for AES + static final boolean isKeySizeValid(int len) { + for (int i = 0; i < AES_KEYSIZES.length; i++) { + if (len == AES_KEYSIZES[i]) { + return true; + } + } + return false; + } + + /** + * Encrypt exactly one block of plaintext. + */ + void encryptBlock(byte[] in, int inOffset, + byte[] out, int outOffset) + { + int keyOffset = 0; + int t0 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + int t1 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + int t2 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + int t3 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + + // apply round transforms + while( keyOffset < limit ) + { + int a0, a1, a2; + a0 = T1[(t0 >>> 24) ] ^ + T2[(t1 >>> 16) & 0xFF] ^ + T3[(t2 >>> 8) & 0xFF] ^ + T4[(t3 ) & 0xFF] ^ K[keyOffset++]; + a1 = T1[(t1 >>> 24) ] ^ + T2[(t2 >>> 16) & 0xFF] ^ + T3[(t3 >>> 8) & 0xFF] ^ + T4[(t0 ) & 0xFF] ^ K[keyOffset++]; + a2 = T1[(t2 >>> 24) ] ^ + T2[(t3 >>> 16) & 0xFF] ^ + T3[(t0 >>> 8) & 0xFF] ^ + T4[(t1 ) & 0xFF] ^ K[keyOffset++]; + t3 = T1[(t3 >>> 24) ] ^ + T2[(t0 >>> 16) & 0xFF] ^ + T3[(t1 >>> 8) & 0xFF] ^ + T4[(t2 ) & 0xFF] ^ K[keyOffset++]; + t0 = a0; t1 = a1; t2 = a2; + } + + // last round is special + int tt = K[keyOffset++]; + out[outOffset++] = (byte)(S[(t0 >>> 24) ] ^ (tt >>> 24)); + out[outOffset++] = (byte)(S[(t1 >>> 16) & 0xFF] ^ (tt >>> 16)); + out[outOffset++] = (byte)(S[(t2 >>> 8) & 0xFF] ^ (tt >>> 8)); + out[outOffset++] = (byte)(S[(t3 ) & 0xFF] ^ (tt )); + tt = K[keyOffset++]; + out[outOffset++] = (byte)(S[(t1 >>> 24) ] ^ (tt >>> 24)); + out[outOffset++] = (byte)(S[(t2 >>> 16) & 0xFF] ^ (tt >>> 16)); + out[outOffset++] = (byte)(S[(t3 >>> 8) & 0xFF] ^ (tt >>> 8)); + out[outOffset++] = (byte)(S[(t0 ) & 0xFF] ^ (tt )); + tt = K[keyOffset++]; + out[outOffset++] = (byte)(S[(t2 >>> 24) ] ^ (tt >>> 24)); + out[outOffset++] = (byte)(S[(t3 >>> 16) & 0xFF] ^ (tt >>> 16)); + out[outOffset++] = (byte)(S[(t0 >>> 8) & 0xFF] ^ (tt >>> 8)); + out[outOffset++] = (byte)(S[(t1 ) & 0xFF] ^ (tt )); + tt = K[keyOffset++]; + out[outOffset++] = (byte)(S[(t3 >>> 24) ] ^ (tt >>> 24)); + out[outOffset++] = (byte)(S[(t0 >>> 16) & 0xFF] ^ (tt >>> 16)); + out[outOffset++] = (byte)(S[(t1 >>> 8) & 0xFF] ^ (tt >>> 8)); + out[outOffset ] = (byte)(S[(t2 ) & 0xFF] ^ (tt )); + } + + + /** + * Decrypt exactly one block of plaintext. + */ + void decryptBlock(byte[] in, int inOffset, + byte[] out, int outOffset) + { + int keyOffset = 4; + int t0 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + int t1 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + int t2 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset++] & 0xFF) ) ^ K[keyOffset++]; + int t3 = ((in[inOffset++] ) << 24 | + (in[inOffset++] & 0xFF) << 16 | + (in[inOffset++] & 0xFF) << 8 | + (in[inOffset ] & 0xFF) ) ^ K[keyOffset++]; + + int a0, a1, a2; + if(ROUNDS_12) + { + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + t0 = T5[(a0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(a2>>> 8)&0xFF] ^ T8[(a1 )&0xFF] ^ K[keyOffset++]; + t1 = T5[(a1>>>24) ] ^ T6[(a0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(a2 )&0xFF] ^ K[keyOffset++]; + t2 = T5[(a2>>>24) ] ^ T6[(a1>>>16)&0xFF] ^ + T7[(a0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(a2>>>16)&0xFF] ^ + T7[(a1>>> 8)&0xFF] ^ T8[(a0 )&0xFF] ^ K[keyOffset++]; + + if(ROUNDS_14) + { + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + t0 = T5[(a0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(a2>>> 8)&0xFF] ^ T8[(a1 )&0xFF] ^ K[keyOffset++]; + t1 = T5[(a1>>>24) ] ^ T6[(a0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(a2 )&0xFF] ^ K[keyOffset++]; + t2 = T5[(a2>>>24) ] ^ T6[(a1>>>16)&0xFF] ^ + T7[(a0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(a2>>>16)&0xFF] ^ + T7[(a1>>> 8)&0xFF] ^ T8[(a0 )&0xFF] ^ K[keyOffset++]; + } + } + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + t0 = T5[(a0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(a2>>> 8)&0xFF] ^ T8[(a1 )&0xFF] ^ K[keyOffset++]; + t1 = T5[(a1>>>24) ] ^ T6[(a0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(a2 )&0xFF] ^ K[keyOffset++]; + t2 = T5[(a2>>>24) ] ^ T6[(a1>>>16)&0xFF] ^ + T7[(a0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(a2>>>16)&0xFF] ^ + T7[(a1>>> 8)&0xFF] ^ T8[(a0 )&0xFF] ^ K[keyOffset++]; + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + t0 = T5[(a0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(a2>>> 8)&0xFF] ^ T8[(a1 )&0xFF] ^ K[keyOffset++]; + t1 = T5[(a1>>>24) ] ^ T6[(a0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(a2 )&0xFF] ^ K[keyOffset++]; + t2 = T5[(a2>>>24) ] ^ T6[(a1>>>16)&0xFF] ^ + T7[(a0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(a2>>>16)&0xFF] ^ + T7[(a1>>> 8)&0xFF] ^ T8[(a0 )&0xFF] ^ K[keyOffset++]; + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + t0 = T5[(a0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(a2>>> 8)&0xFF] ^ T8[(a1 )&0xFF] ^ K[keyOffset++]; + t1 = T5[(a1>>>24) ] ^ T6[(a0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(a2 )&0xFF] ^ K[keyOffset++]; + t2 = T5[(a2>>>24) ] ^ T6[(a1>>>16)&0xFF] ^ + T7[(a0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(a2>>>16)&0xFF] ^ + T7[(a1>>> 8)&0xFF] ^ T8[(a0 )&0xFF] ^ K[keyOffset++]; + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + t0 = T5[(a0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(a2>>> 8)&0xFF] ^ T8[(a1 )&0xFF] ^ K[keyOffset++]; + t1 = T5[(a1>>>24) ] ^ T6[(a0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(a2 )&0xFF] ^ K[keyOffset++]; + t2 = T5[(a2>>>24) ] ^ T6[(a1>>>16)&0xFF] ^ + T7[(a0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(a2>>>16)&0xFF] ^ + T7[(a1>>> 8)&0xFF] ^ T8[(a0 )&0xFF] ^ K[keyOffset++]; + a0 = T5[(t0>>>24) ] ^ T6[(t3>>>16)&0xFF] ^ + T7[(t2>>> 8)&0xFF] ^ T8[(t1 )&0xFF] ^ K[keyOffset++]; + a1 = T5[(t1>>>24) ] ^ T6[(t0>>>16)&0xFF] ^ + T7[(t3>>> 8)&0xFF] ^ T8[(t2 )&0xFF] ^ K[keyOffset++]; + a2 = T5[(t2>>>24) ] ^ T6[(t1>>>16)&0xFF] ^ + T7[(t0>>> 8)&0xFF] ^ T8[(t3 )&0xFF] ^ K[keyOffset++]; + t3 = T5[(t3>>>24) ] ^ T6[(t2>>>16)&0xFF] ^ + T7[(t1>>> 8)&0xFF] ^ T8[(t0 )&0xFF] ^ K[keyOffset++]; + + t1 = K[0]; + out[outOffset++] = (byte)(Si[(a0 >>> 24) ] ^ (t1 >>> 24)); + out[outOffset++] = (byte)(Si[(t3 >>> 16) & 0xFF] ^ (t1 >>> 16)); + out[outOffset++] = (byte)(Si[(a2 >>> 8) & 0xFF] ^ (t1 >>> 8)); + out[outOffset++] = (byte)(Si[(a1 ) & 0xFF] ^ (t1 )); + t1 = K[1]; + out[outOffset++] = (byte)(Si[(a1 >>> 24) ] ^ (t1 >>> 24)); + out[outOffset++] = (byte)(Si[(a0 >>> 16) & 0xFF] ^ (t1 >>> 16)); + out[outOffset++] = (byte)(Si[(t3 >>> 8) & 0xFF] ^ (t1 >>> 8)); + out[outOffset++] = (byte)(Si[(a2 ) & 0xFF] ^ (t1 )); + t1 = K[2]; + out[outOffset++] = (byte)(Si[(a2 >>> 24) ] ^ (t1 >>> 24)); + out[outOffset++] = (byte)(Si[(a1 >>> 16) & 0xFF] ^ (t1 >>> 16)); + out[outOffset++] = (byte)(Si[(a0 >>> 8) & 0xFF] ^ (t1 >>> 8)); + out[outOffset++] = (byte)(Si[(t3 ) & 0xFF] ^ (t1 )); + t1 = K[3]; + out[outOffset++] = (byte)(Si[(t3 >>> 24) ] ^ (t1 >>> 24)); + out[outOffset++] = (byte)(Si[(a2 >>> 16) & 0xFF] ^ (t1 >>> 16)); + out[outOffset++] = (byte)(Si[(a1 >>> 8) & 0xFF] ^ (t1 >>> 8)); + out[outOffset ] = (byte)(Si[(a0 ) & 0xFF] ^ (t1 )); + } + + + /** + * Expand a user-supplied key material into a session key. + * + * @param key The 128/192/256-bit user-key to use. + * @exception InvalidKeyException If the key is invalid. + */ + private static Object[] makeKey(byte[] k) throws InvalidKeyException { + if (k == null) { + throw new InvalidKeyException("Empty key"); + } + if (!isKeySizeValid(k.length)) { + throw new InvalidKeyException("Invalid AES key length: " + + k.length + " bytes"); + } + int ROUNDS = getRounds(k.length); + int ROUND_KEY_COUNT = (ROUNDS + 1) * 4; + + int BC = 4; + int[][] Ke = new int[ROUNDS + 1][4]; // encryption round keys + int[][] Kd = new int[ROUNDS + 1][4]; // decryption round keys + + int KC = k.length/4; // keylen in 32-bit elements + + int[] tk = new int[KC]; + int i, j; + + // copy user material bytes into temporary ints + for (i = 0, j = 0; i < KC; i++, j+=4) { + tk[i] = (k[j] ) << 24 | + (k[j+1] & 0xFF) << 16 | + (k[j+2] & 0xFF) << 8 | + (k[j+3] & 0xFF); + } + + // copy values into round key arrays + int t = 0; + for (j = 0; (j < KC) && (t < ROUND_KEY_COUNT); j++, t++) { + Ke[t / 4][t % 4] = tk[j]; + Kd[ROUNDS - (t / 4)][t % 4] = tk[j]; + } + int tt, rconpointer = 0; + while (t < ROUND_KEY_COUNT) { + // extrapolate using phi (the round key evolution function) + tt = tk[KC - 1]; + tk[0] ^= (S[(tt >>> 16) & 0xFF] ) << 24 ^ + (S[(tt >>> 8) & 0xFF] & 0xFF) << 16 ^ + (S[(tt ) & 0xFF] & 0xFF) << 8 ^ + (S[(tt >>> 24) ] & 0xFF) ^ + (rcon[rconpointer++] ) << 24; + if (KC != 8) + for (i = 1, j = 0; i < KC; i++, j++) tk[i] ^= tk[j]; + else { + for (i = 1, j = 0; i < KC / 2; i++, j++) tk[i] ^= tk[j]; + tt = tk[KC / 2 - 1]; + tk[KC / 2] ^= (S[(tt ) & 0xFF] & 0xFF) ^ + (S[(tt >>> 8) & 0xFF] & 0xFF) << 8 ^ + (S[(tt >>> 16) & 0xFF] & 0xFF) << 16 ^ + (S[(tt >>> 24) ] ) << 24; + for (j = KC / 2, i = j + 1; i < KC; i++, j++) tk[i] ^= tk[j]; + } + // copy values into round key arrays + for (j = 0; (j < KC) && (t < ROUND_KEY_COUNT); j++, t++) { + Ke[t / 4][t % 4] = tk[j]; + Kd[ROUNDS - (t / 4)][t % 4] = tk[j]; + } + } + for (int r = 1; r < ROUNDS; r++) { + // inverse MixColumn where needed + for (j = 0; j < BC; j++) { + tt = Kd[r][j]; + Kd[r][j] = U1[(tt >>> 24) & 0xFF] ^ + U2[(tt >>> 16) & 0xFF] ^ + U3[(tt >>> 8) & 0xFF] ^ + U4[ tt & 0xFF]; + } + } + // assemble the encryption (Ke) and decryption (Kd) round keys into + // one sessionKey object + Object[] result = new Object[] {Ke, Kd}; + return result; + } + + + /** + * Return The number of rounds for a given Rijndael keysize. + * + * @param keySize The size of the user key material in bytes. + * MUST be one of (16, 24, 32). + * @return The number of rounds. + */ + private static int getRounds(int keySize) { + return (keySize >> 2) + 6; + } +} Added: trunk/core/src/openjdk/com/com/sun/crypto/provider/AESKeyGenerator.java =================================================================== --- trunk/core/src/openjdk/com/com/sun/crypto/provider/AESKeyGenerator.java (rev 0) +++ trunk/core/src/openjdk/com/com/sun/crypto/provider/AESKeyGenerator.java 2009-02-14 20:29:54 UTC (rev 5025) @@ -0,0 +1,124 @@ +/* + * Copyright 2002-2007 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package com.sun.crypto.provider; + +import java.security.SecureRandom; +import java.security.InvalidParameterException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.spec.AlgorithmParameterSpec; +import javax.crypto.KeyGeneratorSpi; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; + + +/** + * This class generates a AES key. + * + * @author Valerie Peng + * + */ + +public final class AESKeyGenerator extends KeyGeneratorSpi { + + private SecureRandom random = null; + private int keySize = 16; // default keysize (in number of bytes) + + /** + * Verify the SunJCE provider in the constructor. + * + * @exception SecurityException if fails to verify + * its own integrity + */ + public AESKeyGenerator() { + if (!SunJCE.verifySelfIntegrity(this.getClass())) { + throw new SecurityException("The SunJCE provider may have " + + "been tampered."); + } + } + + /** + * Initializes this key generator. + * + * @param random the source of randomness for this generator + */ + protected void engineInit(SecureRandom random) { + this.random = random; + } + + /** + * Initializes this key generator with the specified parameter + * set and a user-provided source of randomness. + * + * @param params the key generation parameters + * @... [truncated message content] |
From: <ls...@us...> - 2009-02-16 20:42:01
|
Revision: 5036 http://jnode.svn.sourceforge.net/jnode/?rev=5036&view=rev Author: lsantha Date: 2009-02-16 20:41:55 +0000 (Mon, 16 Feb 2009) Log Message: ----------- OpenJDK integration. Added Paths: ----------- trunk/core/src/openjdk/java/java/security/AlgorithmParameterGenerator.java trunk/core/src/openjdk/java/java/security/AllPermission.java trunk/core/src/openjdk/java/java/security/BasicPermission.java trunk/core/src/openjdk/java/java/security/DigestInputStream.java trunk/core/src/openjdk/java/java/security/DigestOutputStream.java trunk/core/src/openjdk/java/java/security/GuardedObject.java trunk/core/src/openjdk/java/java/security/Identity.java trunk/core/src/openjdk/java/java/security/IdentityScope.java trunk/core/src/openjdk/java/java/security/KeyFactory.java trunk/core/src/openjdk/java/java/security/MessageDigest.java trunk/core/src/openjdk/java/java/security/MessageDigestSpi.java trunk/core/src/openjdk/java/java/security/Permission.java trunk/core/src/openjdk/java/java/security/PermissionCollection.java trunk/core/src/openjdk/java/java/security/Permissions.java trunk/core/src/openjdk/java/java/security/SecureRandom.java trunk/core/src/openjdk/java/java/security/Security.java trunk/core/src/openjdk/java/java/security/SecurityPermission.java trunk/core/src/openjdk/java/java/security/Signature.java trunk/core/src/openjdk/java/java/security/SignedObject.java trunk/core/src/openjdk/java/java/security/Signer.java trunk/core/src/openjdk/java/java/security/UnresolvedPermission.java trunk/core/src/openjdk/java/java/security/UnresolvedPermissionCollection.java trunk/core/src/openjdk/java/java/util/jar/Attributes.java trunk/core/src/openjdk/java/java/util/jar/JarEntry.java trunk/core/src/openjdk/java/java/util/jar/JarException.java trunk/core/src/openjdk/java/java/util/jar/JarFile.java trunk/core/src/openjdk/java/java/util/jar/JarInputStream.java trunk/core/src/openjdk/java/java/util/jar/JarOutputStream.java trunk/core/src/openjdk/java/java/util/jar/JarVerifier.java trunk/core/src/openjdk/java/java/util/jar/Manifest.java trunk/core/src/openjdk/java/java/util/jar/package.html trunk/core/src/openjdk/sun/sun/security/provider/ConfigSpiFile.java trunk/core/src/openjdk/sun/sun/security/provider/PolicySpiFile.java trunk/core/src/openjdk/sun/sun/security/provider/SecureRandom.java trunk/core/src/openjdk/sun/sun/security/provider/SeedGenerator.java trunk/core/src/openjdk/sun/sun/security/provider/Sun.java trunk/core/src/openjdk/sun/sun/security/provider/SunEntries.java trunk/core/src/openjdk/sun/sun/security/provider/VerificationProvider.java trunk/core/src/openjdk/sun/sun/security/util/ManifestEntryVerifier.java trunk/core/src/openjdk/svm/sun/security/ trunk/core/src/openjdk/svm/sun/security/provider/ trunk/core/src/openjdk/svm/sun/security/provider/NativePRNG.java trunk/core/src/openjdk/vm/java/util/jar/ trunk/core/src/openjdk/vm/java/util/jar/NativeJarFile.java trunk/core/src/openjdk/vm/sun/security/ trunk/core/src/openjdk/vm/sun/security/provider/ trunk/core/src/openjdk/vm/sun/security/provider/NativeSeedGenerator.java Removed Paths: ------------- trunk/core/src/classpath/java/java/security/AlgorithmParameterGenerator.java trunk/core/src/classpath/java/java/security/AllPermission.java trunk/core/src/classpath/java/java/security/BasicPermission.java trunk/core/src/classpath/java/java/security/DigestInputStream.java trunk/core/src/classpath/java/java/security/DigestOutputStream.java trunk/core/src/classpath/java/java/security/DummyMessageDigest.java trunk/core/src/classpath/java/java/security/DummySignature.java trunk/core/src/classpath/java/java/security/GuardedObject.java trunk/core/src/classpath/java/java/security/Identity.java trunk/core/src/classpath/java/java/security/IdentityScope.java trunk/core/src/classpath/java/java/security/IntersectingDomainCombiner.java trunk/core/src/classpath/java/java/security/KeyFactory.java trunk/core/src/classpath/java/java/security/MessageDigest.java trunk/core/src/classpath/java/java/security/MessageDigestSpi.java trunk/core/src/classpath/java/java/security/Permission.java trunk/core/src/classpath/java/java/security/PermissionCollection.java trunk/core/src/classpath/java/java/security/Permissions.java trunk/core/src/classpath/java/java/security/SecureRandom.java trunk/core/src/classpath/java/java/security/Security.java trunk/core/src/classpath/java/java/security/SecurityPermission.java trunk/core/src/classpath/java/java/security/Signature.java trunk/core/src/classpath/java/java/security/SignedObject.java trunk/core/src/classpath/java/java/security/Signer.java trunk/core/src/classpath/java/java/security/UnresolvedPermission.java trunk/core/src/classpath/java/java/util/jar/ Deleted: trunk/core/src/classpath/java/java/security/AlgorithmParameterGenerator.java =================================================================== --- trunk/core/src/classpath/java/java/security/AlgorithmParameterGenerator.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/AlgorithmParameterGenerator.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,259 +0,0 @@ -/* AlgorithmParameterGenerator.java --- Algorithm Parameter Generator - Copyright (C) 1999, 2003, 2004 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 java.security; - -import gnu.java.security.Engine; - -import java.security.spec.AlgorithmParameterSpec; - -/** - * <code>AlgorithmParameterGenerator</code> is used to generate algorithm - * parameters for specified algorithms. - * - * <p>In case the client does not explicitly initialize the - * <code>AlgorithmParameterGenerator</code> (via a call to an - * <code>init()</code> method), each provider must supply (and document) a - * default initialization. For example, the <b>GNU</b> provider uses a default - * modulus prime size of <code>1024</code> bits for the generation of <i>DSA</i> - * parameters. - * - * @author Mark Benvenuto - * @since 1.2 - * @see AlgorithmParameters - * @see AlgorithmParameterSpec - */ -public class AlgorithmParameterGenerator -{ - /** Service name for algorithm parameter generators. */ - private static final String ALGORITHM_PARAMETER_GENERATOR = - "AlgorithmParameterGenerator"; - - private AlgorithmParameterGeneratorSpi paramGenSpi; - private Provider provider; - private String algorithm; - - /** - * Constructs a new instance of <code>AlgorithmParameterGenerator</code>. - * - * @param paramGenSpi - * the generator to use. - * @param provider - * the provider to use. - * @param algorithm - * the algorithm to use. - */ - protected AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi - paramGenSpi, Provider provider, - String algorithm) - { - this.paramGenSpi = paramGenSpi; - this.provider = provider; - this.algorithm = algorithm; - } - - /** @return the name of the algorithm. */ - public final String getAlgorithm() - { - return algorithm; - } - - /** - * Returns a new <code>AlgorithmParameterGenerator</code> instance which - * generates algorithm parameters for the specified algorithm. - * - * @param algorithm - * the name of algorithm to use. - * @return the new instance. - * @throws NoSuchAlgorithmException - * if <code>algorithm</code> is not implemented by any provider. - */ - public static AlgorithmParameterGenerator getInstance(String algorithm) - throws NoSuchAlgorithmException - { - Provider[] p = Security.getProviders(); - for (int i = 0; i < p.length; i++) - try - { - return getInstance(algorithm, p[i]); - } - catch (NoSuchAlgorithmException e) - { - // Ignore. - } - - throw new NoSuchAlgorithmException(algorithm); - } - - /** - * Returns a new <code>AlgorithmParameterGenerator</code> instance which - * generates algorithm parameters for the specified algorithm. - * - * @param algorithm - * the name of algorithm to use. - * @param provider - * the name of the {@link Provider} to use. - * @return the new instance. - * @throws NoSuchAlgorithmException - * if the algorithm is not implemented by the named provider. - * @throws NoSuchProviderException - * if the named provider was not found. - */ - public static AlgorithmParameterGenerator getInstance(String algorithm, - String provider) - throws NoSuchAlgorithmException, NoSuchProviderException - { - if (provider == null || provider.length() == 0) - throw new IllegalArgumentException("Illegal provider"); - - Provider p = Security.getProvider(provider); - if (p == null) - throw new NoSuchProviderException(provider); - - return getInstance(algorithm, p); - } - - /** - * Returns a new <code>AlgorithmParameterGenerator</code> instance which - * generates algorithm parameters for the specified algorithm. - * - * @param algorithm - * the name of algorithm to use. - * @param provider - * the {@link Provider} to use. - * @return the new instance. - * @throws NoSuchAlgorithmException - * if the algorithm is not implemented by {@link Provider}. - * @since 1.4 - * @see Provider - */ - public static AlgorithmParameterGenerator getInstance(String algorithm, - Provider provider) - throws NoSuchAlgorithmException - { - if (provider == null) - throw new IllegalArgumentException("Illegal provider"); - - try - { - return new AlgorithmParameterGenerator( - (AlgorithmParameterGeneratorSpi) Engine.getInstance( - ALGORITHM_PARAMETER_GENERATOR, algorithm, provider), - provider, algorithm); - } - catch (java.lang.reflect.InvocationTargetException ite) - { - throw new NoSuchAlgorithmException(algorithm); - } - catch (ClassCastException cce) - { - throw new NoSuchAlgorithmException(algorithm); - } - } - - /** @return the {@link Provider} of this generator. */ - public final Provider getProvider() - { - return provider; - } - - /** - * Initializes this instance with the specified size. Since no source of - * randomness is supplied, a default one will be used. - * - * @param size - * size (in bits) to use. - */ - public final void init(int size) - { - init(size, new SecureRandom()); - } - - /** - * Initializes this instance with the specified key-size and source of - * randomness. - * - * @param size - * the size (in bits) to use. - * @param random - * the {@link SecureRandom} to use. - */ - public final void init(int size, SecureRandom random) - { - paramGenSpi.engineInit(size, random); - } - - /** - * Initializes this instance with the specified {@link AlgorithmParameterSpec}. - * Since no source of randomness is supplied, a default one will be used. - * - * @param genParamSpec - * the {@link AlgorithmParameterSpec} to use. - * @throws InvalidAlgorithmParameterException - * if <code>genParamSpec</code> is invalid. - */ - public final void init(AlgorithmParameterSpec genParamSpec) - throws InvalidAlgorithmParameterException - { - init(genParamSpec, new SecureRandom()); - } - - /** - * Initializes this instance with the specified {@link AlgorithmParameterSpec} - * and source of randomness. - * - * @param genParamSpec - * the {@link AlgorithmParameterSpec} to use. - * @param random - * the {@link SecureRandom} to use. - * @throws InvalidAlgorithmParameterException - * if <code>genParamSpec</code> is invalid. - */ - public final void init(AlgorithmParameterSpec genParamSpec, - SecureRandom random) - throws InvalidAlgorithmParameterException - { - paramGenSpi.engineInit(genParamSpec, random); - } - - /** @return a new instance of {@link AlgorithmParameters}. */ - public final AlgorithmParameters generateParameters() - { - return paramGenSpi.engineGenerateParameters(); - } -} Deleted: trunk/core/src/classpath/java/java/security/AllPermission.java =================================================================== --- trunk/core/src/classpath/java/java/security/AllPermission.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/AllPermission.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,198 +0,0 @@ -/* AllPermission.java -- Permission to do anything - Copyright (C) 1998, 2001, 2002, 2004, 2005 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 java.security; - -import gnu.java.util.EmptyEnumeration; - -import java.util.Collections; -import java.util.Enumeration; - -/** - * This class is a permission that implies all other permissions. Granting - * this permission effectively grants all others. Extreme caution should - * be exercised in granting this permission. - * - * @author Aaron M. Renn (ar...@ur...) - * @author Eric Blake (eb...@em...) - * @see AccessController - * @see Permissions - * @see SecurityManager - * @since 1.1 - * @status updated to 1.4 - */ -public final class AllPermission extends Permission -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -2916474571451318075L; - - /** - * Create a new AllPermission object. - */ - public AllPermission() - { - super("*"); - } - - /** - * Create a new AllPermission object. The parameters are ignored, as all - * permission implies ALL PERMISSION. - * - * @param name ignored - * @param actions ignored - */ - public AllPermission(String name, String actions) - { - super("*"); - } - - /** - * This method always returns <code>true</code> to indicate that this - * permission always implies that any other permission is also granted. - * - * @param perm ignored - * @return true, the permission is implied - */ - public boolean implies(Permission perm) - { - return true; - } - - /** - * Checks an object for equality. All AllPermissions are equal. - * - * @param obj the <code>Object</code> to test for equality - */ - public boolean equals(Object obj) - { - return obj instanceof AllPermission; - } - - /** - * This method returns a hash code for this object. This returns 1. - * - * @return a hash value for this object - */ - public int hashCode() - { - return 1; - } - - /** - * This method returns the list of actions associated with this object. - * This will always be the empty string ("") for this class. - * - * @return the action list - */ - public String getActions() - { - return ""; - } - - /** - * Returns a PermissionCollection which can hold AllPermission. - * - * @return a permission collection - */ - public PermissionCollection newPermissionCollection() - { - return new AllPermissionCollection(); - } - - /** - * Implements AllPermission.newPermissionCollection, and obeys serialization - * of JDK. - * - * @author Eric Blake (eb...@em...) - */ - private static final class AllPermissionCollection extends PermissionCollection - { - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -4023755556366636806L; - - /** - * Whether an AllPermission has been added to the collection. - * - * @serial if all permission is in the collection yet - */ - private boolean all_allowed; - - /** - * Add an AllPermission. - * - * @param perm the permission to add - * @throws IllegalArgumentException if perm is not an AllPermission - * @throws SecurityException if the collection is read-only - */ - public void add(Permission perm) - { - if (isReadOnly()) - throw new SecurityException(); - if (! (perm instanceof AllPermission)) - throw new IllegalArgumentException(); - all_allowed = true; - } - - /** - * Returns true if this collection implies a permission. - * - * @param perm the permission to check - * @return true if this collection contains an AllPermission - */ - public boolean implies(Permission perm) - { - return all_allowed; - } - - /** - * Returns an enumeration of the elements in the collection. - * - * @return the elements in the collection - */ - public Enumeration elements() - { - return all_allowed - ? Collections.enumeration(Collections.singleton(new AllPermission())) - : EmptyEnumeration.getInstance(); - } - } // class AllPermissionCollection -} // class AllPermission Deleted: trunk/core/src/classpath/java/java/security/BasicPermission.java =================================================================== --- trunk/core/src/classpath/java/java/security/BasicPermission.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/BasicPermission.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,308 +0,0 @@ -/* BasicPermission.java -- implements a simple named permission - Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005, 2006 - 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 java.security; - -import java.io.Serializable; -import java.util.Enumeration; -import java.util.Hashtable; - -/** - * This class implements a simple model for named permissions without an - * associated action list. That is, either the named permission is granted - * or it is not. - * - * <p>It also supports trailing wildcards to allow the easy granting of - * permissions in a hierarchical fashion. (For example, the name "org.gnu.*" - * might grant all permissions under the "org.gnu" permissions hierarchy). - * The only valid wildcard character is a '*' which matches anything. It - * must be the rightmost element in the permission name and must follow a - * '.' or else the Permission name must consist of only a '*'. Any other - * occurrence of a '*' is not valid. - * - * <p>This class ignores the action list. Subclasses can choose to implement - * actions on top of this class if desired. - * - * @author Aaron M. Renn (ar...@ur...) - * @author Eric Blake (eb...@em...) - * @see Permission - * @see Permissions - * @see PermissionCollection - * @see RuntimePermission - * @see SecurityPermission - * @see PropertyPermission - * @see AWTPermission - * @see NetPermission - * @see SecurityManager - * @since 1.1 - * @status updated to 1.4 - */ -public abstract class BasicPermission extends Permission - implements Serializable -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 6279438298436773498L; - - /** - * Create a new instance with the specified permission name. If the - * name is empty an exception is thrown. - * - * @param name the name of this permission - * @throws NullPointerException if name is null - * @throws IllegalArgumentException if name is invalid - */ - public BasicPermission(String name) - { - super(name); - - // This routine used to check for illegal wildcards, but no such - // requirement exists in the specification and Sun's runtime - // doesn't appear to do it. - - if (name.equals("")) - throw new IllegalArgumentException("Empty name"); - } - - /** - * Create a new instance with the specified permission name. If the name - * is empty, or contains an illegal wildcard character, an exception is - * thrown. The actions parameter is ignored. - * - * @param name the name of this permission - * @param actions ignored - * @throws NullPointerException if name is null - * @throws IllegalArgumentException if name is invalid - */ - public BasicPermission(String name, String actions) - { - this(name); - } - - /** - * This method tests to see if the specified permission is implied by this - * permission. This will be true if the following conditions are met:<ul> - * <li>The specified object is an instance of the same class as this - * object.</li> - * <li>The name of the specified permission is implied by this permission's - * name based on wildcard matching. For example, "a.*" implies "a.b".</li> - * </ul> - * - * @param perm the <code>Permission</code> object to test against - * @return true if the specified permission is implied - */ - public boolean implies(Permission perm) - { - if (! getClass().isInstance(perm)) - return false; - - String otherName = perm.getName(); - String name = getName(); - - if (name.equals(otherName)) - return true; - - int last = name.length() - 1; - return name.charAt(last) == '*' - && otherName.startsWith(name.substring(0, last)); - } - - /** - * This method tests to see if this object is equal to the specified - * <code>Object</code>. This will be true if and only if the specified - * object meets the following conditions:<ul> - * <li>It is an instance of the same class as this.</li> - * <li>It has the same name as this permission.</li> - * </ul> - * - * @param obj the <code>Object</code> to test for equality - * @return true if obj is semantically equal to this - */ - public boolean equals(Object obj) - { - return getClass().isInstance(obj) - && getName().equals(((BasicPermission) obj).getName()); - } - - /** - * This method returns a hash code for this permission object. The hash - * code returned is the value returned by calling the <code>hashCode</code> - * method on the <code>String</code> that is the name of this permission. - * - * @return a hash value for this object - */ - public int hashCode() - { - return getName().hashCode(); - } - - /** - * This method returns a list of the actions associated with this - * permission. This method always returns the empty string ("") since - * this class ignores actions. - * - * @return the action list - */ - public String getActions() - { - return ""; - } - - /** - * This method returns an instance of <code>PermissionCollection</code> - * suitable for storing <code>BasicPermission</code> objects. The - * collection returned can only store objects of the same type as this. - * Subclasses which use actions must override this method; but a class with - * no actions will work fine with this. - * - * @return a new empty <code>PermissionCollection</code> object - */ - public PermissionCollection newPermissionCollection() - { - return new BasicPermissionCollection(getClass()); - } - - /** - * Implements AllPermission.newPermissionCollection, and obeys serialization - * of JDK. - * - * @author Eric Blake (eb...@em...) - */ - private static final class BasicPermissionCollection extends PermissionCollection - { - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 739301742472979399L; - - /** - * The permissions in the collection. - * - * @serial a hash mapping name to permissions, all of type permClass - */ - private final Hashtable permissions = new Hashtable(); - - /** - * If "*" is in the collection. - * - * @serial true if a permission named "*" is in the collection - */ - private boolean all_allowed; - - /** - * The runtime class which all entries in the table must belong to. - * - * @serial the limiting subclass of this collection - */ - private final Class permClass; - - /** - * Construct a collection over the given runtime class. - * - * @param c the class - */ - BasicPermissionCollection(Class c) - { - permClass = c; - } - - /** - * Add a Permission. It must be of the same type as the permission which - * created this collection. - * - * @param perm the permission to add - * @throws IllegalArgumentException if perm is not the correct type - * @throws SecurityException if the collection is read-only - */ - public void add(Permission perm) - { - if (isReadOnly()) - throw new SecurityException("readonly"); - if (! permClass.isInstance(perm)) - throw new IllegalArgumentException("Expecting instance of " + permClass); - BasicPermission bp = (BasicPermission) perm; - String name = bp.getName(); - if (name.equals("*")) - all_allowed = true; - permissions.put(name, bp); - } - - /** - * Returns true if this collection implies the given permission. - * - * @param permission the permission to check - * @return true if it is implied by this - */ - public boolean implies(Permission permission) - { - if (! permClass.isInstance(permission)) - return false; - if (all_allowed) - return true; - BasicPermission toImply = (BasicPermission) permission; - String name = toImply.getName(); - if (name.equals("*")) - return false; - int prefixLength = name.length(); - if (name.endsWith("*")) - prefixLength -= 2; - - while (true) - { - if (permissions.get(name) != null) - return true; - prefixLength = name.lastIndexOf('.', prefixLength); - if (prefixLength < 0) - return false; - name = name.substring(0, prefixLength + 1) + '*'; - } - } - - /** - * Enumerate over the collection. - * - * @return an enumeration of the collection contents - */ - public Enumeration elements() - { - return permissions.elements(); - } - } // class BasicPermissionCollection -} // class BasicPermission Deleted: trunk/core/src/classpath/java/java/security/DigestInputStream.java =================================================================== --- trunk/core/src/classpath/java/java/security/DigestInputStream.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/DigestInputStream.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,167 +0,0 @@ -/* DigestInputStream.java --- An Input stream tied to a message digest - Copyright (C) 1999, 2003, 2004, 2005 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 java.security; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * DigestInputStream is a class that ties an InputStream with a - * MessageDigest. The Message Digest is used by the class to - * update it self as bytes are read from the InputStream. - * - * The updating to the digest depends on the on flag which is set - * to true by default to tell the class to update the data - * in the message digest. - * - * @version 0.0 - * @author Mark Benvenuto (ivy...@wo...) - */ -public class DigestInputStream extends FilterInputStream -{ - /** - * The message digest for the DigestInputStream - */ - protected MessageDigest digest; - - //Manages the on flag - private boolean state = true; - - /** - * Constructs a new DigestInputStream. - * It associates a MessageDigest with the stream to - * compute the stream as data is written. - * - * @param stream An InputStream to associate this stream with - * @param digest A MessageDigest to hash the stream with - */ - public DigestInputStream(InputStream stream, MessageDigest digest) - { - super(stream); - //this.in = stream; - this.digest = digest; - } - - /** - * Returns the MessageDigest associated with this DigestInputStream - * - * @return The MessageDigest used to hash this stream - */ - public MessageDigest getMessageDigest() - { - return digest; - } - - /** - * Sets the current MessageDigest to current parameter - * - * @param digest A MessageDigest to associate with this stream - */ - public void setMessageDigest(MessageDigest digest) - { - this.digest = digest; - } - - /** - * Reads a byte from the input stream and updates the digest. - * This method reads the underlying input stream and if the - * on flag is true then updates the message digest. - * - * @return Returns a byte from the input stream, -1 is returned to indicate that - * the end of stream was reached before this read call - * - * @throws IOException if an IO error occurs in the underlying input stream, - * this error is thrown - */ - public int read() throws IOException - { - int temp = in.read(); - - if (state == true && temp != -1) - digest.update((byte) temp); - - return temp; - } - - /** - * Reads bytes from the input stream and updates the digest. - * This method reads the underlying input stream and if the - * on flag is true then updates the message digest. - * - * @param b a byte array to store the data from the input stream - * @param off an offset to start at in the array - * @param len length of data to read - * @return Returns count of bytes read, -1 is returned to indicate that - * the end of stream was reached before this read call - * - * @throws IOException if an IO error occurs in the underlying input stream, - * this error is thrown - */ - public int read(byte[]b, int off, int len) throws IOException - { - int temp = in.read(b, off, len); - - if (state == true && temp != -1) - digest.update(b, off, temp); - - return temp; - } - - /** - * Sets the flag specifing if this DigestInputStream updates the - * digest in the write() methods. The default is on; - * - * @param on True means it digests stream, false means it does not - */ - public void on(boolean on) - { - state = on; - } - - /** - * Converts the input stream and underlying message digest to a string. - * - * @return A string representing the input stream and message digest. - */ - public String toString() - { - return "[Digest Input Stream] " + digest.toString(); - } -} Deleted: trunk/core/src/classpath/java/java/security/DigestOutputStream.java =================================================================== --- trunk/core/src/classpath/java/java/security/DigestOutputStream.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/DigestOutputStream.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,158 +0,0 @@ -/* DigestOutputStream.java --- An output stream tied to a message digest - Copyright (C) 1999, 2004, 2005 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 java.security; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * DigestOutputStream is a class that ties an OutputStream with a - * MessageDigest. The Message Digest is used by the class to update it - * self as bytes are written to the OutputStream. - * - * The updating to the digest depends on the on flag which is set to - * true by default that tells the class to update the data in the - * message digest. - * - * @version 0.0 - * @author Mark Benvenuto (ivy...@wo...) - */ -public class DigestOutputStream extends FilterOutputStream -{ - /** - * The message digest for the DigestOutputStream - */ - protected MessageDigest digest; - - //Manages the on flag - private boolean state = true; - - /** - * Constructs a new DigestOutputStream. It associates a - * MessageDigest with the stream to compute the stream as data is - * written. - * - * @param stream An OutputStream to associate this stream with - * @param digest A MessageDigest to hash the stream with - */ - public DigestOutputStream(OutputStream stream, MessageDigest digest) - { - super(stream); - this.digest = digest; - } - - /** - * Returns the MessageDigest associated with this DigestOutputStream - * - * @return The MessageDigest used to hash this stream - */ - public MessageDigest getMessageDigest() - { - return digest; - } - - /** - * Sets the current MessageDigest to current parameter - * - * @param digest A MessageDigest to associate with this stream - */ - public void setMessageDigest(MessageDigest digest) - { - this.digest = digest; - } - - - /** - * Updates the hash if the on flag is true and then writes a byte to - * the underlying output stream. - * - * @param b A byte to write to the output stream - * - * @exception IOException if the underlying output stream - * cannot write the byte, this is thrown. - */ - public void write(int b) throws IOException - { - if (state) - digest.update((byte) b); - - out.write(b); - } - - /** - * Updates the hash if the on flag is true and then writes the bytes - * to the underlying output stream. - * - * @param b Bytes to write to the output stream - * @param off Offset to start to start at in array - * @param len Length of data to write - * - * @exception IOException if the underlying output stream - * cannot write the bytes, this is thrown. - */ - public void write(byte[]b, int off, int len) throws IOException - { - if (state) - digest.update(b, off, len); - - out.write(b, off, len); - } - - /** - * Sets the flag specifying if this DigestOutputStream updates the - * digest in the write() methods. The default is on; - * - * @param on True means it digests stream, false means it does not - */ - public void on(boolean on) - { - state = on; - } - - /** - * Converts the output stream and underlying message digest to a string. - * - * @return A string representing the output stream and message digest. - */ - public String toString() - { - return "[Digest Output Stream] " + digest.toString(); - } -} Deleted: trunk/core/src/classpath/java/java/security/DummyMessageDigest.java =================================================================== --- trunk/core/src/classpath/java/java/security/DummyMessageDigest.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/DummyMessageDigest.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,90 +0,0 @@ -/* DummyMessageDigest.java - Wrapper for MessageDigestSpi - Copyright (C) 1999, 2002 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 java.security; - -final class DummyMessageDigest extends MessageDigest -{ - private MessageDigestSpi mdSpi = null; - - public DummyMessageDigest(MessageDigestSpi mdSpi, String algorithm) - { - super(algorithm); - this.mdSpi = mdSpi; - } - - public Object clone() throws CloneNotSupportedException - { - MessageDigest result = new DummyMessageDigest - ((MessageDigestSpi) mdSpi.clone(), this.getAlgorithm()); - result.provider = this.getProvider(); - return result; - } - - // java.security.MessageDigestSpi abstract methods implementation --------- - - public byte[] engineDigest() - { - return mdSpi.engineDigest(); - } - - public int engineDigest(byte[] buf, int offset, int len) - throws DigestException - { - return mdSpi.engineDigest(buf, offset, len); - } - - public int engineGetDigestLength() - { - return mdSpi.engineGetDigestLength(); - } - - public void engineReset() - { - mdSpi.engineReset(); - } - - public void engineUpdate(byte input) - { - mdSpi.engineUpdate(input); - } - - public void engineUpdate(byte[] input, int offset, int len) - { - mdSpi.engineUpdate(input, offset, len); - } -} Deleted: trunk/core/src/classpath/java/java/security/DummySignature.java =================================================================== --- trunk/core/src/classpath/java/java/security/DummySignature.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/DummySignature.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,102 +0,0 @@ -/* DummySignature.java - Signature wrapper for SignatureSpi. - Copyright (C) 1999, 2002 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 java.security; - -final class DummySignature extends Signature -{ - private SignatureSpi sigSpi = null; - - public DummySignature(SignatureSpi sigSpi, String algorithm) - { - super(algorithm); - this.sigSpi = sigSpi; - } - - public Object clone() throws CloneNotSupportedException - { - Signature result = new DummySignature - ((SignatureSpi) sigSpi.clone(), this.getAlgorithm()); - result.provider = this.getProvider(); - return result; - } - - protected void engineInitVerify(PublicKey publicKey) - throws InvalidKeyException - { - sigSpi.engineInitVerify(publicKey); - } - - protected void engineInitSign(PrivateKey privateKey) - throws InvalidKeyException - { - sigSpi.engineInitSign(privateKey); - } - - protected void engineUpdate(byte b) throws SignatureException - { - sigSpi.engineUpdate(b); - } - - protected void engineUpdate(byte[]b, int off, int len) - throws SignatureException - { - sigSpi.engineUpdate(b, off, len); - } - - protected byte[] engineSign() throws SignatureException - { - return sigSpi.engineSign(); - } - - protected boolean engineVerify(byte[]sigBytes) throws SignatureException - { - return sigSpi.engineVerify(sigBytes); - } - - protected void engineSetParameter(String param, Object value) - throws InvalidParameterException - { - sigSpi.engineSetParameter(param, value); - } - - protected Object engineGetParameter(String param) - throws InvalidParameterException - { - return sigSpi.engineGetParameter(param); - } -} Deleted: trunk/core/src/classpath/java/java/security/GuardedObject.java =================================================================== --- trunk/core/src/classpath/java/java/security/GuardedObject.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/GuardedObject.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,121 +0,0 @@ -/* GuardedObject.java -- An object protected by a Guard - Copyright (C) 1998, 2002, 2004, 2005 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 java.security; - -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * This class is an object that is guarded by a <code>Guard</code> object. - * The object that is being guarded is retrieved by a call to the only - * method in this class - <code>getObject</code>. That method returns the - * guarded <code>Object</code> after first checking with the - * <code>Guard</code>. If the <code>Guard</code> disallows access, an - * exception will be thrown. - * - * @author Aaron M. Renn (ar...@ur...) - * @since 1.1 - * @status updated to 1.4 - */ -public class GuardedObject implements Serializable -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -5240450096227834308L; - - /** - * This is the Guard that is protecting the object. - * - * @serial the guard - */ - private final Guard guard; - - /** - * This is the object that is being guarded. - * - * @serial the protected object - */ - private final Object object; - - /** - * This method initializes a new instance of <code>GuardedObject</code> - * that protects the specified <code>Object</code> using the specified - * <code>Guard</code>. A null guard means there are no restrictions on - * accessing the object. - * - * @param object the <code>Object</code> to guard - * @param guard the <code>Guard</code> that is protecting the object - */ - public GuardedObject(Object object, Guard guard) - { - this.object = object; - this.guard = guard; - } - - /** - * This method first call the <code>checkGuard</code> method on the - * <code>Guard</code> object protecting the guarded object. If the - * <code>Guard</code> disallows access, an exception is thrown, otherwise - * the <code>Object</code> is returned. - * - * @return The object being guarded - * @throws SecurityException if access is denied - */ - public Object getObject() - { - if (guard != null) - guard.checkGuard(object); - return object; - } - - /** - * Ensures that serialization is legal, by checking the guard. - * - * @param s the stream to write to - * @throws IOException if the underlying stream fails - */ - private void writeObject(ObjectOutputStream s) throws IOException - { - if (guard != null) - guard.checkGuard(object); - s.defaultWriteObject(); - } -} // class GuardedObject Deleted: trunk/core/src/classpath/java/java/security/Identity.java =================================================================== --- trunk/core/src/classpath/java/java/security/Identity.java 2009-02-16 20:38:42 UTC (rev 5035) +++ trunk/core/src/classpath/java/java/security/Identity.java 2009-02-16 20:41:55 UTC (rev 5036) @@ -1,346 +0,0 @@ -/* Identity.java --- Identity Class - Copyright (C) 1999, 2003, 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 java.security; - -import java.io.Serializable; -import java.util.Vector; - -/** - * The <code>Identity</code> class is used to represent people and companies - * that can be authenticated using public key encryption. The identities can - * also be abstract objects such as smart cards. - * - * <p><code>Identity</code> objects store a name and public key for each - * identity. The names cannot be changed and the identities can be scoped. Each - * identity (name and public key) within a scope are unique to that scope.</p> - * - * <p>Each identity has a set of ceritificates which all specify the same - * public key, but not necessarily the same name.</p> - * - * <p>The <code>Identity</code> class can be subclassed to allow additional - * information to be attached to it.</p> - * - * @author Mark Benvenuto - * @see IdentityScope - * @see Signer - * @see Principal - * @deprecated Replaced by <code>java.security.KeyStore</code>, the - * <code>java.security.cert</code> package, and - * <code>java.security.Principal</code>. - */ -public abstract class Identity implements Principal, Serializable -{ - private static final long serialVersionUID = 3609922007826600659L; - - private String name; - private IdentityScope scope; - private PublicKey publicKey; - private String info; - private Vector certificates; - - /** Constructor for serialization only. */ - protected Identity() - { - } - - /** - * Constructs a new instance of <code>Identity</code> with the specified - * name and scope. - * - * @param name - * the name to use. - * @param scope - * the scope to use. - * @throws KeyManagementException - * if the identity is already present. - */ - public Identity(String name, IdentityScope scope) - throws KeyManagementException - { - this.name = name; - this.scope = scope; - } - - /** - * Constructs a new instance of <code>Identity</code> with the specified - * name and no scope. - * - * @param name - * the name to use. - */ - public Identity(String name) - { - this.name = name; - this.scope = null; - } - - /** @return the name of this identity. */ - public final String getName() - { - return name; - } - - /** @return the scope of this identity. */ - public final IdentityScope getScope() - { - return scope; - } - - /** - * @return the public key of this identity. - * @see #setPublicKey(java.security.PublicKey) - */ - public PublicKey getPublicKey() - { - return publicKey; - } - - /** - * Sets the public key for this identity. The old key and all certificates - * are removed. - * - * @param key - * the public key to use. - * @throws KeyManagementException - * if this public key is used by another identity in the current - * scope. - * @throws SecurityException - * if a {@link SecurityManager} is installed which disallows this - * operation. - */ - public void setPublicKey(PublicKey key) throws KeyManagementException - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkSecurityAccess("setIdentityPublicKey"); - - this.publicKey = key; - } - - /** - * Sets the general information string. - * - * @param info - * the general information string. - * @throws SecurityException - * if a {@link SecurityManager} is installed which disallows this - * operation. - */ - public void setInfo(String info) - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkSecurityAccess("setIdentityInfo"); - - this.info = info; - } - - /** - * @return the general information string of this identity. - * @see #setInfo(String) - */ - public String getInfo() - { - return info; - } - - /** - * Adds a certificate to the list of ceritificates for this identity. The - * public key in this certificate must match the existing public key if it - * exists. - * - * @param certificate - * the certificate to add. - * @throws KeyManagementException - * if the certificate is invalid, or the public key conflicts. - * @throws SecurityException - * if a {@link SecurityManager} is installed which disallows this - * operation. - */ - public void addCertificate(Certificate certificate) - throws KeyManagementException - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkSecurityAccess("addIdentityCertificate"); - - // Check public key of this certific... [truncated message content] |
From: <ls...@us...> - 2009-03-01 08:55:35
|
Revision: 5077 http://jnode.svn.sourceforge.net/jnode/?rev=5077&view=rev Author: lsantha Date: 2009-03-01 08:55:23 +0000 (Sun, 01 Mar 2009) Log Message: ----------- OpenJDK integration. Added Paths: ----------- trunk/core/src/openjdk/java/java/lang/ref/ trunk/core/src/openjdk/java/java/lang/ref/FinalReference.java trunk/core/src/openjdk/java/java/lang/ref/Finalizer.java trunk/core/src/openjdk/java/java/lang/ref/PhantomReference.java trunk/core/src/openjdk/java/java/lang/ref/Reference.java trunk/core/src/openjdk/java/java/lang/ref/ReferenceQueue.java trunk/core/src/openjdk/java/java/lang/ref/SoftReference.java trunk/core/src/openjdk/java/java/lang/ref/WeakReference.java trunk/core/src/openjdk/java/java/lang/ref/package.html trunk/core/src/openjdk/vm/java/lang/ref/ trunk/core/src/openjdk/vm/java/lang/ref/NativeFinalizer.java Removed Paths: ------------- trunk/core/src/classpath/java/java/lang/ref/ Added: trunk/core/src/openjdk/java/java/lang/ref/FinalReference.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/FinalReference.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/FinalReference.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,37 @@ +/* + * Copyright 1997-2003 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + + +/* Final references, used to implement finalization */ + +class FinalReference<T> extends Reference<T> { + + public FinalReference(T referent, ReferenceQueue<? super T> q) { + super(referent, q); + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/Finalizer.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/Finalizer.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/Finalizer.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,197 @@ +/* + * Copyright 1997-2004 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + +import java.security.PrivilegedAction; +import java.security.AccessController; + + +final class Finalizer extends FinalReference { /* Package-private; must be in + same package as the Reference + class */ + + /* A native method that invokes an arbitrary object's finalize method is + required since the finalize method is protected + */ + static native void invokeFinalizeMethod(Object o) throws Throwable; + + static private ReferenceQueue queue = new ReferenceQueue(); + static private Finalizer unfinalized = null; + static private Object lock = new Object(); + + private Finalizer + next = null, + prev = null; + + private boolean hasBeenFinalized() { + return (next == this); + } + + private void add() { + synchronized (lock) { + if (unfinalized != null) { + this.next = unfinalized; + unfinalized.prev = this; + } + unfinalized = this; + } + } + + private void remove() { + synchronized (lock) { + if (unfinalized == this) { + if (this.next != null) { + unfinalized = this.next; + } else { + unfinalized = this.prev; + } + } + if (this.next != null) { + this.next.prev = this.prev; + } + if (this.prev != null) { + this.prev.next = this.next; + } + this.next = this; /* Indicates that this has been finalized */ + this.prev = this; + } + } + + private Finalizer(Object finalizee) { + super(finalizee, queue); + add(); + } + + /* Invoked by VM */ + static void register(Object finalizee) { + new Finalizer(finalizee); + } + + private void runFinalizer() { + synchronized (this) { + if (hasBeenFinalized()) return; + remove(); + } + try { + Object finalizee = this.get(); + if (finalizee != null && !(finalizee instanceof java.lang.Enum)) { + invokeFinalizeMethod(finalizee); + /* Clear stack slot containing this variable, to decrease + the chances of false retention with a conservative GC */ + finalizee = null; + } + } catch (Throwable x) { } + super.clear(); + } + + /* Create a privileged secondary finalizer thread in the system thread + group for the given Runnable, and wait for it to complete. + + This method is used by both runFinalization and runFinalizersOnExit. + The former method invokes all pending finalizers, while the latter + invokes all uninvoked finalizers if on-exit finalization has been + enabled. + + These two methods could have been implemented by offloading their work + to the regular finalizer thread and waiting for that thread to finish. + The advantage of creating a fresh thread, however, is that it insulates + invokers of these methods from a stalled or deadlocked finalizer thread. + */ + private static void forkSecondaryFinalizer(final Runnable proc) { + PrivilegedAction pa = new PrivilegedAction() { + public Object run() { + ThreadGroup tg = Thread.currentThread().getThreadGroup(); + for (ThreadGroup tgn = tg; + tgn != null; + tg = tgn, tgn = tg.getParent()); + Thread sft = new Thread(tg, proc, "Secondary finalizer"); + sft.start(); + try { + sft.join(); + } catch (InterruptedException x) { + /* Ignore */ + } + return null; + }}; + AccessController.doPrivileged(pa); + } + + /* Called by Runtime.runFinalization() */ + static void runFinalization() { + forkSecondaryFinalizer(new Runnable() { + public void run() { + for (;;) { + Finalizer f = (Finalizer)queue.poll(); + if (f == null) break; + f.runFinalizer(); + } + } + }); + } + + /* Invoked by java.lang.Shutdown */ + static void runAllFinalizers() { + forkSecondaryFinalizer(new Runnable() { + public void run() { + for (;;) { + Finalizer f; + synchronized (lock) { + f = unfinalized; + if (f == null) break; + unfinalized = f.next; + } + f.runFinalizer(); + }}}); + } + + private static class FinalizerThread extends Thread { + FinalizerThread(ThreadGroup g) { + super(g, "Finalizer"); + } + public void run() { + for (;;) { + try { + Finalizer f = (Finalizer)queue.remove(); + f.runFinalizer(); + } catch (InterruptedException x) { + continue; + } + } + } + } + + static { + ThreadGroup tg = Thread.currentThread().getThreadGroup(); + for (ThreadGroup tgn = tg; + tgn != null; + tg = tgn, tgn = tg.getParent()); + Thread finalizer = new FinalizerThread(tg); + finalizer.setPriority(Thread.MAX_PRIORITY - 2); + finalizer.setDaemon(true); + finalizer.start(); + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/PhantomReference.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/PhantomReference.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/PhantomReference.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,83 @@ +/* + * Copyright 1997-2003 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + + +/** + * Phantom reference objects, which are enqueued after the collector + * determines that their referents may otherwise be reclaimed. Phantom + * references are most often used for scheduling pre-mortem cleanup actions in + * a more flexible way than is possible with the Java finalization mechanism. + * + * <p> If the garbage collector determines at a certain point in time that the + * referent of a phantom reference is <a + * href="package-summary.html#reachability">phantom reachable</a>, then at that + * time or at some later time it will enqueue the reference. + * + * <p> In order to ensure that a reclaimable object remains so, the referent of + * a phantom reference may not be retrieved: The <code>get</code> method of a + * phantom reference always returns <code>null</code>. + * + * <p> Unlike soft and weak references, phantom references are not + * automatically cleared by the garbage collector as they are enqueued. An + * object that is reachable via phantom references will remain so until all + * such references are cleared or themselves become unreachable. + * + * @author Mark Reinhold + * @since 1.2 + */ + +public class PhantomReference<T> extends Reference<T> { + + /** + * Returns this reference object's referent. Because the referent of a + * phantom reference is always inaccessible, this method always returns + * <code>null</code>. + * + * @return <code>null</code> + */ + public T get() { + return null; + } + + /** + * Creates a new phantom reference that refers to the given object and + * is registered with the given queue. + * + * <p> It is possible to create a phantom reference with a <tt>null</tt> + * queue, but such a reference is completely useless: Its <tt>get</tt> + * method will always return null and, since it does not have a queue, it + * will never be enqueued. + * + * @param referent the object the new phantom reference will refer to + * @param q the queue with which the reference is to be registered, + * or <tt>null</tt> if registration is not required + */ + public PhantomReference(T referent, ReferenceQueue<? super T> q) { + super(referent, q); + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/Reference.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/Reference.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/Reference.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,238 @@ +/* + * Copyright 1997-2006 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + +import sun.misc.Cleaner; + + +/** + * Abstract base class for reference objects. This class defines the + * operations common to all reference objects. Because reference objects are + * implemented in close cooperation with the garbage collector, this class may + * not be subclassed directly. + * + * @author Mark Reinhold + * @since 1.2 + */ + +public abstract class Reference<T> { + + /* A Reference instance is in one of four possible internal states: + * + * Active: Subject to special treatment by the garbage collector. Some + * time after the collector detects that the reachability of the + * referent has changed to the appropriate state, it changes the + * instance's state to either Pending or Inactive, depending upon + * whether or not the instance was registered with a queue when it was + * created. In the former case it also adds the instance to the + * pending-Reference list. Newly-created instances are Active. + * + * Pending: An element of the pending-Reference list, waiting to be + * enqueued by the Reference-handler thread. Unregistered instances + * are never in this state. + * + * Enqueued: An element of the queue with which the instance was + * registered when it was created. When an instance is removed from + * its ReferenceQueue, it is made Inactive. Unregistered instances are + * never in this state. + * + * Inactive: Nothing more to do. Once an instance becomes Inactive its + * state will never change again. + * + * The state is encoded in the queue and next fields as follows: + * + * Active: queue = ReferenceQueue with which instance is registered, or + * ReferenceQueue.NULL if it was not registered with a queue; next = + * null. + * + * Pending: queue = ReferenceQueue with which instance is registered; + * next = Following instance in queue, or this if at end of list. + * + * Enqueued: queue = ReferenceQueue.ENQUEUED; next = Following instance + * in queue, or this if at end of list. + * + * Inactive: queue = ReferenceQueue.NULL; next = this. + * + * With this scheme the collector need only examine the next field in order + * to determine whether a Reference instance requires special treatment: If + * the next field is null then the instance is active; if it is non-null, + * then the collector should treat the instance normally. + * + * To ensure that concurrent collector can discover active Reference + * objects without interfering with application threads that may apply + * the enqueue() method to those objects, collectors should link + * discovered objects through the discovered field. + */ + + private T referent; /* Treated specially by GC */ + + ReferenceQueue<? super T> queue; + + Reference next; + transient private Reference<T> discovered; /* used by VM */ + + + /* Object used to synchronize with the garbage collector. The collector + * must acquire this lock at the beginning of each collection cycle. It is + * therefore critical that any code holding this lock complete as quickly + * as possible, allocate no new objects, and avoid calling user code. + */ + static private class Lock { }; + private static Lock lock = new Lock(); + + + /* List of References waiting to be enqueued. The collector adds + * References to this list, while the Reference-handler thread removes + * them. This list is protected by the above lock object. + */ + private static Reference pending = null; + + /* High-priority thread to enqueue pending References + */ + private static class ReferenceHandler extends Thread { + + ReferenceHandler(ThreadGroup g, String name) { + super(g, name); + } + + public void run() { + for (;;) { + + Reference r; + synchronized (lock) { + if (pending != null) { + r = pending; + Reference rn = r.next; + pending = (rn == r) ? null : rn; + r.next = r; + } else { + try { + lock.wait(); + } catch (InterruptedException x) { } + continue; + } + } + + // Fast path for cleaners + if (r instanceof Cleaner) { + ((Cleaner)r).clean(); + continue; + } + + ReferenceQueue q = r.queue; + if (q != ReferenceQueue.NULL) q.enqueue(r); + } + } + } + + static { + ThreadGroup tg = Thread.currentThread().getThreadGroup(); + for (ThreadGroup tgn = tg; + tgn != null; + tg = tgn, tgn = tg.getParent()); + Thread handler = new ReferenceHandler(tg, "Reference Handler"); + /* If there were a special system-only priority greater than + * MAX_PRIORITY, it would be used here + */ + handler.setPriority(Thread.MAX_PRIORITY); + handler.setDaemon(true); + handler.start(); + } + + + /* -- Referent accessor and setters -- */ + + /** + * Returns this reference object's referent. If this reference object has + * been cleared, either by the program or by the garbage collector, then + * this method returns <code>null</code>. + * + * @return The object to which this reference refers, or + * <code>null</code> if this reference object has been cleared + */ + public T get() { + return this.referent; + } + + /** + * Clears this reference object. Invoking this method will not cause this + * object to be enqueued. + * + * <p> This method is invoked only by Java code; when the garbage collector + * clears references it does so directly, without invoking this method. + */ + public void clear() { + this.referent = null; + } + + + /* -- Queue operations -- */ + + /** + * Tells whether or not this reference object has been enqueued, either by + * the program or by the garbage collector. If this reference object was + * not registered with a queue when it was created, then this method will + * always return <code>false</code>. + * + * @return <code>true</code> if and only if this reference object has + * been enqueued + */ + public boolean isEnqueued() { + /* In terms of the internal states, this predicate actually tests + whether the instance is either Pending or Enqueued */ + synchronized (this) { + return (this.queue != ReferenceQueue.NULL) && (this.next != null); + } + } + + /** + * Adds this reference object to the queue with which it is registered, + * if any. + * + * <p> This method is invoked only by Java code; when the garbage collector + * enqueues references it does so directly, without invoking this method. + * + * @return <code>true</code> if this reference object was successfully + * enqueued; <code>false</code> if it was already enqueued or if + * it was not registered with a queue when it was created + */ + public boolean enqueue() { + return this.queue.enqueue(this); + } + + + /* -- Constructors -- */ + + Reference(T referent) { + this(referent, null); + } + + Reference(T referent, ReferenceQueue<? super T> queue) { + this.referent = referent; + this.queue = (queue == null) ? ReferenceQueue.NULL : queue; + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/ReferenceQueue.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/ReferenceQueue.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/ReferenceQueue.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,152 @@ +/* + * Copyright 1997-2005 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + +/** + * Reference queues, to which registered reference objects are appended by the + * garbage collector after the appropriate reachability changes are detected. + * + * @author Mark Reinhold + * @since 1.2 + */ + +public class ReferenceQueue<T> { + + /** + * Constructs a new reference-object queue. + */ + public ReferenceQueue() { } + + private static class Null extends ReferenceQueue { + boolean enqueue(Reference r) { + return false; + } + } + + static ReferenceQueue NULL = new Null(); + static ReferenceQueue ENQUEUED = new Null(); + + static private class Lock { }; + private Lock lock = new Lock(); + private Reference<? extends T> head = null; + private long queueLength = 0; + + boolean enqueue(Reference<? extends T> r) { /* Called only by Reference class */ + synchronized (r) { + if (r.queue == ENQUEUED) return false; + synchronized (lock) { + r.queue = ENQUEUED; + r.next = (head == null) ? r : head; + head = r; + queueLength++; + if (r instanceof FinalReference) { + sun.misc.VM.addFinalRefCount(1); + } + lock.notifyAll(); + return true; + } + } + } + + private Reference<? extends T> reallyPoll() { /* Must hold lock */ + if (head != null) { + Reference<? extends T> r = head; + head = (r.next == r) ? null : r.next; + r.queue = NULL; + r.next = r; + queueLength--; + if (r instanceof FinalReference) { + sun.misc.VM.addFinalRefCount(-1); + } + return r; + } + return null; + } + + /** + * Polls this queue to see if a reference object is available. If one is + * available without further delay then it is removed from the queue and + * returned. Otherwise this method immediately returns <tt>null</tt>. + * + * @return A reference object, if one was immediately available, + * otherwise <code>null</code> + */ + public Reference<? extends T> poll() { + synchronized (lock) { + return reallyPoll(); + } + } + + /** + * Removes the next reference object in this queue, blocking until either + * one becomes available or the given timeout period expires. + * + * <p> This method does not offer real-time guarantees: It schedules the + * timeout as if by invoking the {@link Object#wait(long)} method. + * + * @param timeout If positive, block for up to <code>timeout</code> + * milliseconds while waiting for a reference to be + * added to this queue. If zero, block indefinitely. + * + * @return A reference object, if one was available within the specified + * timeout period, otherwise <code>null</code> + * + * @throws IllegalArgumentException + * If the value of the timeout argument is negative + * + * @throws InterruptedException + * If the timeout wait is interrupted + */ + public Reference<? extends T> remove(long timeout) + throws IllegalArgumentException, InterruptedException + { + if (timeout < 0) { + throw new IllegalArgumentException("Negative timeout value"); + } + synchronized (lock) { + Reference<? extends T> r = reallyPoll(); + if (r != null) return r; + for (;;) { + lock.wait(timeout); + r = reallyPoll(); + if (r != null) return r; + if (timeout != 0) return null; + } + } + } + + /** + * Removes the next reference object in this queue, blocking until one + * becomes available. + * + * @return A reference object, blocking until one becomes available + * @throws InterruptedException If the wait is interrupted + */ + public Reference<? extends T> remove() throws InterruptedException { + return remove(0); + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/SoftReference.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/SoftReference.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/SoftReference.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,115 @@ +/* + * Copyright 1997-2003 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + + +/** + * Soft reference objects, which are cleared at the discretion of the garbage + * collector in response to memory demand. Soft references are most often used + * to implement memory-sensitive caches. + * + * <p> Suppose that the garbage collector determines at a certain point in time + * that an object is <a href="package-summary.html#reachability">softly + * reachable</a>. At that time it may choose to clear atomically all soft + * references to that object and all soft references to any other + * softly-reachable objects from which that object is reachable through a chain + * of strong references. At the same time or at some later time it will + * enqueue those newly-cleared soft references that are registered with + * reference queues. + * + * <p> All soft references to softly-reachable objects are guaranteed to have + * been cleared before the virtual machine throws an + * <code>OutOfMemoryError</code>. Otherwise no constraints are placed upon the + * time at which a soft reference will be cleared or the order in which a set + * of such references to different objects will be cleared. Virtual machine + * implementations are, however, encouraged to bias against clearing + * recently-created or recently-used soft references. + * + * <p> Direct instances of this class may be used to implement simple caches; + * this class or derived subclasses may also be used in larger data structures + * to implement more sophisticated caches. As long as the referent of a soft + * reference is strongly reachable, that is, is actually in use, the soft + * reference will not be cleared. Thus a sophisticated cache can, for example, + * prevent its most recently used entries from being discarded by keeping + * strong referents to those entries, leaving the remaining entries to be + * discarded at the discretion of the garbage collector. + * + * @author Mark Reinhold + * @since 1.2 + */ + +public class SoftReference<T> extends Reference<T> { + + /* Timestamp clock, updated by the garbage collector + */ + static private long clock; + + /* Timestamp updated by each invocation of the get method. The VM may use + * this field when selecting soft references to be cleared, but it is not + * required to do so. + */ + private long timestamp; + + /** + * Creates a new soft reference that refers to the given object. The new + * reference is not registered with any queue. + * + * @param referent object the new soft reference will refer to + */ + public SoftReference(T referent) { + super(referent); + this.timestamp = clock; + } + + /** + * Creates a new soft reference that refers to the given object and is + * registered with the given queue. + * + * @param referent object the new soft reference will refer to + * @param q the queue with which the reference is to be registered, + * or <tt>null</tt> if registration is not required + * + */ + public SoftReference(T referent, ReferenceQueue<? super T> q) { + super(referent, q); + this.timestamp = clock; + } + + /** + * Returns this reference object's referent. If this reference object has + * been cleared, either by the program or by the garbage collector, then + * this method returns <code>null</code>. + * + * @return The object to which this reference refers, or + * <code>null</code> if this reference object has been cleared + */ + public T get() { + T o = super.get(); + if (o != null) this.timestamp = clock; + return o; + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/WeakReference.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/WeakReference.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/WeakReference.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,72 @@ +/* + * Copyright 1997-2003 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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. + */ + +package java.lang.ref; + + +/** + * Weak reference objects, which do not prevent their referents from being + * made finalizable, finalized, and then reclaimed. Weak references are most + * often used to implement canonicalizing mappings. + * + * <p> Suppose that the garbage collector determines at a certain point in time + * that an object is <a href="package-summary.html#reachability">weakly + * reachable</a>. At that time it will atomically clear all weak references to + * that object and all weak references to any other weakly-reachable objects + * from which that object is reachable through a chain of strong and soft + * references. At the same time it will declare all of the formerly + * weakly-reachable objects to be finalizable. At the same time or at some + * later time it will enqueue those newly-cleared weak references that are + * registered with reference queues. + * + * @author Mark Reinhold + * @since 1.2 + */ + +public class WeakReference<T> extends Reference<T> { + + /** + * Creates a new weak reference that refers to the given object. The new + * reference is not registered with any queue. + * + * @param referent object the new weak reference will refer to + */ + public WeakReference(T referent) { + super(referent); + } + + /** + * Creates a new weak reference that refers to the given object and is + * registered with the given queue. + * + * @param referent object the new weak reference will refer to + * @param q the queue with which the reference is to be registered, + * or <tt>null</tt> if registration is not required + */ + public WeakReference(T referent, ReferenceQueue<? super T> q) { + super(referent, q); + } + +} Added: trunk/core/src/openjdk/java/java/lang/ref/package.html =================================================================== --- trunk/core/src/openjdk/java/java/lang/ref/package.html (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ref/package.html 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,147 @@ +<!-- + Copyright 1998-2003 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. Sun designates this + particular file as subject to the "Classpath" exception as provided + by Sun in the LICENSE file that accompanied this code. + + 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. +--> + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<body bgcolor="white"> + + +Provides reference-object classes, which support a limited degree of +interaction with the garbage collector. A program may use a reference object +to maintain a reference to some other object in such a way that the latter +object may still be reclaimed by the collector. A program may also arrange to +be notified some time after the collector has determined that the reachability +of a given object has changed. + + +<h2>Package Specification</h2> + +A <em>reference object</em> encapsulates a reference to some other object so +that the reference itself may be examined and manipulated like any other +object. Three types of reference objects are provided, each weaker than the +last: <em>soft</em>, <em>weak</em>, and <em>phantom</em>. Each type +corresponds to a different level of reachability, as defined below. Soft +references are for implementing memory-sensitive caches, weak references are +for implementing canonicalizing mappings that do not prevent their keys (or +values) from being reclaimed, and phantom references are for scheduling +pre-mortem cleanup actions in a more flexible way than is possible with the +Java finalization mechanism. + +<p> Each reference-object type is implemented by a subclass of the abstract +base <code>{@link java.lang.ref.Reference}</code> class. An instance of one of +these subclasses encapsulates a single reference to a particular object, called +the <em>referent</em>. Every reference object provides methods for getting and +clearing the reference. Aside from the clearing operation reference objects +are otherwise immutable, so no <code>set</code> operation is provided. A +program may further subclass these subclasses, adding whatever fields and +methods are required for its purposes, or it may use these subclasses without +change. + + +<h3>Notification</h3> + +A program may request to be notified of changes in an object's reachability by +<em>registering</em> an appropriate reference object with a <em>reference +queue</em> at the time the reference object is created. Some time after the +garbage collector determines that the reachability of the referent has changed +to the value corresponding to the type of the reference, it will add the +reference to the associated queue. At this point, the reference is considered +to be <em>enqueued</em>. The program may remove references from a queue either +by polling or by blocking until a reference becomes available. Reference +queues are implemented by the <code>{@link java.lang.ref.ReferenceQueue}</code> +class. + +<p> The relationship between a registered reference object and its queue is +one-sided. That is, a queue does not keep track of the references that are +registered with it. If a registered reference becomes unreachable itself, then +it will never be enqueued. It is the responsibility of the program using +reference objects to ensure that the objects remain reachable for as long as +the program is interested in their referents. + +<p> While some programs will choose to dedicate a thread to removing reference +objects from one or more queues and processing them, this is by no means +necessary. A tactic that often works well is to examine a reference queue in +the course of performing some other fairly-frequent action. For example, a +hashtable that uses weak references to implement weak keys could poll its +reference queue each time the table is accessed. This is how the <code>{@link +java.util.WeakHashMap}</code> class works. Because the <code>{@link +java.lang.ref.ReferenceQueue#poll ReferenceQueue.poll}</code> method simply +checks an internal data structure, this check will add little overhead to the +hashtable access methods. + + +<h3>Automatically-cleared references</h3> + +Soft and weak references are automatically cleared by the collector before +being added to the queues with which they are registered, if any. Therefore +soft and weak references need not be registered with a queue in order to be +useful, while phantom references do. An object that is reachable via phantom +references will remain so until all such references are cleared or themselves +become unreachable. + + +<a name="reachability"></a> +<h3>Reachability</h3> + +Going from strongest to weakest, the different levels of reachability reflect +the life cycle of an object. They are operationally defined as follows: + +<ul> + +<li> An object is <em>strongly reachable</em> if it can be reached by some +thread without traversing any reference objects. A newly-created object is +strongly reachable by the thread that created it. + +<li> An object is <em>softly reachable</em> if it is not strongly reachable but +can be reached by traversing a soft reference. + +<li> An object is <em>weakly reachable</em> if it is neither strongly nor +softly reachable but can be reached by traversing a weak reference. When the +weak references to a weakly-reachable object are cleared, the object becomes +eligible for finalization. + +<li> An object is <em>phantom reachable</em> if it is neither strongly, softly, +nor weakly reachable, it has been finalized, and some phantom reference refers +to it. + +<li> Finally, an object is <em>unreachable</em>, and therefore eligible for +reclamation, when it is not reachable in any of the above ways. + +</ul> + + +@author Mark Reinhold +@since 1.2 + +<!-- +<h2>Related Documentation</h2> + +For overviews, tutorials, examples, guides, and tool documentation, please see: +<ul> + <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> +</ul> +--> +</body> +</html> Added: trunk/core/src/openjdk/vm/java/lang/ref/NativeFinalizer.java =================================================================== --- trunk/core/src/openjdk/vm/java/lang/ref/NativeFinalizer.java (rev 0) +++ trunk/core/src/openjdk/vm/java/lang/ref/NativeFinalizer.java 2009-03-01 08:55:23 UTC (rev 5077) @@ -0,0 +1,13 @@ +package java.lang.ref; + +/** + * @see java.lang.ref.Finalizer + */ +class NativeFinalizer { + /** + * @see java.lang.ref.Finalizer#invokeFinalizeMethod(java.lang.Object) + */ + private static void invokeFinalizeMethod(Object arg1) { + //todo implement it + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-03-01 09:15:36
|
Revision: 5078 http://jnode.svn.sourceforge.net/jnode/?rev=5078&view=rev Author: lsantha Date: 2009-03-01 09:15:24 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Improved String interning. Modified Paths: -------------- trunk/core/src/core/org/jnode/util/BootableHashMap.java trunk/core/src/core/org/jnode/vm/VmSystemObject.java trunk/core/src/core/org/jnode/vm/classmgr/SelectorMap.java trunk/core/src/core/org/jnode/vm/classmgr/Signature.java trunk/core/src/core/org/jnode/vm/classmgr/VmCP.java trunk/core/src/core/org/jnode/vm/classmgr/VmConstClass.java trunk/core/src/core/org/jnode/vm/classmgr/VmMember.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java trunk/core/src/core/org/jnode/vm/classmgr/VmType.java trunk/core/src/core/org/jnode/vm/classmgr/VmUTF8Convert.java trunk/core/src/openjdk/vm/java/lang/NativeString.java Added Paths: ----------- trunk/core/src/core/org/jnode/vm/InternString.java Modified: trunk/core/src/core/org/jnode/util/BootableHashMap.java =================================================================== --- trunk/core/src/core/org/jnode/util/BootableHashMap.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/util/BootableHashMap.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -250,4 +250,7 @@ locked = true; } + public boolean isLocked() { + return locked; + } } Added: trunk/core/src/core/org/jnode/vm/InternString.java =================================================================== --- trunk/core/src/core/org/jnode/vm/InternString.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/InternString.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -0,0 +1,48 @@ +package org.jnode.vm; + +import org.jnode.util.BootableHashMap; + +/** + * + */ +public class InternString extends VmSystemObject { + private static BootableHashMap<String, String> bootInternTable; + private static boolean booted = false; + + public static String internString(String instance) { + if (booted) { + return instance.intern(); + } else { + if (Vm.getVm().isBootstrap()) { + if (bootInternTable == null) { + bootInternTable = new BootableHashMap<String, String>(); + } + + instance = instance.intern(); + //todo the string interned after emiting bootInternTable will be lost + if (!bootInternTable.isLocked()) { + synchronized (bootInternTable) { + final String str = bootInternTable.get(instance); + if (str != null) { + return str; + } + bootInternTable.put(instance, instance); + } + } + return instance; + } else { + return instance.intern(); + } + } + } + + //todo protect it + public static void boot() { + booted = true; + } + + //todo protect it + public static BootableHashMap<String, String> getBootInternTable() { + return bootInternTable; + } +} Modified: trunk/core/src/core/org/jnode/vm/VmSystemObject.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmSystemObject.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/VmSystemObject.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -43,7 +43,7 @@ res.append(Integer.toHexString(ch)); } } - return res.toString().intern(); + return InternString.internString(res.toString()); } /** @@ -64,7 +64,7 @@ res.append(v.length()); res.append(v); } - return res.toString().intern(); + return InternString.internString(res.toString()); } /** Modified: trunk/core/src/core/org/jnode/vm/classmgr/SelectorMap.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/SelectorMap.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/SelectorMap.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -22,6 +22,7 @@ import org.jnode.util.BootableHashMap; import org.jnode.vm.VmSystemObject; +import org.jnode.vm.InternString; /** * This class is used to maintain a mapping between a method signature (name+type) @@ -42,7 +43,7 @@ * @return The global unique selector */ public int get(String name, String signature) { - final String id = (name + '#' + signature).intern(); + final String id = InternString.internString(name + '#' + signature); final Integer selector = (Integer) map.get(id); if (selector != null) { return selector.intValue(); Modified: trunk/core/src/core/org/jnode/vm/classmgr/Signature.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/Signature.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/Signature.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -23,6 +23,7 @@ import java.util.ArrayList; import org.jnode.vm.JvmType; +import org.jnode.vm.InternString; /** * <description> @@ -247,8 +248,8 @@ } } ofs++; - String sig = new String(signature, start, ofs - start).intern() - .replace('/', '.'); + String sig = new String(signature, start, ofs - start).replace('/', '.'); + sig = InternString.internString(sig); vmClass = loader.loadClass(sig, true); break; } @@ -258,8 +259,8 @@ while (signature[ofs] != ';') { ofs++; } - String sig = new String(signature, start, ofs - start).intern() - .replace('/', '.'); + String sig = new String(signature, start, ofs - start).replace('/', '.'); + sig = InternString.internString(sig); ofs++; vmClass = loader.loadClass(sig, true); break; Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmCP.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -21,6 +21,7 @@ package org.jnode.vm.classmgr; import org.jnode.vm.VmSystemObject; +import org.jnode.vm.InternString; /** * A VmCP is the runtime representation of a constant pool @@ -162,7 +163,7 @@ } protected void setUTF8(int index, String value) { - set(index, value.intern()); + set(index, InternString.internString(value)); } public VmConstString getString(int index) { Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmConstClass.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmConstClass.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmConstClass.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -20,6 +20,8 @@ package org.jnode.vm.classmgr; +import org.jnode.vm.InternString; + /** * Entry of a constantpool describing a class reference. * @@ -38,7 +40,7 @@ * @param name */ VmConstClass(String name) { - this.data = name.replace('/', '.').intern(); + this.data = InternString.internString(name.replace('/', '.')); } /** Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmMember.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmMember.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmMember.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -21,6 +21,7 @@ package org.jnode.vm.classmgr; import org.jnode.vm.annotation.KernelSpace; +import org.jnode.vm.InternString; import org.vmmagic.pragma.Uninterruptible; /** @@ -68,7 +69,7 @@ if (Modifier.isWide(signature)) { modifiers |= Modifier.ACC_WIDE; } - this.name = name.intern(); //todo review interning, this might not be needed here + this.name = InternString.internString(name); //todo review interning, this might not be needed here this.signature = signature; this.modifiers = modifiers; this.declaringClass = declaringClass; Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -27,6 +27,7 @@ import org.jnode.vm.LoadCompileService; import org.jnode.vm.Vm; import org.jnode.vm.VmAddress; +import org.jnode.vm.InternString; import org.jnode.vm.annotation.MagicPermission; import org.jnode.vm.isolate.VmIsolateLocal; import org.vmmagic.unboxed.Address; @@ -254,8 +255,8 @@ */ public final String getMangledName() { if (mangledName == null) { - mangledName = (declaringClass.getMangledName() - + mangle("#" + getName() + '.' + getSignature())).intern(); + mangledName = InternString.internString(declaringClass.getMangledName() + + mangle("#" + getName() + '.' + getSignature())); } return mangledName; } Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmType.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmType.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmType.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -38,6 +38,7 @@ import org.jnode.vm.VmMagic; import org.jnode.vm.VmReflection; import org.jnode.vm.VmSystemClassLoader; +import org.jnode.vm.InternString; import org.jnode.vm.annotation.Inline; import org.jnode.vm.annotation.KernelSpace; import org.jnode.vm.annotation.LoadStatics; @@ -313,10 +314,9 @@ } } - this.name = name.intern(); + this.name = InternString.internString(name); this.superClass = superClass; - this.superClassName = (superClassName == null) ? null : superClassName - .intern(); + this.superClassName = (superClassName == null) ? null : InternString.internString(superClassName); this.modifiers = modifiers; this.state = VmTypeState.ST_LOADED; this.loader = loader; @@ -507,7 +507,7 @@ result[i + 2] = name.charAt(i); } } - arrayClassName = new String(result).intern(); + arrayClassName = InternString.internString(new String(result)); } return arrayClassName; } Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmUTF8Convert.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmUTF8Convert.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmUTF8Convert.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -22,6 +22,7 @@ import java.io.UTFDataFormatException; import java.nio.ByteBuffer; +import org.jnode.vm.InternString; /** * VM_UTF8Convert @@ -127,7 +128,7 @@ + i); } } - return new String(result, 0, result_index).intern(); + return InternString.internString(new String(result, 0, result_index)); } /** Modified: trunk/core/src/openjdk/vm/java/lang/NativeString.java =================================================================== --- trunk/core/src/openjdk/vm/java/lang/NativeString.java 2009-03-01 08:55:23 UTC (rev 5077) +++ trunk/core/src/openjdk/vm/java/lang/NativeString.java 2009-03-01 09:15:24 UTC (rev 5078) @@ -17,25 +17,53 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package java.lang; import java.lang.ref.WeakReference; import java.util.WeakHashMap; +import org.jnode.vm.InternString; +import org.jnode.vm.annotation.SharedStatics; +import org.jnode.util.BootableHashMap; + /** * */ +@SharedStatics public class NativeString { - static final WeakHashMap<String, WeakReference<String>> internTable = new WeakHashMap<String, WeakReference<String>>(); + static final WeakHashMap<String, WeakReference<String>> internTable = + new WeakHashMap<String, WeakReference<String>>(); + static boolean booted = false; + //keeps live refrences to the string in bootheap + //TODO cleanup might still be good in case the bootiamge builder interns unnecessary strings + static BootableHashMap<String, String> bootInternTable; + static void boot() { + bootInternTable = InternString.getBootInternTable(); + for (String instance : bootInternTable.values()) { + final WeakReference<String> ref = internTable.get(instance); + if(ref == null) { + internTable.put(instance, new WeakReference<String>(instance)); + } else { + final String s = ref.get(); + if(s == null) { + internTable.put(instance, new WeakReference<String>(instance)); + } + } + } + InternString.boot(); + } + /** - * - * @param instance - * @return - * @see String#intern() + * @see String#intern() */ private static String intern(String instance){ synchronized (internTable) { + if(!booted) { + boot(); + booted = true; + } + final WeakReference<String> ref = internTable.get(instance); if (ref != null) { final String s = ref.get(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |