Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

classpath.h File Reference


Detailed Description

Implementation of the CLASSPATH environment heuristic.

The Java Virtual Machine Specification, version 2, says absolutely NOTHING about the CLASSPATH item, neither as an environment variable, a JVM command line parameter, or anything. Instead, section 5.3.1 states, "The Java virtual machine searches for a purported representation of [class] C in a platform-dependent manner. Note that there is no guarantee that a purported representation found is valid or is a representation of C. Typically, a class or interface will be represented using a file in a hierarchiacal file system. The name of the class or interface will usually be encoded in the pathname of the file."

This is the industry standard practice, as implemented by use of the CLASSPATH variable. This header file defines its characteristics. The same goes for the JAVA_PATH environment variable, which has no further definitions that its name and string content that contains a path name. Since these variables are actually a part of standard practice, their names are actually defined in jvmcfg.h instead of here, but CLASSPATH behavior is defined here.

Conventions for OS file systems (see also jvmcfg.h for JVMCFG_PATHNAME_xxx and JVMCFG_EXTENSION_xxx definitions).

   Unix style:     CLASSPATH="/path/name1:/path/name2/filename.jar"
  
   Windows style:  CLASSPATH="c:\path\name1;d:\path\name2\\filename.jar"
  
   

Control

$URL: https://svn.apache.org/path/name/classpath.h $ $Id: classpath.h 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file classpath.h.

Go to the source code of this file.

File extensions

Convention for class file names, but not mandatory.

#define CLASSFILE_EXTENSION_DEFAULT   "class"
#define CLASSFILE_EXTENSION_JAR   "jar"
#define CLASSFILE_EXTENSION_ZIP   "zip"

Defines

#define CLASSPATH_ITEM_DELIMITER_CHAR   ':'
 Delimiter betwen members of CLASSPATH string.

Functions

 ARCH_COPYRIGHT_APACHE (classpath, h,"$URL: https://svn.apache.org/path/name/classpath.h $ $Id: classpath.h 0 09/28/2005 dlydick $")
rcharclasspath_external2internal_classname (rchar *clsname)
 Convert class name format external to internal form.
rcharclasspath_external2internal_classname_inplace (rchar *inoutbfr)
rcharclasspath_get_from_cp_entry_utf (cp_info_dup *clsname)
 Search CLASSPATH for a given class name using a CONSTANT_Utf8_info.
rcharclasspath_get_from_prchar (rchar *clsname)
 Search CLASSPATH for a given class name using a prchar.
rvoid classpath_init (rvoid)
rboolean classpath_isjar (rchar *pclasspath)
 Determine whether or not a CLASSPATH entry is a JAR file instead of being a directory name.
rvoid classpath_shutdown (rvoid)


Define Documentation

#define CLASSPATH_ITEM_DELIMITER_CHAR   ':'
 

Delimiter betwen members of CLASSPATH string.

Definition at line 85 of file classpath.h.

#define CLASSFILE_EXTENSION_DEFAULT   "class"
 

Definition at line 99 of file classpath.h.

#define CLASSFILE_EXTENSION_JAR   "jar"
 

Definition at line 100 of file classpath.h.

#define CLASSFILE_EXTENSION_ZIP   "zip"
 

Definition at line 101 of file classpath.h.


Function Documentation

ARCH_COPYRIGHT_APACHE classpath  ,
,
"$URL: https://svn.apache.org/path/name/classpath.h $ $Id: classpath.h 0 09/28/2005 dlydick $" 
 

rvoid classpath_init rvoid   ) 
 

rvoid classpath_shutdown rvoid   ) 
 

rboolean classpath_isjar rchar pclasspath  ) 
 

Determine whether or not a CLASSPATH entry is a JAR file instead of being a directory name.

A JAR file will be named /path/name/filename.jar, while a file name in a directory will be named /path/name/ClassName.class .

Parameters:
pclasspath String from CLASSPATH list
Returns:
rtrue if string ends with .jar, rfalse otherwise.

Definition at line 279 of file classpath.c.

rchar* classpath_external2internal_classname rchar clsname  ) 
 

Convert class name format external to internal form.

The external format is class.name.format , while the internal format is class/name/format . Result is unchanged if it is already in internal format. When finished with result, call HEAP_FREE_DATA().

Parameters:
clsname Null-terminated string containing class name.
Returns:
Null terminated string in internal format. Call HEAP_FREE_DATA() when finished with buffer.

Definition at line 333 of file classpath.c.

rchar* classpath_external2internal_classname_inplace rchar inoutbfr  ) 
 

Definition at line 358 of file classpath.c.

References CLASSNAME_EXTERNAL_DELIMITER_CHAR, and CLASSNAME_INTERNAL_DELIMITER_CHAR.

rchar* classpath_get_from_prchar rchar clsname  ) 
 

Search CLASSPATH for a given class name using a prchar.

Return heap pointer to a buffer containing its location. If not found, return rnull. If a class by this name is stored in more than one location, only the first location is returned. When done with result, call HEAP_FREE_DATA(result) to return buffer to heap area.

All CLASSNAME_EXTERNAL_DELIMITER (ASCII period) characters found in the input class name will be unconditionally replaced with CLASSNAME_INTERNAL_DELIMITER (ASCII slash) characters. Therefore, the class file extension CLASSFILE_EXTENSION_DEFAULT may not be appended to the class name. This constraint permits both internal and external class names to use the same function to search for classes.

Parameters:
clsname Name of class, without .class extension, as either some.class.name or some/class/name , that is, the internal form of the class name. The string may or may not contain class formatting of the form [[[Lsome/class/name;
Returns:
Heap pointer into CLASSPATH of directory or JAR file containing class (for a regular .class file). For a JAR file, report the name of the .jar file as for a .class file, but also call classpath_isjar() to distinguish between them. Thus the usage is, Return rnull if no match.
Todo:
VM Spec section 5.3.1: Throw 'NoClassDeffoundError' if no match.
Notice that clsname must be specified with package designations using INTERNAL (slash) delimiter form of the path. This is what is natively found in the class files. Of course, no package name means the simple default package, that is, an unpackaged class having no package some.package.name statement in source.

               rchar *p = classpath_get_from_prchar(
                                     "some/package/name/SomeClassName");
  
               if (rnull != p)
               {
             
                   if (rtrue == classpath_isjar(p))
                   {
                       ** Extract class from JAR file **
                   }
                   else
                   {
                       ** Read class file directly **
                   }
               }
   

< Convenient size for any disk path

< terminator for instance of class

< Convenient size for a system(3) call

For internal use only.

Build up JAR command using internal class name with suffix. Make sure all files are writeable for final rm -rf.

Definition at line 444 of file classpath.c.

rchar* classpath_get_from_cp_entry_utf cp_info_dup clsname  ) 
 

Search CLASSPATH for a given class name using a CONSTANT_Utf8_info.

Invoke classpath_get_from_prchar after converting clsname from CONSTANT_Utf8_info to prchar.

For more information, see classpath_get_from_prchar.

Parameters:
clsname Name of class, without .class extension, as either some.class.name or some/class/name , that is, the internal form of the class name. The string may or may not contain class formatting of the form [[[Lsome/class/name;
Returns:
Heap pointer into CLASSPATH of directory or JAR file containing class (for a regular .class file).

Definition at line 630 of file classpath.c.


Generated on Fri Sep 30 18:49:41 2005 by  doxygen 1.4.4