Skip to content

Commit 752a438

Browse files
committed
8314684: Add overview docs to loaderConstraints.cpp
Reviewed-by: ccheung, dholmes
1 parent acd9310 commit 752a438

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/hotspot/share/classfile/loaderConstraints.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,50 @@
3838
#include "runtime/safepoint.hpp"
3939
#include "utilities/resourceHash.hpp"
4040

41-
// Implementation Classes for Loader Constraints
41+
// Overview
42+
//
43+
// The LoaderConstraintTable controls whether two ClassLoaders can resolve the same class name N
44+
// to different InstanceKlasses.
45+
//
46+
// The design of the algorithm can be found in the OOPSLA'98 paper "Dynamic Class Loading in
47+
// the Java Virtual Machine" by Sheng Liang and Gilad Bracha.
48+
//
49+
// To understand the implementation, start with LoaderConstraintTable::{add_entry, check_or_update}
50+
//
51+
// When a class name N is entered into the LoaderConstraintTable, it's mapped to a ConstraintSet which
52+
// contains one or more LoaderConstraints:
53+
//
54+
// LoaderConstraint_a = { _klass_a, loader_a1, loader_a2, ...}
55+
// LoaderConstraint_b = { _klass_b, loader_b1, loader_b2, ...}
56+
// LoaderConstraint_c = { _klass_c, loader_c1, loader_c2, ...}
57+
// ...
58+
//
59+
// If _klass_<m> is null, when the first loader_<m><n> resolves the name N to a class K,
60+
// we assign _klass_<m> = K.
61+
//
62+
// if _klass_<m> is non-null, when a loader loader_<m><n> tries to resolve the name N to a class K,
63+
// where _klass_<m> != K, a LinkageError is thrown, and the resolution fails.
64+
//
65+
// Management of LoaderConstraints
66+
//
67+
// When the SystemDictionary decides that loader_x and loader_y must resolve the name N to the same class:
68+
// For the name N, find two LoaderConstraints such that:
69+
//
70+
// - LoaderConstraint_x contains loader_x
71+
// - LoaderConstraint_y contains loader_y
72+
//
73+
// (Note that no class loader will appear in more than one LoaderConstraint for
74+
// each name N, as enforced by the following steps).
75+
//
76+
// If neither LoaderConstraint_x nor LoaderConstraint_y exist, add a new LoaderConstraint that contains
77+
// both loader_x and loader_y.
78+
//
79+
// Otherwise if LoaderConstraint_x exists but LoaderConstraint_y doesn't exist, add loader_y to LoaderConstraint_x,
80+
// or vice versa.
81+
//
82+
// Otherwise if both LoaderConstraints have different values for _klass, a LinkageError is thrown.
83+
//
84+
// Otherwise the two LoaderConstraints are merged into one.
4285

4386
class LoaderConstraint : public CHeapObj<mtClass> {
4487
InstanceKlass* _klass;

0 commit comments

Comments
 (0)