eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Autoload':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Autoload


Inheritance:

   nil
   |
   +--Autoload

  This class inherits NOTHING - most messages will lead into doesNotUnderstand:

Package:
stx:libbasic
Category:
Kernel-Classes
Version:
rev: 1.189 date: 2022/07/01 15:44:37
user: cg
file: Autoload.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


Autoload is a stub for an 'as yet unloaded' class.

In memory limited systems (as my original 8Mb 386 system was),
all seldom-used classes were made subclasses of this class.
Autoload catches all messages sent to it, and files-in the real class's
code when first used. Then the caught message is resent to the (now existing) class.

A note from later days:
    These days, systems usually have enough memory to allow
    having all classes present, so many of the classes which used to be
    autoloaded are no longer these days. However, a number of examples or
    very seldom used frameworks are still present as autoloaded.
    Instead of using autoloaded classes, it is now recommended to bundle
    extra classes into packages, which are loaded en-bloque.
    Packages can be compiled to a shared class library and thus be loaded
    much faster (there is no need to parse and compile source files).

Lazy loading:
Class files are searched along the searchPath (see Smalltalk),
and any of binary-classFile, byteCode-classFile or sourceFile are loaded,
whichever is found first.
For binaries to be loaded, these must be found in a package-subdirectory
along the so called package path.
Sources in a package directory along the source path.
In practice, most Autoloaded classes are found and loaded as source file.

Initial Setup of Auoload Stubs:
At initial startup (i.e. when ST/X is NOT coming up with an image),
the 'patches' startup script recursively walks along all directories
below the TOP directory (that is one above the stx folder),
and installs autoload stubs for all .st class files found, for which no
corresponding class is already present.
As you can imagine, this takes a long time and makes the initial startup quite slow.
Therefore, this scheme is no longer the recommended one and we (at eXept)
always start ST/X with the '--quick' option, which skips this scan operation.
Late note:
    --quick is now (7.1.1) the default.
    To force an autoload scan, start stx with a --autoload argument.


Advantage of Autoload stubs:
Autoload stubs make it easier for a beginner to ST/X, to see what frameworks and classes
are there, as they appear in the browser with category and class name (although no
more details are initially visible.

[class variables:]

    LazyLoading             <Boolean>       if true, the loaded classes
                                            methods will NOT be compiled at
                                            autoload time, but instead when
                                            first called. This allows for a
                                            faster load. However, expect short
                                            pauses later when the methods are
                                            first executed.

    AutoloadFailedSignal    <Signal>        signal raised if an autoloaded
                                            classes source is not available.

    LoadedClasses           <Collection>    set of classes that heve been
                                            autoloaded (for later unload)

copyright

COPYRIGHT (c) 1991 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

Signal constants
o  autoloadFailedSignal
return the signal raised when an autoload fails

adding/removing autoloaded classes
o  addClass: aClassName
given a name, install a corresponding autoload class stub for it.
Return the (autoload-) stubClass or nil, if no new class was created.

Usage example(s):

     Autoload addClass:'Clock'

o  addClass: aClassName inCategory: aCategory
given a name, install a corresponding autoload class stub for it.
Return the (autoload-) stubClass or nil, if no new class was created.

Usage example(s):

     Autoload addClass:'Clock' inCategory:'autoloaded-Demos'

o  removeClass: aClass
remove a class from the list of loaded classes

fileOut
o  basicFileOutDefinitionOn: aStream withNameSpace: forceNameSpace withPackage: withPackage
print an expression to define myself on aStream.
Since autoloaded classes don't know their real definition, simply
output some comment string making things clear in the browser.

initialization
o  initialize
initialize either the Autoload class
or load an autoloaded class and initialize it.

Usage example(s):

initialize myself

lazy compilation
o  compileLazy
return the lazy loading flag - if on, fileIn is much faster,
but pauses are to be expected later, since methods are compiled
when first executed.

o  compileLazy: aBoolean
turn on/off lazy loading - if on, fileIn is much faster,
but pauses are to be expected later, since methods are compiled
when first executed.
If you like it, add a line to your startup file.

loading
o  autoload
use this to force loading
- it is defined a noop in all non-autoloading classes.
Return the loaded class

Usage example(s):

Class is already being loaded. 
         In most cases we come here through the path:
            subclass autoload 
            -> superclass autoload 
            -> superclass initialize/postAutoload 
            -> subclass autoload (hardcoded in initialize method).
         Simply ignore it here

Usage example(s):

if filename is absolute, the autoload-class was created by an

Usage example(s):

explicit install-as-autoloaded via the fileBrowser.

Usage example(s):

reinstall the autoload class, this will be undone by #become:

Usage example(s):

         USER INFORMATION:
         this exception has been raised because an autoloaded class
         could not be loaded. Usually, this happens when
         the classes sourcefile is missing, unreadable or if 
         an entry is missing in the abbreviation file.

         Check for a readable file named .st 
         in the 'source' directory and (if the fileName is not the same as the class name) 
         for a corresponding entry in the abbreviation file 'abbrev.stc'.
         Finally, your searchpath could be set wrong -
         the package might not be found along one of the directories named in systemPath.

         In the debugger, press 'Abort' to continue execution.

Usage example(s):

autoloaded classes get their package from the revision (if present)

Usage example(s):

this only happens with autoloaded sourceFiles which have no package

message catching
o  askFor: aSelector
catch askFor: - load the class and resend #askFor: to the real one

Usage example(s):

     Wrapper unload.
     Wrapper askFor:#isSecret

o  at: arg
catch at: - redefined because it is understood

o  basicNew
catch basicNew - load the class and send it to the real one

o  basicNew: arg
catch basicNew: - load the class and send it to the real one

o  classResources
catch classResources - load the class and resend to the real one

o  comment
return the classes comment.
Autoloaded classes have no comment; but I myself have one

o  copy
catch copy - load the class and resend #copy to the real one

o  doesNotUnderstand: aMessage
caught a message; load the class and retry the message

o  error
catch error - load the class and resend #error to the real one

o  fromString: aString
catch - load the class and send it to the real one

o  handle: handler do: aBlock
autoload the class and resend

o  in: arg
catch new: - load the class and resend #in: to the real one

o  inspectorExtraAttributes
( an extension from the stx:libtool package )
extra (pseudo instvar) entries to be shown in an inspector.

o  isAbstract
actually: don't know, but do not want to load my class for this query

o  new
catch new - load the class and resend #new to the real one

o  new: arg
catch new: - load the class and resend #new: to the real one

o  privateClassesAt: aClassNameString
catch - load the class and send it to the real one

o  readFrom: aStream
catch - load the class and send it to the real one

o  readFrom: aStream onError: exceptionBlock
catch - load the class and send it to the real one

o  readFromString: aString
catch - load the class and send it to the real one

o  readFromString: aString onError: exceptionBlock
catch - load the class and send it to the real one

o  respondsTo: aSelector
catch respondsTo: - load the class and resend #respondsTo: to the real one

o  value
catch value - load the class and resend #value to the real one

private
o  loadAndResendMessage
common helper to autoload a class and define a subclass of it by sending
the sender-message again.
This is invoked by all #subClass... definition messages.

queries
o  accepts: aSignalOrExceptionClass
redefined to avoid recursive autoload.
(#autoload eventually raises QueryExceptions.
These exception may send #accepts: to exception classes
that are currently being loaded)

o  handles: anException
redefined to avoid recursive autoload.
(#autoload eventually raises QueryExceptions.
These exception may send #handles: to exception classes
that are currently being loaded)

o  isBehavior
return true, if the receiver is describing another object's' behavior.
Autoloaded classes are definitely; therefore return true.

o  isBeingLoaded
answer true if the class loading is currently in process

o  isBuiltInClass
return true if this class is known by the run-time-system.
Returns false here.

o  isLoaded
return true, if the class has been loaded.
Autoload itself is loaded, subclasses are not.
This allows testing whether a class has already been loaded.

o  loadedClasses
return the set of classes that were autoloaded

o  privateClassesOrAll: allOfThem
an autoloaded class has none

o  wasAutoloaded: aClass
return true, if aClass was autoloaded

utilities
o  withClass: aClass loadedDo: aBlock
ensure that aClass is loaded, while evaluating aBlock for it

Usage example(s):

     Autoload withClass:Array loadedDo:[:cls | self assert:cls isLoaded]
     Autoload withClass:Cons loadedDo:[:cls | self assert:cls isLoaded]


Subclasses (direct subclasses only):




ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:07:12 GMT