Home > Store

Component Development for the Java Platform

Register your product to gain access to bonus material or receive a coupon.

Component Development for the Java Platform

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2002
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 360
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-75306-5
  • ISBN-13: 978-0-201-75306-6

If you're serious about writing components in Java, this book focuses on the component services you need to master. DevelopMentor Chief Scientist Stuart Halloway presents unprecedented, in-depth coverage of writing, deploying, and maintaining Java components. Halloway begins by showing how to use, control, and troubleshoot components. He offers real-world guidance on reflection performance, and demonstrates how reflection is used to build the Java serialization architecture. He also offers detailed coverage of using the Java Native Interface (JNI) to control the boundaries between Java code and components written in other environments. In Part II, Halloway presents a practical vision for using component services to become a more effective Java developer. Through examples and sample code, he introduces generative programming techniques that leverage Java into high performance. Finally, building on these techniques, he shows how to construct robust interoperability between Java and Win32/COM.

Sample Content

Online Sample Chapter

Java Type Information and Reflection

Downloadable Sample Chapter

Click below for Sample Chapter related to this title:
hallowaych03.pdf

Table of Contents



Preface.


1. From Objects to Components.


2. The Class Loader Architecture.

Assembling an Application.

Goals of the Class Loader Architecture.

Transparency.

Extensibility.

Capability @

Configurability.

Handling Name and Version Conflicts.

Security.

Explicit and Implicit Class Loading.

Explicit Loading with URLClassLoader.

Implicit Class Loading.

Reference Type vs. Referenced Class.

ClassLoader.loadClass vs. Class.forName.

Loading Nonclass Resources.

The Class Loader Rules.

The Consistency Rule.

The Delegation Rule.

The Visibility Rule.

Delegations as Namespaces.

Static Fields are Not Singletons.

Implicit Loading Hides Most Details.

Hot Deployment.

Using Hot Deployment.

Unloading Classes.

Making Sure Classes are Collectable.

Bootclasspath, Extensions Path, and Classpath.

The Classpath.

The Extensions Path.

The Bootstrap Loader.

Debugging Class Loading.

Instrumenting an Application.

Using -verbose:class.

Instrumenting the Core API.

Inversion and the Context Class Loader.

Onward.

Resources.



3. Type Information and Reflection.

The Binary Class Format.

Binary Compatibility.

Binary Class Metadata.

From Binary Classes to Reflection.

Reflection.

Reflecting on Fields.

The Difference between get and getDeclared.

Type Errors Occur at Runtime.

Reflecting on Methods.

Reflective Invocation.

A Reflective Launcher.

Wrapping Primitive Types.

Bypassing Language Access Rules.

Exceptions Caused by Reflective Invocation.

Dynamic Proxies.

Delegation Instead of Implementation Inheritance.

Dynamic Proxies Make Delegation Generic.

Implementing InvocationHandler.

Implementing a Forwarding Handler.

The InvocationHandler as Generic Service.

Handling Exceptions in an InvocationHandler.

Either Client or Server can Install a Proxy.

Advantages of Dynamic Proxies.

Reflection Performance.

Package Reflection.

Setting Package Metadata.

Accessing Package Metadata.

Sealing Packages.

Weaknesses of the Versioning Mechanism.

Custom Metadata.

Onward.

Resources.



4. Serialization.

Serialization and Metadata.

Serialization Basics.

Serialization Skips Some Fields.

Serialization And Class Constructors.

Using readObject and writeObject.

Matching Streams With Classes.

The serialVersionUID.

Overriding the Default SUID.

Compatible and Incompatible Changes.

Explicitly Managing Serializable Fields.

ObjectInputStream.GetField Caveats.

Writer Makes Right.

Overriding Class Metadata.

Performance Problems.

Custom Class Descriptors.

Abandoning Metadata.

Writing Custom Data After defaultWriteObject.

Externalizable.

Using writeObject to Write Raw Data Only: Bad Idea.

Object Graphs.

Pruning Graphs with Transient.

Preserving Identity.

Encouraging the Garbage Collector with Reset.

Object Replacement.

Stream-Controlled Replacement.

Class-Controlled Replacement.

Ordering Rules for Replacement.

Taking Control of Graph Ordering.

Finding Class Code.

Annotation in RMI.

RMI MarshalledObjects.

Onward.

Resources.



5. Customizing Class Loading.

Java 2 Security.

The Role of Class Loaders.

Custom Class Loaders.

Pre-Java 2 Custom Class Loaders.

Class Loading Since SDK 1.2.

A Transforming Class Loader.

Protocol Handlers.

Implementing a Handler.

Installing a Custom Handler.

Choosing Between Loaders and Handlers.

Getting Past Security to the Loader You Need.

Reading Custom Metadata.

Example: Version Attributes.

Serializable Classes as Attributes.

Reading Attributes During Class Loading.

Debugging Support.

Onward.

Resources.



6. Interop 1: JNI.

Why Interoperate?

The Dangers of Native Code.

Finding and Loading Native Code.

Name Mappings.

Type Mappings.

Overloaded Names.

Loading Native Libraries.

Class Loaders and JNI.

Common Errors Loading Native Libraries.

Troubleshooting Native Loading.

Calling Java from C++.

Minimizing Round Trips.

Performance Comparisons.

Differences Between JNI and Reflective Invocation.

Error Handling in JNI.

Failures in Native Code.

Handling C++ Exceptions.

Handling Java Exceptions from Native Code.

Throwing Java Exceptions from Native Code.

Resource Management.

Interacting with the Garbage Collector.

Managing Native Resources.

Managing Arrays.

Managing Strings.

Onward.

Resources.



7. Generative Programming.

Why Generate Code?

Object Oriented Approaches to Modeling Variabilities.

Thinking in Terms of Bind Time.

Separating Specification From Bind Time.

Choosing a Specification Language.

Reuse Requires More than One Use.

A Little Domain Analysis is a Dangerous Thing.

Why Generate Code with Java?

Type Information Acts As a Free Specification Document.

Class Loading Supports Flexible Binding Modes.

Java Source is Easy To Generate.

Java Binary Classes are Easy To Generate.

Code Generation Boosts Performance.

Levels of Commitment to Code Generation.

A Taxonomy of Bind Times and Modes.

Code Generation in RMI.

Code Generation in JSP.

Code Generation in EJB.

The Deployment Descriptor.

Alternate Implementations.

Generating Strongly Typed Collections.

Code Generation Language versus Target Language.

Generating Custom Serialization Code.

Onward.

Resources.



8. Onward.

Where We Are.

Where We Are Going.

Resources.



Appendix—Interop 2: Bridging Java and Win32/COM.


Index. 0201753065T11262001

Preface

This book is about developing components using the Java platform. In this book, the term component has a very specific meaning. A component is an independent unit of production and deployment that is combined with other components to assemble an application.

To elaborate on this definition, consider the difference between objects and components. An object represents an entity in the problem domain, while a component is an atomic piece of the installed solution. The object and component perspectives are complementary, and good designs take account of both.

Modern development platforms such as Java provide the infrastructure that developers need to create classes and components. To support object-oriented programming, Java provides encapsulation, inheritance, and polymorphism. To support components, Java provides loaders and rich type information. This book assumes that you already understand object-oriented programming in Java, and it explains how to use Java's component infrastructure effectively.

Loaders are responsible for locating, bringing into memory, and connecting components at runtime. Using Java's loaders, you can

  • Deploy components at fine granularity.
  • Load components dynamically as needed.
  • Load components from other machines on the network.
  • Locate components from custom repositories.
  • Create mobile code agents that live across multiple virtual machines.
  • Import the services of non-Java components.

Loaders manage the binary boundaries between components. In a world of distributed applications and multiple component suppliers, loaders locate and connect compatible components.

Type information describes the capabilities of some unit of code. In some development environments type information is present only in source code. In Java, type information is not merely a source code artifact; it is also an intrinsic part of a compiled class and is available at runtime through a programmatic interface. Because Java type information is never "compiled away," loaders use it to verify linkages between classes at runtime. In application programming, you can use type information to

  • Serialize the state of Java objects so that they can be recreated on another virtual machine.
  • Create dynamic proxies at runtime, to provide generic services that can decorate any interface.
  • Translate data into alternate representations to interoperate with non-Java components.
  • Convert method calls into network messages.
  • Convert between Java and XML, the new lingua franca of enterprise systems.
  • Annotate components with application-specific metadata.
Type information automates many tasks that might otherwise be coded by hand, and it helps to make components forward compatible to platforms of the future.

Who Should Read This Book

You should read this book if you want to design, develop, or deploy substantial applications in Java. Taking a full-lifecycle view of a Java application requires that you consider not just objects, but components. This book is about the core features of Java as a component platform: class loaders, reflection, serialization, and interoperation with other platforms. You should already know the basics of Java syntax and have some experience in object-oriented programming with Java.

This book is not specifically about high-level Java technologies, such as Remote Method Invocation (RMI), Enterprise JavaBeans (EJB), JINI, Java Server Pages (JSP), servlets, or JavaBeans, but understanding the topics in this book is critical to using those technologies effectively. If you learn how to use the component services described here, you will understand how these high-level technologies are built, which is the key to employing them effectively.

Security is also an important aspect of component development and deployment. It is too complex a topic to handle fairly here, and it deserves its own book-length treatment. (See Gon99 for coverage of security on the Java platform.)

Organization of the Book

The chapters of this book fall into three sections. Chapter 1 introduces components. Chapters 2 through 6 explain loaders and type information on the Java platform. Chapter 7 shows more advanced uses of these services.

Chapter 1 introduces component-oriented programming. Component relationships must be established not only at compile time, but also at deployment and runtime. This chapter asks the key questions of component programming and relates them to the Java platform services discussed in subsequent chapters. Though the other chapters might be read out of order, you should definitely read this chapter first.

Chapter 2 shows how to use and troubleshoot class loaders. Class loaders control the loading of code and create namespace boundaries between code in the same process. With class loaders you can load code dynamically at runtime, even from other machines. Class loader namespaces permit multiple versions of the same class in a single Java virtual machine. You can use class loaders to reload changed classes without ever shutting down the virtual machine. You will see how to use class loaders, how the class loader delegation model creates namespaces, and how to troubleshoot class loading bugs. You will also learn to effectively control the bootclasspath, extensions path, and classpath.

Chapter 3 introduces Java type information. Java preserves type information in the binary class format. This means that even after you compile your Java programs, you still have access to field names, field types, and method signatures. You can access type information at runtime via reflection, and you can use type information to build generic services that add capability to any object. You will see how to use dynamic invocation, dynamic proxies, package reflection, and custom attributes. Chapter 3 also includes a discussion of reflection performance.

Chapter 4 shows how Java serialization uses reflection. Serialization is a perfect example of a generic service. Without any advance knowledge of a class's layout, serialization can ship both code and state from one virtual machine to another across time or space. You will see how the serialization format embeds its own style of type information and how you can customize that representation. You will also see how to extend default serialization, replace it entirely with custom externalization code, or tune it to handle multiple versions of a class as code evolves. You will then learn how to validate objects being deserialized into your application and how to annotate serialized objects with instructions for finding the correct class loader.

Chapter 5 returns to class loaders and shows you how to implement your own. While the standard class loaders are dominant in most applications, custom class loaders allow you to transform class code as classes are loaded. These transformations could include decryption, adding instrumentation for performance monitoring, or even building new classes on-the-fly at runtime. You will see how to tie your custom class loaders into Java's security architecture, how to write a custom class loader, and how to write protocol handlers that can customize not just how you load classes, but also how you load any other type of resource.

Chapter 6 presents the Java Native Interface (JNI) as a basic means of controlling the boundary between Java code and components written in other environments. JNI provides a set of low-level tools for exposing Java objects to platform native code and native code to Java objects. You will learn to use the JNI application programming interface (API) to translate between Java and native programming styles—which differ markedly in their approach to class loading, type information, resource management, error handling, and array storage. Understanding the deficiencies of JNI sets the stage for Appendix A, which describes a higher-level approach.

Chapter 7 discusses using Java metadata to automate the creation of source code or bytecode. Generated code is a high-performance strategy for reuse because you generate only the exact code paths that you will need at runtime. The chapter first presents JSP and EJB as examples of existing applications that auto-generate code, and then it introduces some ideas for code generation in your own programs.

Appendix A returns to interoperation. By building on the code generation techniques from Chapter 7, Appendix A shows you how to build an interoperation layer between Java and another component platform: Win32/COM. This chapter uses the open source Jawin library as an example, to show you how to generate Java stubs for Win32 objects, and vice versa.

Sample Code, Website, Feedback...

Unless specifically noted otherwise, all the sample code in this book is open source. You can download sample code from the book's website at http://staff.develop.com/halloway/compsvcs.html.

Unless otherwise noted, the code in this book is compiled and tested against the Java 2 Software Development Kit (SDK) version 1.3. Most of the code in the book will work identically under SDK versions 1.2, 1.3, and 1.4. Where this is not the case, the text will include a specific reference to the appropriate SDK version.

The author welcomes your comments, corrections, and feedback. Please send email to stu@develop.com.



0201753065P11212001

Bibliography

Download the Bibliography related to this title.

Index

A

Abandoning metadata, 124-130
Abstract classes, 61
Abstract methods, 61
AccessControlException class, 78, 157, 177
AccessibleObject class, 77, 215
Account object, 263
Accounts class, 263
Activatable class, 150
AddRef method, 293
AllocHandle, 231
AllocObject class, 216-217
AnnotateClass method, 147
AnnotatedOutputStream class, 148
Annotating components, XVI
Apartments, 297
App library, 200
AppClassLoader, 45
Applets, 25-26
Application class, 22
Application class loader, 37
Applications
assembling, 11-14
assembling with components, 3
bypassing or ignoring settings, 14
configuration settings, 12
data resources, 12
dynamic, 12
growing and evolving, 4-5
instrumenting, 44-45
linking correctly, 13-14
looking for resources, 13
modifying, 12
sharing components, 11
splitting into components, 11-12
ArrayList, 142
Arrays
incrementing elements, 234
Java definition of, 233
managing, 233-239
pinning, 236
read-only traversal, 236-237
storing, 233, 235
Assembling
applications, 11-14
components, 12
ATL (Active Template Library), 307
Attribute class, 102, 181
attribute_info structure, 99
Auctioneer interface, 244
AuctioneerImpl class, 245
Audit class, 84
Automating tasks, XVI

B

Base interface loaded implicitly, 34
Base class fields and serialization, 109
Binary boundaries between components, XVI
Binary classes, 58, 66, 252
data structures, 64-65
introspecting against, 57
metadata, 63-64
Binary compatibility, 58-62
Bind modes, 251, 253-255
Bind times, 244, 246-247, 251, 253-255
changing priorities, 249
separating specification from, 247-249
blowUpWorld method, 59
BMovie class, 58-61
Bootclasspath, 41-43
Bootstrap class loader, 36, 41-43, 48
Boss class, 141, 146

C

C++
calling Java from, 208-217
exception handling, 218-219
method declarations, 196
parameters with multiple levels of indirection, 196
Call stack logging, 46
Callee class, 189
Caller class, 189
Caller class loader, 21
CallVoidMethod method, 213, 219
CallVoidMethodA method, 221
Capability, 16
CauseConfusion methods, 199
CComBSTR class, 307
Chars API, 239
checkPermission method, 299
Child loader and classes, 49
Circular reference problems during resolution, 141-142
Class class, 21, 67-68, 70, 123
Class loader architecture, 5, 11
assembling applications, 14
capability, 16
configurability, 16
explicit class loading, 19
extensibility, 15-16
goals, 14-17
handling name and version conflicts, 16-17
security, 17
transparency, 15
Class loader delegation model, 5
Class loaders, 11, 14, 55, 281
applet, 25
caller's, 21
choosing, 174-175
configuration options, 36
consistency rule, 23-24
context, 5
crossing boundaries, 72
custom, 5, 153-190
delegation, 24-25, 27
effective use of, 14
exotic designs, 15-16
explicit use of, 29
getting past security to, 175-177
hierarchy, 52
holding cache of classes, 35-36
hot deployment, 29-34
installing all classes under, 52
instantiating, 53, 177
interaction with, 36
inversion, 49-55
JNI (Java Native Interface), 202-204
keeping in memory, 36
limited sharing of classes, 25
loading arbitrary resources, 22-23
meeting common needs, 16
memory, 35
multiple versions of native code, 203
overriding findLibrary method, 202
parent, 24
role, 157-159
rules, 23-29
security hole, 177
since SDK 1.2, 160-162
source-aware, 23
system, 25
transforming, 162-167
visibility rule, 25-26
Class loading, 55
capable, 16
debugging, 43-49
dynamic, 28-29, 251
easily configurable, 16
errors, 28
explicit, 18-23
implicit, 19-23, 24, 29
name conflicts, 16-17
reading attributes during, 183-188
supporting flexible binding modes, 251
version incompatibilities, 16-17
Class object, 18, 35
ClassCastException class, 144
Class-controlled object replacement, 137-139
Classes
already-loaded, 23-24
child loader, 49
compatibility, 66
compatible and incompatible changes, 117-118
configuring loading, 36-43
core, 25
customizing descriptors, 124
deploying multiple versions simultaneously, 17
diagnosing loading problems, 44
discovering fields, 68
dynamic proxies, 57
dynamically discovering characteristics, 66
dynamically loading, 19
extensible loading, 15-16
extensions path, 39-41
externalizable, 125-127
finding code, 147-150
garbage collecting, 36-37
in class loader hierachy, 50
incremental changes, 30
invisible, 60
loaded at different times, 27
loaded by bootstrap class loader, 41
loaded from classpath, 41
loaded from different locations, 27
loading, 37-39
loading resources for, 5
loading wrong version, 28
locating, 5, 38-39
matching streams with, 113-118
memory, 35
naming rule, 16-17
nonexistent, 60
overwriting metadata, 122-123
package names, 16
parent loader, 49
permissions, 155-157
postponing linking, 21
preventing creation of multiple instances, 28
public methods, 69
referencing nonexistent or invalid entry, 60
referencing other classes, 49
referring to another class, 19
relationship between old and new versions, 34
sealed JAR files, 178
security, 25, 41
separating serialized form from in-memory representation, 138
serializable, 106-109
serving old version, 17
tracing loading, 45
type information, 67
unintended references, 35
unloading, 35-36
verified, 41
version-reconciliation, 5
versions, 14
visibility, 23
ClassEx file, 102
ClassFormatError, 166
Class-level metadata, 94
Class-level object replacement, 137-140
Class-level resolution, 140
ClassLoader class, 17-18, 20-21, 95, 147, 153, 158-159, 175-176
checking another path, 202
convenience constructor, 25
modifications, 160-161
ClassLoader object, 35
ClassNotFoundError class, 43
ClassNotFoundException class, 18, 19, 113
ClassNotter class, 165-167
Class-oriented design, 3
Classpath class loader, 36, 37-39
-classpath command-line switch, 37-38
CLASSPATH environment variable, 37, 38
Client applications, 2
Client class, 61-62
Client code, 30
Clients, 33
installing dynamic proxies, 90-91
reference of base class or interface type, 34
reference of implementation type, 34
state of original object available to server factory, 34
Close method, 133, 232
close method, 302
Code
bind times, 244, 246-247
choosing specification language, 249
commonalities, 243-244
controlled sharing, 28
domain analysis, 243
ease of generating, 251
generation, 5-6
generation boosting performance, 252
generation language, 270-271
high in class loader hierarchy, 50
integrity endangered, 24
in-the-large generation, 252-253
Code (con't.)
in-the-small generation, 253
levels of commitment to generation, 252-253
loading, 36
reasons for generating, 243-250
reuse requiring multiple use, 249
RMI (Remote Method Invocation) generation, 255-257
separating specification from bind time, 247-249
sharing, 5
trusted, 175
Code attribute, 101
CodeBase attribute, 155
Collections
generic, 267
strongly-typed, 267-271
COM (Component Object Model), 285-286, 290-291
apartments, 297
context model, 297
error handling, 295-296
GUID (Globally Unique ID), 291
local loader, 291-292
object lifecycle, 293-294
platform impedance, 290
security, 298-299
stubs, 297
thread affinity, 296-298
type discovery, 294-295
type information, 292-293
com.develop package, 269
com.develop.benchmark package, 92
com.develop.hello package, 95
com.develop.jawin.tools package, 311
Com.develop.version.audit property, 188
COMException class, 295-296, 310
Commonalities, 243
Compilers and custom virtual machine attributes, 101
Compile-time binding, 247
Component approach, 3, 6-9
Component-oriented design, 3
Components, XV, 3
annotating, XVI
binary boundaries between, XVI
bloated, 5-6
class loaders, 281
concurrency protection mechanisms, 297
control over fitting together, 12-13
deployment, 12-13
EJB (Enterprise JavaBeans), 264-265
extending, 6
loading configuration information, 5
locating, 12
mobile, 105
multiple versions, 12
non-Java, XVI
platforms, 12
rogue, 12
sharing, 11
splitting applications into, 11-12
thread-affine, 296-297
type information, 281
unable to find, 12
COMSharedStubBuilder class, 311
COMSharedStubDriver class, 311, 314
Configurability, 16
Connect method, 170
Consistency rule, 23
breaking, 24
forbidding unloading and reloading from single loader, 31
implicit class loading, 29
Constant pool, 63-64
ConstantValue attribute, 101
Constructor class, 72-73, 77
Constructors
serialization, 110-111
throwing exception, 82
Contact interface, 1-2
Contact management domain, 6-9
Contact management systems, 1
ContactFinder interface, 1-2
Contacts, 2
Containers
code generation, 266-267
EJB (Enterprise JavaBeans), 264-265
Container-transaction element, 263
Context class loader, 5, 49-55
Context loader, 53
Context model, 297
contextLocalize method, 298
CORBA, 197
Core API
classes, 26, 46
instrumenting, 46-49
loading packages, 41
protecting integrity, 26
Core classes, 25
recompiling subset, 42
replacing, 42, 49
Core packages, loading, 36
-cp command-line switch, 37-38
createClassLoader method, 158
createPoint method, 31
Critical APIs, 237-238, 239
Critical array API, 239
Critical region, 238
Critical string API, 239
Cross-platform communication, 6
CrunchArray method, 292
current directory (.), 19
custom attributes, 5
Custom class loaders, 5, 153-190
adding configuration options, 16
pre-Java 2, 159
Custom metadata, 98-102
debugging support, 188-189
reading, 177-189
reading attributes during class loading, 183-188
serializable classes as attributes, 179-182
version attributes classes, 178-179
Custom serialization code, 271-276
Custom type formats, 300
Customizing class descriptors, 124

D

Data
alternate representations, XVI
structures and binary classes, 64-65
Data(N) classes, 149
DataInput interface, 124
DataOutput interface, 124, 130
DCOM, 197
Debugging
custom metadata support, 188-190
replacing core classes, 42
Debugging class loading
instrumenting Core API, 46-49
tracing class loading, 45
-verbose:class flag, 45
Default field data, 119
DefaultReadObject method, 119, 120
DefaultWriteObject method, 124-125, 128, 129
Defective PointImpl listing, 30defineClass method, 158-162, 165, 187, 216
definePackage method, 95
delegate method, 88-89
Delegation rule, 24-25
Delegation, 25
of class loaders, 24-25, 27
generic, 84-85
instead of implementation inheritance, 83
as namespaces, 27
object-oriented design, 5
delete method, 156
DeleteGlobalRef method, 225-226
DeleteLocalRef method, 226-227, 229
DemoLogging class, 85-86
Deployer, 13-14
Deployment
discouraging analysis of, 4
simplify, 23
Deployment descriptor, 263-265
Deployment-time binding, 247
deposit method, 262, 263
Deserialize-on-demand, 149-150
Deserializing objects, 113
Design-time binding, 247
Developer's machine, 4
Development environments, XVI
DiplomaticContact interface, 3
Directories and extensions path, 40
-Djava.security.manager flag, 156
DLLs (Dynamic Link Libraries)
error reporting, 302
loader architecture, 299-300
object lifecycle, 301-302
security, 303
thread affinity, 302
type discovery, 302
type information, 300-301
doGet method, 257-258
Domain analysis, 5, 243, 250
Dynamic applications, 12
Dynamic bind mode, 254
Dynamic bindings, 251
Dynamic class loading, 28-29, 251
Dynamic proxies, XVI, 57, 251, 254, 256-257, 565
advantages, 91
generating on-the-fly, 91
Dynamic proxies (con't.)
generic delegation, 84-85
implementing forwarding handler, 86-87
implementing InvocationHandler interface,
85-86
installed by client or server, 90-91
InvocationHandler interface as generic service, 87-89
method call forwarding, 87
reflective invocation, 83

E

Early binding, 252
Earth singleton, 138
Echo1 class, 65
Eiffel programming language, 16
EJB (Enterprise JavaBeans), XVII, 254
alternate implementations, 265-267
bean object, 261
containers, 264-265
deployment descriptor, 261, 263-265
entity beans, 260
generic classes, 265
home interface, 260, 261
remote interface, 260, 261
serialization, 105
session beans, 260
skeletons, 264
stubs, 264
Element array API, 235-236, 239
Enable methods, 134
Encapsulation, XV
EnsureLocalCapacity API, 230
EnsureLocalCapacity method, 228-229
Enterprise applications, 282
Entity beans, 260
Environment variables, 201-202
equals method, 86
Error 82, 205
Error handling
COM (Component Object Model), 295-296
JNI (Java Native Interface), 217-223
Errors and class loading, 28
Exception class, 295
ExceptionCheck method, 219-221
ExceptionClear method, 220, 223
ExceptionOccurred method, 219-221
Exceptions
declared and binary compatibility, 61-62
handling with InvocationHandler interface, 89
reflective invocation, 81-83
Exceptions attribute, 101
Explicit class loading, 18-23
Explicit loading APIs, 21
Explicitly
loading from URL, 18
managing serializable fields, 119-124
ExtClassLoader, 45
Extensibility, 15-16
Extensions, loading, 36
Extensions class loader, 36, 48
Extensions loader, 39-40, 45
Extensions path, 39-41
Externalizable class, 125-127
Externalizer class, 271, 273

F

Field class, 72-73, 77
Fields, 60
File URL, 18
FilePermission permission, 155, 157
final class, 61
final fields, 79-81
finalize method, 232, 293, 294, 301, 302
finally block, 232
FindBestMatch method, 229-230
FindClass method, 102, 160, 165, 183, 216, 219, 226
FindContact interface, 1
Finding class code, 147-150
findLibrary method, 202
FindResources method, 183
Flexible binding modes, 251
Foo class, 43
ForgetToLoadLibrary class, 205
FormatMessage function, 295, 302
forName method, 21, 216
Forwarding handler, implementing, 86-87
FuncPtr function, 310
Function pointers, 72

G

Garbage collector, 35
classes, 36-37
encouraging, 132-133
interacting with, 224-231
local references, 224
gc method, 204
Generating stubs, 311-316
GeneratorBase class, 271
Generators, 247-248, 249
Generic collections, 267
Generic delegation and dynamic proxies, 84-85
Generic interceptors, 83
Generic services, XVI, 87-89
Generic skeletons, 256
Generic stubs, 308
get method, 72
GetAnswer method, 194, 197
getBadDateValue method, 90
getClass method, 35
getClassLoader method, 19, 35, 41
GetContentType method, 170
GetDate method, 170
getDeclared method, 72
getDeclaredField method, 70-71, 210
getDeclaredFields method, 69
getDeclaredXXX accessor method, 68-70
GetErrorInfo function, 295
getExpiration method, 170
GetField class, 121, 275
getField method, 70-71, 123-124, 210
GetFieldID method, 210
getFields method, 69
getGoodDateValue method, 90
getInputStream method, 170
GetIntArrayElements method, 236, 237
GetIntArrayRegion method, 235
getInterfaces method, 67
GetLastError function, 302
getMethod method, 73, 75
GetMethodID method, 213
getModifiers method, 69-70
getOutputStream method, 170
getParent method, 24, 44
GetPrimitiveArrayCritical method, 238
GetProcAddress function, 299, 310
getProtectionDomain method, 162
GetRegion method, 240
getResource method, 22, 165
getResourceAsStream method, 22
getResources method, 22
getSuperclass method, 67
getSystemClassLoader method, 25
getTargetException method, 82
GetTokenInformation Win32 API, 300-301, 302
getURLBase method, 165
getVersionInfo method, 187
getXXX accessor method, 68-70
Global references, 224-225, 226
GP (generative programming), 243
binary classes, 252
bind modes, 253-255
bind times, 253-255
class loading supporting flexible binding modes, 251
code generation boosting performance, 252
code generation language, 270-271
custom serialization code, 271-276
domain analysis, 250
ease of generating Java source code, 251
EJB (Enterprise JavaBeans) code generation, 260-267
generating stubs, 311-316
inputs and outputs, 254-255
JSP (Java Server Pages) code generation, 257-260
levels of commitment to code generation, 252-253
marshalling architecture, 303-311
reasons for generating code, 243-250
strongly-typed collections, 267-271
target language, 270-271
type information as free specification document, 250-251
GUID (Globally Unique ID), 291

H

Handler class, 169, 174
hashCode method, 86
HashMap class, 24
Header files, 300
Hello.jsp servlet, 257, 258-259
Helper components, 253
Hot deployment, 29-34
HRESULT type, 295
Humanoid class, 106-107, 113

I

IDL (Interface Definitions Language), 292-293
IDL files, 300
IIDs, 294
IllegalAccessException class, 78, 81
IllegalArgumentException class, 81, 226
Implementation class, 34
Implicit class loading, 19-23, 24, 29
Implicit class references, 20
InadequateNationalInfrustructure class, 61
Incompatible changes, 62
IncompatibleClassChangeError class, 60
Infoset, 282
Inheritance, XV
delegation instead of, 83
extensible design with, 2
modeling variabilities, 245-246
multiple, 83
object-oriented design, 5
InnerClass attribute, 101
Installed optional packages
completely trusted by virtual machine, 40-41
loading, 39-41
security, 40-41
InstantiationException class, 81
Instruction strings, 309-311
Instrumenting
applications, 44-45
core API, 46-49
int return type, 197
Integer class, 75
Integer.class class, 75
Integer.TYPE class, 75
Interceptors, 83
Interface stubs, generating, 314-316
Interfaces, 72, 294
Internal name collisions, 17
Intrinsic functions, 307
Introspecting against binary classes, 57
Introspection, 57
InvalidClassException class, 116, 118, 123
Invariants, 16
Inversion
avoiding problems, 50
context class loader, 49-55
InvocationHandler interface, 87, 254
as generic service, 87-89
handling exceptions, 89
implementing, 85-86
InvocationHandler.invoke method, 87
InvocationTargetException class, 82, 89
invoke method, 86, 87, 265
isCompatibleWith API, 96
ItemImpl class, 246
itf1 variable, 295
itf5 variable, 295
itfs array, 85
ITypeInfo interface, 292
ITypeLib interface, 292
IUknown interface, 293

J

J2EE implementation, 53
-jar command-line switch, 38
JAR files
adding version information, 95-96
extensions loader, 40
sealing packages, 97
Java
accessing code libraries not written in, 192
accessing platform-specific resources, 192
calling from C++, 208-217
code and dotted notation, 63-64
converting to XML, XVI
direct access to system memory, 191-192
hand-tuned, peak performance code, 192
IDE wizards, 72
loaders, XV-XVI
memory protections, 193
multiple inheritance, 196
passing parameters by value, 196
reasons for generating code, 250-253
serialization, 5
tasks ill-suited for, 191-192
type information, XVI
WORA (write-once, run-anywhere), 191
Java 2 SDK, XIX, 118
Java launcher, 230
Java Reflection API, 57, 66-72, 101-102
Java Virtual Machine Specification, 103
JavaBeans, XVII, 66-67, 105
javah utility, 199, 206-207
java.io.DataOutputStream stream, 114
Java.io.Externalizable class, 125
java.io.File.pathSeparatorChar constant, 38
java.io.NotSerializableException class, 108
java.io.ObjectOutputStream wrapper stream, 108
java.io.Serializable interface, 106
java.lang package, 75
java.lang.Class class, 67, 102
java.lang.ClassLoader class, 207-208, 216
java.lang.IllegalArgumentException class, 226
java.lang.Package class, 94
java.lang.reflect package, 67
java.lang.reflect.Constructor class, 216
java.lang.reflect.Field class, 68
java.lang.reflect.Method class, 71
java.lang.reflect.Modifiers class, 70
java.lang.String class, 64
java.library.path system property, 201-202
java.net.URL class, 168
java.net.URLConnection class, 169
java.net.URLStreamHandler class, 169
javap utility, 65
java.policy file, 41
java.protocol.handler.pkgs property, 173
java.rmi.MarshalledObject class, 150
java.rmi.RemoteException class, 289
java.security.AccessControlContext class, 158
java.security.CodeSource class, 155
java.security.Permission class, 155
java.security.Policy class, 155
java.security.ProtectionDomain class, 158
java.security.SecureClassLoader class, 161-162
java.util package, 267
java.util.Date class, 87-88
java.util.Stack class, 269
JavaVM pointer, 218
Jawin, 285
COM threading rules, 298
instruction strings, 310-311
translucent stubs, 286-289
Win32 stubs, 301
JCFE (Java Class File Editor), 102, 181
JconstructorID type, 216
JCP (Java Community Process), 282
JINI, XVII, 105
jint return type, 197
JNDI (Java Naming and Directory Interface), 262
JNI (Java Native Interface), 6, 79, 191, 285-286
APIs for field access, 210
APIs for method access, 213
array region APIs, 234
calling C-style API, 212
calling Java from C++, 208-217
class loader and construction functions, 216
class loaders, 202-204
cross-platform standard, 193
error handling, 217-223
finding and loading native code, 194-208
handling C++ exceptions, 218-219
handling Java exceptions from native code, 219-222
improving performance by precalculating jfieldIDs, 211-212
jobject references, 224
layer of indirection, 195
loading native libraries, 199-202
minimalist mapping from Java types to C++ types, 197
minimizing round trips, 211-213
name mappings, 195
name-mangling scheme, 198
overloaded names, 198-199
passing arrays, 233
performance comparisions, 214
reflection, 215
reflective invocation and, 214-217
resource management, 223-240
stubs, 287
throwing Java exceptions from native code, 222-223
troubleshooting native loading, 207-208
type mappings, 195-197
virtual machine, 192
JNI_ABORT flag, 236-237
JNI_COMMIT flag, 236-237
JNICALL macro, 197
JNIEnv type, 197, 208, 218, 222-223
JNIEnvUtil class, 221, 222
JNIEXPORT macro, 197
JNI_OnLoad method, 212, 220-221, 222, 226
JNI_OnUnload method, 226
JNI_VERSION_1_2 method, 212
jobject references, 224
jobject type, 197, 208, 210
JSP (Java Server Pages), XVII, 251, 253, 254
code generation, 257-260
generator language for Java, 270-271
strongly-typed stack classes, 268-269
_jspService method, 258

L

Late binding, 252
Launcher and command line processing, 39
LaunchVehicle interface, 98-99
LD_LIBRARY_PATH environment variable, 201
LICENSE file, 49
LineNumberTable attribute, 101
Linking
application correctly, 13-14
methods at runtime, 59
native libraries, 199-202
with full paths, 200
ListBaseTypes class, 67
ListByLastName console client, 2
ListMostFields class, 69-70
LittleEndianOutputStream, 310
load method, 200-202
loadClass method, 21, 47, 159-161
LoaderDemo class, 19, 27-28
Loading native libraries, 199-202
LoadLibrary Win32 function, 310
loadLibrary method, 200-202, 205-206, 299
LoadMe class, 19, 20, 27-28
LoadMeAlso class, 20
LoadMeBase class, 20
LoadMeThree class, 20
LoadMeToo class, 20
LoadNonExistentLibrary class, 205
LoadTheWrongLibrary class, 206
Local references, 224, 226, 227
LocalVariableTable attribute, 101
Locating components, 12
logConstructor method, 46
Logging call stacks, 46
LoggingHandler class, 85-86

M

-m switch, 95
MadScientist class, 58-61
Main class, 49
Mars singleton, 138
MarshalledObject class, 150
Marshalling architecture, 6, 286-287
generic stubs, 308
instruction strings, 309-311
shared stubs, 303-307
Message object, 149
MessageBoxW function, 300, 309-311
Metadata, 57, 66
abandoning, 124-130
accessing from packages, 96
binary classes, 63-64
binary compatibility, 58-62
class-level, 94
correct units for numeric arguments, 98
custom, 98-102
externalizable classes, 125-127
overwriting, 122-123
reading custom, 177-189
serialization, 105-106
setting for packages, 95-96
skipping, 127
supplementing, 197
tables of allowable state transitions, 98
version information, 94
Method class, 71, 72-73, 77, 256, 257
Methods
call forwarding, 87
converting to network messages, XVI
invalid arguments, 81
invisible, 60
linking at runtime, 59
nonexistent, 60
overloaded, 198
reflection, 71-72
small-grained, 211
throwing exception, 82
virtual and non-virtual invocation, 215
midl compiler, 292
Mobile components, 105
Modifying applications, 12
Money class, 263
Moving corrected PointImpl, 33
MTA (multi-threaded apartment), 297
Multiple inheritance, 83, 196

N

Name conflicts, 16-17
Name mappings, 195
Namespaces, delegations as, 27-28
Naming rule, 16-17
Native code
bypassing language protection modifiers, 193
calling Java constructor, 216
dangers of, 193-194
failures, 217-218
finding and loading, 194-208
global references, 224-225
handling Java exceptions, 219-222
loading, 204
reflective access, 209
throwing Java exceptions, 222-223
type-safety, 193
native keyword, 194
Native libraries
common errors loading, 205-207
loading, 199-202
loading old version, 204
troubleshooting loading, 207
visible across all class loaders, 203
Native methods
instantiating Person class, 79
loading, 200
populating fields, 81
shared stubs implementation, 305-306

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020