⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vmintegration.texinfo

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
methods, handling integers, longs and Objects, but the field is alwayschanged on a put.  Different methods are provided for different semantics.Ordered variants perform a lazy put, in that the change does notimmediately propogate to other threads, while the others providevolatile or 'normal' semantics.@item @code{arrayBaseOffset(Class)} and @code{arrayIndexScale(Class)} --These two methods allow an array class to be traversed by pointerarithmetic, by gaining the address of the first element and thenscaling appropriately for the later ones.@item @code{park(boolean,long)} and @code{unpark(Thread)} -- These methodsblock and unblock threads respectively, with an optional timeout beingprovided for the blocking.  @code{unpark} is unsafe as the thread may havebeen destroyed by native code. @end itemize@node java.util, java.io, gnu.classpath, Classpath Hooks@section java.utilThe @code{java.util} VM hooks provide links between the mix of functionalitypresent in that package, which includes collections, date and time handlingand parsing.  At present, there is only one hook, which connects GNU Classpathto the timezone information provided by the underlying platform.@menu* java.util.VMTimeZone::@end menu@node java.util.VMTimeZone,,java.util,java.util@subsection @code{java.util.VMTimeZone}@code{VMTimeZone} joins @code{TimeZone} to the platform timezone informationvia the static method, @code{getDefaultTimeZoneId()}.  The VM hook isexpected to return a @code{TimeZone} instance that represents the currenttimezone in use by the platform.  The default implementation providesthis functionality for POSIX or GNU-like systems, and VMs that want thisfunctionality can keep this implementation and implement the nativemethod, @code{getSystemTimeZoneId()}.  This method is only called whenobtaining the timezone name from the @code{TZ} environment variable,@code{/etc/timezone} and @code{/etc/localtime} all fail.  This fallbackmechanism also means that a system which doesn't provide the above threemethods, but does provide a timezone in string form, can still use thisimplementation.@node java.io, java.security, java.util, Classpath Hooks@section java.ioThe @code{java.io} package is heavily reliant on access to the I/O facilitiesof the underlying platform.  As far as its VM hooks go, they provide twoareas of functionality to GNU Classpath, these being@itemize @bullet@item File and directory queries and manipulation@item Serialization of objects@end itemizeThe first corresponds directly to most of the @code{File} class, whilethe latter underlies the functionality provided by the@code{ObjectInputStream} and @code{ObjectOutputStream}.  More low-level I/Ois provided by @ref{java.nio}.@menu* java.io.VMFile::* java.io.VMObjectInputStream::* java.io.VMObjectStreamClass::@end menu@node java.io.VMFile,java.io.VMObjectInputStream,java.io,java.io@subsection @code{java.io.VMFile}@code{VMFile} allows GNU Classpath's @code{File} representations toprobe and modify the file system using the native functions of theplatform.  The default implementation (which consists of both a@code{VMFile} class and the native methods) is primarily UNIX-centric,working with POSIX functions and assuming case-sensitive filenames,without the restriction of the 8.3 format.  It consists mainly of@code{static} @code{native} methods, with a few Java helper methods.The native methods represent the file as a string containing its path,rather than using the object itself.@itemize @bullet@item Native Methods@itemize @bullet@item @code{lastModified(String)} -- The native method should return a@code{long} value that represents the last modified date of the file.@item @code{setReadOnly(String)} -- Sets the file's permissions to read only,in whichever way this is realised by the platform.@item @code{create(String)} -- Create the named file.@item @code{list(String)} -- The native method opens the named directory,reads the contents and returns them as a Java @code{String} array.@item @code{renameTo(String,String)} -- Renames the first file to the second.@item @code{length(String)} -- Returns a @code{long} value representingthe file size.@item @code{exists(String)} -- Tests for the existence of the named fileor directory.@item @code{delete(String)} -- Deletes the file or directory.@item @code{setLastModified(String,long)} -- Change the last modified time.@item @code{mkdir(String)} -- Creates the named directory.@item @code{isFile(String)} -- Tests that the named path references a file.@item @code{canWrite(String)} -- Tests that the file can be written to.This method is @code{synchronized}, so the object is locked during the check.@item @code{canRead(String)} -- Complement of the last method.@item @code{isDirectory(String)} -- Tests that the named path referencesa directory.@end itemize@item Java Helper Methods@itemize @bullet@item @code{canWriteDirectory(File)} -- Checks that the directory can bewritten to, by trying to create a temporary file in it.@item @code{listRoots()} -- Returns the root of a GNU filesystem i.e. `/'in an array.@item @code{isHidden(String)} -- Checks whether the file starts with `.',which is how files are hidden on UNIX-style systems.@item @code{getName(String)} -- Pulls the actual filename from the end ofthe path, by breaking off the characters after the last occurrence of theplatform's file separator.@item @code{getCanonicalForm(String)} -- This converts a UNIX path toits canonical form by removing the `.' and `..' sections that occur within.@end itemize@end itemize@node java.io.VMObjectInputStream,java.io.VMObjectStreamClass,java.io.VMFile,java.io@subsection @code{java.io.VMObjectInputStream}This class consists of two methods which provide functionality used indeserializing an object.  @code{currentClassLoader()} provides the firstuser-defined class loader from the class context(@xref{gnu.classpath.VMStackWalker},) via a @code{PrivilegedAction}.@code{allocateObject(Class,Class,Constructor)} is a @code{native} method(a reference implementation is provided) which creates an object butcalls the constructor of another class, which is a superclass of theobject's class.@node java.io.VMObjectStreamClass,,java.io.VMObjectInputStream,java.io@subsection @code{java.io.VMObjectStreamClass}@code{VMObjectStreamClass} is a series of @code{static} @code{native}methods that provide some of the groundwork for @code{ObjectStreamClass}and @code{ObjectStreamField}.  @code{hasClassInitializer(Class)} workswith the former, and checks for the presence of a static initializer.The remaining methods are of the form @code{setXXXNative(Field,Object,XXX)}and support @code{ObjectStreamField}.  One exists for each of the main types(boolean, float, double, long, int, short, char, byte and object) and is usedto set the specified field in the supplied instance to the given value.A default implementation is provided for all of them, so a VM implementationis optional.@node java.security, java.net, java.io, Classpath Hooks@section java.securityThe @code{java.security} package provides support for Java's securityarchitecture.  At present, @code{VMAccessController} represents the soleVM hook for this.@menu* java.security.VMAccessController::@end menu@node java.security.VMAccessController,,java.security,java.security@subsection @code{java.security.VMAccessController}The @code{AccessController} is used to perform privileged actions.  Itshook class, @code{VMAccessController}, maintains the@code{AccessControlContext} and the default implementation is purelyJava-based.  The VM may choose to replace this with their own.The methods in the reference version are as follows:@itemize @bullet@item @code{pushContext(AccessControlContext)} -- Adds a new context to thestack for the current thread.  This is called before a privileged actiontakes place.@item @code{popContext()} -- Removes the top context from the stack.  Thisis performed after the privileged action takes place.@item @code{getContext()} -- Either derives a context based on the @code{ProtectionDomain}s of the call stack (see the next method) or returnsthe top of the context stack.@item @code{getStack()} -- Provides access to the call stack as a pair ofarrays of classes and method names.  The actual implementation returnsan empty array, indicating that there are no permissions.@end itemize@node java.net, java.nio, java.security, Classpath Hooks@section java.netThe @code{java.net} package is heavily reliant on access to the networkingfacilities of the underlying platform.  The VM hooks provide informationabout the available network interfaces, and access to lookup facilitiesfor network addresses.@menu* java.net.VMInetAddress::* java.net.VMNetworkInterface::@end menu@node java.net.VMInetAddress,java.net.VMNetworkInterface,java.net,java.net@subsection @code{java.net.VMInetAddress}@code{VMInetAddress} is a series of @code{static} @code{native} methodswhich provide access to the platform's lookup facilities.  All the methodsare implemented by GNU Classpath, making VM implementation optional, andare as follows:@itemize @bullet@item @code{getLocalHostname()} -- Wraps the @code{gethostname} function, andfalls back on `localhost'.@item @code{lookupInaddrAny()} -- Returns the value of @code{INADDR_ANY}.@item @code{getHostByAddr(byte[])} -- Looks up the hostname based on an IPaddress.@item @code{getHostByName(String)} -- The reverse of the last method, itreturns the IP addresses which the given host name resolves to.@end itemize@node java.net.VMNetworkInterface,,java.net.VMInetAddress,java.net@subsection @code{java.net.VMNetworkInterface}@code{VMNetworkInterface} currently consists of a single @code{static}@code{native} method, @code{getInterfaces()}, which retrieves thenetwork interfaces available on the underlying platform as a @code{Vector}.The current GNU Classpath implementation is a native stub.@node java.nio, java.nio.channels, java.net, Classpath Hooks@section java.nioThe @code{java.nio} package is part of the New I/O framework added inJava 1.4.  This splits I/O into the concepts of @emph{buffers},@emph{charsets}, @emph{channels} and @emph{selectors}, and@code{java.nio} defines the buffer classes.  As far as native and VMcode is concerned, the new package needs support for low-level efficientbuffer operations.@menu* java.nio.VMDirectByteBuffer::@end menu@node java.nio.VMDirectByteBuffer,,java.nio,java.nio@subsection @code{java.nio.VMDirectByteBuffer}A @code{ByteBuffer} maintains a buffer of bytes, and allows it to bemanipulated using primitive operations such as @code{get}, @code{put},@code{allocate} and @code{free}.  A direct buffer avoids intermediatecopying, and uses native data which shouldn't be manipulated by agarbage collector.  The VM class consists of @code{static} @code{native}methods, all of which are given default implementations by GNUClasspath.@itemize @bullet@item @code{init()} -- Creates an instance of an appropriate@code{gnu.classpath.RawData} class.  This class is not garbagecollected, is created natively and is used in the other methods to referencethe buffered data.@item @code{allocate(int)} -- Allocates the memory for the buffer using@code{malloc} and returns a reference to the @code{RawData} class.@item @code{free(RawData)} -- Frees the memory used by the buffer.@item @code{get(RawData,int)}  -- Returns the data at the specified index.@item @code{get(RawData,int,byte[],int,int)} -- Copies a section of thedata into a byte array using @code{memcpy}.@item @code{put(RawData,int,byte)} -- Puts the given data in the bufferat the specified index.@item @code{adjustAddress(RawData,int)} -- Adjusts the pointer into the buffer.@item @code{shiftDown(RawData,int,int,int)} -- Moves the content of the bufferat an offset down to a new offset using @code{memmove}.@end itemize @node java.nio.channels, gnu.java.nio, java.nio, Classpath Hooks@section java.nio.channelsChannels provide the data for the buffers with the New I/O packages.For example, a channel may wrap a file or a socket.  The VM hooks,at the moment, simply allow the channels to be accessed by @code{java.io}streams.@menu* java.nio.channels.VMChannels::@end menu@node java.nio.channels.VMChannels,,java.nio.channels,java.nio.channels@subsection @code{java.nio.channels.VMChannels}@code{VMChannels} provides the methods that create the channels orstreams.  The default implementation is in pure Java and simply wrapsthe channels in standard I/O classes from @code{java.io}.@itemize @bullet@item @code{createStream(Class,Channel)} -- Creates a @code{FileChannel}which wraps an instance of the specified stream class, created by reflection.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -