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

classpath.c File Reference


Detailed Description

Extract CLASSPATH runtime variables from the environment and/or the command line or other appropriate sources.

The HEAP_INIT() function must have been called before using these functions so the environment variables can be stored into it and not depend on the argument or environment pointers to always be unchanged.

The tmparea_init() function must have been called before these functions so the internal CLASSPATH can be set up properly.

Control

$URL: https://svn.apache.org/path/name/classpath.c $ $Id: classpath.c 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.c.

#include "arch.h"
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "jvmcfg.h"
#include "cfmacros.h"
#include "classfile.h"
#include "classpath.h"
#include "exit.h"
#include "heap.h"
#include "linkage.h"
#include "jvm.h"
#include "nts.h"
#include "utf.h"
#include "util.h"

Go to the source code of this file.

Functions

static void classpath_c_dummy (void)
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 ()
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 ()
 Shut down the CLASSPATH search area of the JVM model after JVM execution.

Variables

static char * classpath_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/classpath.c $ $Id: classpath.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable."
static rchar ** classpath_list = ((rvoid *) 0)
 Initialize CLASSPATH search area of the JVM model. Permit null pointer manifest constant for initializing static and global storage.
static rint classpath_list_len = 0


Function Documentation

static void classpath_c_dummy void   )  [static]
 

Definition at line 49 of file classpath.c.

rvoid classpath_init  ) 
 

Definition at line 110 of file classpath.c.

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.

rvoid classpath_shutdown  ) 
 

Shut down the CLASSPATH search area of the JVM model after JVM execution.

Parameters: rvoid

Returns:
rvoid

Definition at line 653 of file classpath.c.


Variable Documentation

char* classpath_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/classpath.c $ $Id: classpath.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." [static]
 

Definition at line 49 of file classpath.c.

rchar** classpath_list = ((rvoid *) 0) [static]
 

Initialize CLASSPATH search area of the JVM model. Permit null pointer manifest constant for initializing static and global storage.

Break CLASSPATH apart into its constituent paths. Run once during startup to parse CLASSPATH. Heap management must be started before calling this function via HEAP_INIT(). The command line must also have been scanned via argv_init().

The tmparea_init() function must have been called before these functions so the internal CLASSPATH can be set up properly.

Parameters:
argc Number of arguments on command line
argv Argument vector from the command line
envp Environment pointer from command line environ
Returns:
rvoid
Todo:
Add proper searching for rt.jar file and Xbootclasspath . For the moment, they are defined in config.h as the CONFIG_HACKED_RTJARFILE and CONFIG_HACKED_BOOTCLASSPATH pre-processor symbols and are commented in jvmcfg.h after this fashion.

Definition at line 103 of file classpath.c.

rint classpath_list_len = 0 [static]
 

Definition at line 108 of file classpath.c.


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