-
Notifications
You must be signed in to change notification settings - Fork 747
/
Copy pathClasspathManagerImpl2.cpp
1443 lines (1266 loc) · 56.5 KB
/
ClasspathManagerImpl2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright IBM Corp. and others 2001
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
/**
* @file
* @ingroup Shared_Common
*/
#include "ClasspathManagerImpl2.hpp"
#include "CacheMap.hpp"
#include "j9shrnls.h"
#include "ut_j9shr.h"
#include "vmzipcachehook.h"
#include <string.h>
#define CPLLI_LAST_ITEM_TAG 0x10000
#define IDENTIFIED_START_SIZE 20
#define ID_NOT_SET 0x10000
#define ID_NOT_FOUND 0x20000
#define JAR_LOCKED 2
#define CPM_ZIP_OPEN 1 /* Indicates zip/jar is currently open */
#define CPM_ZIP_FORCE_CHECK_TIMESTAMP 2 /* When a jar/zip is first opened, we should force a check of its timestamp */
#define CPM_ZIP_ONLY_TIMESTAMP_ON_INIT 4 /* Indicates that the timestamp of this container should only be checked once during initialization to support OSGi requirements */
#define CPM_ZIP_CHECKED_INIT_TIMESTAMP 8 /* Indicates that the initialization timestamp has been done */
SH_ClasspathManagerImpl2::SH_ClasspathManagerImpl2()
: _tsm(0),
_identifiedMutex(0),
_linkedListImplPool(0),
_identifiedClasspaths(0),
_classpathCount(0),
_urlCount(0),
_tokenCount(0),
_allCacheletsStarted(false)
{
_htMutexName = "cpeTableMutex";
}
SH_ClasspathManagerImpl2::~SH_ClasspathManagerImpl2()
{
}
/**
* Create a new CpLinkedListImpl
*
* @param[in] CPEIndex_ The index of the classpath entry that this link represents
* @param[in] item ShcItem in cache (will be a ClasspathWrapper)
* @param[in] memForConstructor Memory to build instance into
*
* @return new CpLinkedListImpl
*/
SH_ClasspathManagerImpl2::CpLinkedListImpl*
SH_ClasspathManagerImpl2::CpLinkedListImpl::newInstance(I_16 CPEIndex_, const ShcItem* item_, SH_CompositeCache* cachelet_, CpLinkedListImpl* memForConstructor)
{
CpLinkedListImpl* newCLLI = (CpLinkedListImpl*)memForConstructor;
Trc_SHR_CMI_CpLinkedListImpl_newInstance_Entry(CPEIndex_, item_);
new(newCLLI) CpLinkedListImpl();
newCLLI->initialize(CPEIndex_, item_, cachelet_);
Trc_SHR_CMI_CpLinkedListImpl_newInstance_Exit(newCLLI);
return newCLLI;
}
/* Initialize a new CpLinkedListImpl */
void
SH_ClasspathManagerImpl2::CpLinkedListImpl::initialize(I_16 CPEIndex_, const ShcItem* item_, SH_CompositeCache* cachelet_)
{
Trc_SHR_CMI_CpLinkedListImpl_initialize_Entry();
_CPEIndex = CPEIndex_;
_item = item_;
/* Create the required circular link during initialization so
* it will be there when the entry is added to the hashtable under
* synchronization.
*/
_next = this;
Trc_SHR_CMI_CpLinkedListImpl_initialize_Exit();
}
/**
* Static function that creates a new link and links it to the list given. Overloads the function in SH_Manager.
*
* @param[in] addToList The list to link the new entry to
* @param[in] CPEIndex The index of the classpath entry that this link represents
* @param[in] item The cache item that this link represents
* @param[in] doTag Tag the link
* @param[in] allocationPool The pool used for allocating new links
*
* @return A new CpLinkedListImpl or NULL if this fails
*/
SH_ClasspathManagerImpl2::CpLinkedListImpl*
SH_ClasspathManagerImpl2::CpLinkedListImpl::link(CpLinkedListImpl* addToList, I_16 CPEIndex, const ShcItem* item, bool doTag, SH_CompositeCache* cachelet, J9Pool* allocationPool)
{
CpLinkedListImpl *newLink, *memPtr, *result;
Trc_SHR_CMI_CpLinkedListImpl_link_Entry(addToList, CPEIndex, item, doTag);
Trc_SHR_CMI_CpLinkedListImpl_link_PoolNew(allocationPool);
if (!(memPtr = (CpLinkedListImpl*)pool_newElement(allocationPool))) {
Trc_SHR_CMI_CpLinkedListImpl_link_Exit1();
return NULL;
}
newLink = CpLinkedListImpl::newInstance(CPEIndex, item, cachelet, memPtr);
if (doTag) {
tag(newLink);
}
result = (CpLinkedListImpl*)SH_Manager::LinkedListImpl::link(addToList, newLink);
Trc_SHR_CMI_CpLinkedListImpl_link_Exit2(result);
return result;
}
/**
* Searches for a CpLinkedListImpl in the list which belongs to a classpath which is an exact match for the classpath given at the index given
*
* Should only ever return one possible entry from the list. Will not return any classpaths which are part-stale.
*
* @param[in] currentThread The current thread
* @param[in] item The classpath that the link should belong to
* @param[in] index The index in the classpath that the link should be stored at
*
* @return A CpLinkedListImpl that is at the correct index in a matching classpath or NULL if one is not found
*/
SH_ClasspathManagerImpl2::CpLinkedListImpl*
SH_ClasspathManagerImpl2::CpLinkedListImpl::forCacheItem(J9VMThread* currentThread, ClasspathItem* item, UDATA index)
{
CpLinkedListImpl* walk = this;
Trc_SHR_CMI_CpLinkedListImpl_forCacheItem_Entry(currentThread, index, item);
do {
UDATA testIndex = getCPEIndex(walk);
ClasspathWrapper* testItem = (ClasspathWrapper*)ITEMDATA(walk->_item);
Trc_SHR_CMI_CpLinkedListImpl_forCacheItem_DoTest(currentThread, walk, testIndex, testItem->staleFromIndex);
if ((testIndex==index) &&
(testItem->staleFromIndex == CPW_NOT_STALE) &&
(ClasspathItem::compare(currentThread->javaVM->internalVMFunctions, ((ClasspathItem*)CPWDATA(testItem)), item))) { /* Note: Compares whole classpath */
Trc_SHR_CMI_CpLinkedListImpl_forCacheItem_Exit1(currentThread, walk);
return walk;
}
walk = (CpLinkedListImpl*)walk->_next;
} while (walk!=this);
Trc_SHR_CMI_CpLinkedListImpl_forCacheItem_Exit2(currentThread);
return NULL;
}
/**
* Static function which tags a link. Used to indicate that a link is the last entry in a classpath.
*
* @param[in] item The item to tag
*/
void
SH_ClasspathManagerImpl2::CpLinkedListImpl::tag(CpLinkedListImpl* item)
{
Trc_SHR_CMI_CpLinkedListImpl_tag(item);
item->_CPEIndex |= CPLLI_LAST_ITEM_TAG;
}
/**
* Static function which returns the CPEIndex field of a link
*
* @note The CPEIndex of a link should never be accessed directly as it needs to be marked to remove the tag
* @param[in] item The item to get the CPEIndex for
*
* @return The CPEIndex value of the link
*/
I_16
SH_ClasspathManagerImpl2::CpLinkedListImpl::getCPEIndex(CpLinkedListImpl* item)
{
I_16 result = (item->_CPEIndex & ~CPLLI_LAST_ITEM_TAG);
Trc_SHR_CMI_CpLinkedListImpl_getCPEIndex(result, item);
return result;
}
SH_ClasspathManagerImpl2::CpLinkedListHdr::CpLinkedListHdr(const char* key_, U_16 keySize_, U_8 isToken_, CpLinkedListImpl* listItem)
: _isToken(isToken_),
_flags(0),
_keySize(keySize_),
_key(key_),
_list(listItem)
{
}
SH_ClasspathManagerImpl2::CpLinkedListHdr::~CpLinkedListHdr()
{
}
/**
* Create a new SH_ClasspathManagerImpl2
*
* @param[in] vm A Java VM
* @param[in] cache_ The shared cache that this SH_ClasspathManager will manage
* @param[in] tsm_ The timestamp manager used by the cache
* @param[in] memForConstructor Memory to build instance into
*
* @return new SH_ClasspathManagerImpl2
*/
SH_ClasspathManagerImpl2*
SH_ClasspathManagerImpl2::newInstance(J9JavaVM* vm, SH_SharedCache* cache_, SH_TimestampManager* tsm_, SH_ClasspathManagerImpl2* memForConstructor)
{
SH_ClasspathManagerImpl2* newCMI = (SH_ClasspathManagerImpl2*)memForConstructor;
Trc_SHR_CMI_newInstance_Entry(vm, cache_, tsm_);
new(newCMI) SH_ClasspathManagerImpl2();
newCMI->initialize(vm, cache_, tsm_, ((BlockPtr)memForConstructor + sizeof(SH_ClasspathManagerImpl2)));
Trc_SHR_CMI_newInstance_Exit(newCMI);
return newCMI;
}
/* Initialize the SH_ClasspathManagerImpl2 */
void
SH_ClasspathManagerImpl2::initialize(J9JavaVM* vm, SH_SharedCache* cache_, SH_TimestampManager* tsm_, BlockPtr memForConstructor)
{
Trc_SHR_CMI_initialize_Entry();
_cache = cache_;
_tsm = tsm_;
_portlib = vm->portLibrary;
_htMutex = NULL;
_identifiedMutex = NULL;
_dataTypesRepresented[0] = TYPE_CLASSPATH;
_dataTypesRepresented[1] = _dataTypesRepresented[2] = 0;
notifyManagerInitialized(_cache->managers(), "TYPE_CLASSPATH");
Trc_SHR_CMI_initialize_Exit();
}
U_32
SH_ClasspathManagerImpl2::getHashTableEntriesFromCacheSize(UDATA cacheSizeBytes)
{
return (U_32)((cacheSizeBytes / 50000) + 20);
}
/* Should be called only after _htEntries, _runtimeFlagsPtr and _portlib have been initialized */
IDATA
SH_ClasspathManagerImpl2::localInitializePools(J9VMThread* currentThread)
{
IDATA returnVal = 0;
PORT_ACCESS_FROM_PORT(_portlib);
Trc_SHR_CMI_localInitializePools_Entry(currentThread);
_linkedListImplPool = pool_new(sizeof(SH_ClasspathManagerImpl2::CpLinkedListImpl), 0, 0, 0, J9_GET_CALLSITE(), J9MEM_CATEGORY_CLASSES, POOL_FOR_PORT(_portlib));
if (!_linkedListImplPool) {
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_CREATE_LINKEDLISTIMPL);
returnVal = -1;
goto _exit;
}
if (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING) {
_identifiedClasspaths = initializeIdentifiedClasspathArray(_portlib, IDENTIFIED_START_SIZE, NULL, 0, 0);
if (!_identifiedClasspaths) {
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_CREATE_IDCPARRAY);
returnVal = -1;
goto _exit;
}
}
_exit:
Trc_SHR_CMI_localInitializePools_Exit(currentThread, returnVal);
return returnVal;
}
/* Destroy the hashtable and linked list entries */
void
SH_ClasspathManagerImpl2::localTearDownPools(J9VMThread* currentThread)
{
Trc_SHR_CMI_localTearDownPools_Entry(currentThread);
if (_linkedListImplPool) {
pool_kill(_linkedListImplPool);
_linkedListImplPool = NULL;
}
if (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING) {
if (_identifiedClasspaths) {
freeIdentifiedClasspathArray(_portlib, _identifiedClasspaths);
_identifiedClasspaths = NULL;
}
}
Trc_SHR_CMI_localTearDownPools_Exit(currentThread);
}
/**
* Start the initialized SH_ClasspathManager
*
* @see Manager.hpp
* @note should be called only after initialize
* @param[in] currentThread The current thread
*
* @return 0 for success, -1 for failure
*/
IDATA
SH_ClasspathManagerImpl2::localPostStartup(J9VMThread* currentThread)
{
Trc_SHR_CMI_localPostStartup_Entry(currentThread);
if (omrthread_monitor_init(&_identifiedMutex, 0)) {
PORT_ACCESS_FROM_PORT(_portlib);
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_CREATE_IDMUTEX);
Trc_SHR_CMI_localPostStartup_Exit1(currentThread);
return -1;
}
Trc_SHR_CMI_localPostStartup_Exit2(currentThread);
return 0;
}
void
SH_ClasspathManagerImpl2::localPostCleanup(J9VMThread* currentThread)
{
Trc_SHR_CMI_localPostCleanup_Entry(currentThread);
if (_identifiedMutex) {
omrthread_monitor_destroy(_identifiedMutex);
_identifiedMutex = NULL;
}
Trc_SHR_CMI_localPostCleanup_Exit(currentThread);
}
/**
* Returns the number of bytes required to construct this SH_ROMClassManager
*
* @return size in bytes
*/
UDATA
SH_ClasspathManagerImpl2::getRequiredConstrBytes(void)
{
UDATA reqBytes = 0;
reqBytes += sizeof(SH_ClasspathManagerImpl2);
return reqBytes;
}
/* Make decisions about which entries to actually timestamp
* Returns 1 if item is stampable and time has changed, 0 if it has not changed, JAR_LOCKED if it was not checked and -1 for error
*/
IDATA
SH_ClasspathManagerImpl2::hasTimestampChanged(J9VMThread* currentThread, ClasspathEntryItem* itemToCheck, CpLinkedListHdr* knownLLH, bool doTryLockJar)
{
if (getState() != MANAGER_STATE_STARTED) {
return 0;
}
Trc_SHR_CMI_hasTimestampChanged_Entry(currentThread, itemToCheck, doTryLockJar);
/* Only check JARs/Jimage as we check specific classfile timestamps in directories */
if ((PROTO_JAR == itemToCheck->protocol)
|| (PROTO_JIMAGE == itemToCheck->protocol)
) {
U_16 pathLen = 0;
const char* itemPath = NULL;
I_64 newTS;
CpLinkedListHdr* header;
if (knownLLH) {
header = knownLLH; /* Optimization: Don't need to get mutex and do lookup if header is provided */
} else {
itemPath = itemToCheck->getLocation(&pathLen);
header = cpeTableLookup(currentThread, itemPath, pathLen, 0); /* 0 = isToken. Certainly won't be a token. */
if (header == NULL) {
/* CMVC 131285: This is not expected to happen, but has been seen with concurrent writing
* when called by localValidate_checkAndTimestampManually at the point at which the cache becomes full */
Trc_SHR_CMI_hasTimestampChanged_ExitError(currentThread);
return -1;
}
}
if ((header->_flags == CPM_ZIP_OPEN) || /* Implies !CPM_ZIP_ONLY_TIMESTAMP_ON_INIT and !CPM_ZIP_FORCE_CHECK_TIMESTAMP */
(header->_flags & CPM_ZIP_CHECKED_INIT_TIMESTAMP)) {
Trc_SHR_CMI_hasTimestampChanged_ExitLocked(currentThread, header);
return JAR_LOCKED;
}
newTS = _tsm->checkCPEITimeStamp(currentThread, itemToCheck);
/* If only timestamping the container once, mark it so that it won't be checked again */
if (header->_flags & CPM_ZIP_ONLY_TIMESTAMP_ON_INIT) {
header->_flags &= ~CPM_ZIP_ONLY_TIMESTAMP_ON_INIT;
header->_flags |= CPM_ZIP_CHECKED_INIT_TIMESTAMP;
/* If the container has just been opened, force a single check each time, unless CPM_ZIP_ONLY_TIMESTAMP_ON_INIT */
} else if (header->_flags & CPM_ZIP_FORCE_CHECK_TIMESTAMP) {
header->_flags &= ~CPM_ZIP_FORCE_CHECK_TIMESTAMP;
}
if ((newTS == TIMESTAMP_DOES_NOT_EXIST) || (newTS == TIMESTAMP_DISAPPEARED)) {
UDATA result = (newTS == TIMESTAMP_DISAPPEARED); /* If resource was there and has gone, timestamp has changed */
Trc_SHR_CMI_hasTimestampChanged_ExitDoesNotExist(currentThread, result);
return result;
} else {
UDATA result = (newTS != TIMESTAMP_UNCHANGED);
Trc_SHR_CMI_hasTimestampChanged_Exit(currentThread, newTS, result);
return result;
}
} else {
Trc_SHR_CMI_hasTimestampChanged_NotJar(currentThread);
}
Trc_SHR_CMI_hasTimestampChanged_ExitFalse(currentThread);
return 0;
}
/* Creates a new hashtable. Pre-req: portLibrary must be initialized */
J9HashTable*
SH_ClasspathManagerImpl2::localHashTableCreate(J9VMThread* currentThread, U_32 initialEntries)
{
J9HashTable* returnVal;
Trc_SHR_CMI_localHashTableCreate_Entry(currentThread, initialEntries);
returnVal = hashTableNew(OMRPORT_FROM_J9PORT(_portlib), J9_GET_CALLSITE(), initialEntries, sizeof(SH_ClasspathManagerImpl2::CpLinkedListHdr), sizeof(char *), 0, J9MEM_CATEGORY_CLASSES, SH_ClasspathManagerImpl2::cpeHashFn, SH_ClasspathManagerImpl2::cpeHashEqualFn, NULL, (void*)currentThread->javaVM->internalVMFunctions);
Trc_SHR_CMI_localHashTableCreate_Exit(currentThread, returnVal);
return returnVal;
}
/* Hash function for hashtable */
UDATA
SH_ClasspathManagerImpl2::cpeHashFn(void* item, void *userData)
{
CpLinkedListHdr* itemValue = (CpLinkedListHdr*)item;
J9InternalVMFunctions* internalFunctionTable = (J9InternalVMFunctions*)userData;
UDATA hashValue;
Trc_SHR_CMI_cpeHashFn_Entry(item);
hashValue = (internalFunctionTable->computeHashForUTF8((U_8*)itemValue->_key, itemValue->_keySize) + itemValue->_isToken);
Trc_SHR_CMI_cpeHashFn_Exit(hashValue);
return hashValue;
}
/**
* HashEqual function for hashtable
*
* @param[in] left a match candidate from the hashtable
* @param[in] right search key
*
* @retval 0 not equal
* @retval non-zero equal
*/
UDATA
SH_ClasspathManagerImpl2::cpeHashEqualFn(void* left, void* right, void *userData)
{
CpLinkedListHdr* leftItem = (CpLinkedListHdr*)left;
CpLinkedListHdr* rightItem = (CpLinkedListHdr*)right;
UDATA result;
Trc_SHR_CMI_cpeHashEqualFn_Entry(leftItem, rightItem);
/* PERFORMANCE: Hot function. This is likely to mostly be the first point of failure. */
if (leftItem->_keySize != rightItem->_keySize) {
Trc_SHR_CMI_cpeHashEqualFn_Exit2();
return 0;
}
if (leftItem->_key==NULL || rightItem->_key==NULL) {
Trc_SHR_CMI_cpeHashEqualFn_Exit1();
return 0;
}
if (leftItem->_isToken != rightItem->_isToken) {
Trc_SHR_CMI_cpeHashEqualFn_Exit3();
return 0;
}
result = J9UTF8_DATA_EQUALS((U_8*)leftItem->_key, leftItem->_keySize, (U_8*)rightItem->_key, rightItem->_keySize);
Trc_SHR_CMI_cpeHashEqualFn_Exit4(result);
return result;
}
SH_ClasspathManagerImpl2::CpLinkedListHdr*
SH_ClasspathManagerImpl2::cpeTableAddHeader(J9VMThread* currentThread, const char* name, U_16 nameLen, CpLinkedListImpl* newItem, U_8 isToken)
{
CpLinkedListHdr* rc = NULL;
IDATA retryCount = 0;
CpLinkedListHdr header(name, nameLen, isToken, newItem);
while (retryCount < MONITOR_ENTER_RETRY_TIMES) {
if (_cache->enterLocalMutex(currentThread, _htMutex, "cpeTableMutex", "cpeTableAddHeader")==0) {
Trc_SHR_CMI_cpeTableAdd_HashtableAdd(currentThread);
rc = (CpLinkedListHdr*)hashTableAdd(_hashTable, &header);
if (rc == NULL) {
PORT_ACCESS_FROM_PORT(_portlib);
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_CREATE_HASHTABLE_ENTRY);
}
_cache->exitLocalMutex(currentThread, _htMutex, "cpeTableMutex", "cpeTableAddHeader");
if (rc == NULL) {
return NULL;
}
break;
}
retryCount++;
}
return rc;
}
/* Creates a new header and a new linked list entry, which is added to the header. The new header is then added to the hashtable.
* CPEIndex and doTag are parameters stored by the link and name and isToken are parameters used by the header.
* Returns a pointer to the new link, or NULL if there was an error */
SH_ClasspathManagerImpl2::CpLinkedListImpl*
SH_ClasspathManagerImpl2::cpeTableAdd(J9VMThread* currentThread, const char* name, U_16 nameLen, I_16 CPEIndex, const ShcItem* item, U_8 isToken, bool doTag, SH_CompositeCache* cachelet)
{
CpLinkedListImpl* newItem = NULL;
Trc_SHR_CMI_cpeTableAdd_Entry(currentThread, nameLen, name, CPEIndex, item, isToken, doTag);
/* Note that it is legitimate for item to be NULL if we're being notified about a container opening which we have no cache data for yet */
if (item != NULL) {
if (!(newItem = CpLinkedListImpl::link(NULL, CPEIndex, item, doTag, cachelet, _linkedListImplPool))) {
PORT_ACCESS_FROM_PORT(_portlib);
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_CREATE_LINKEDLISTITEM);
Trc_SHR_CMI_cpeTableAdd_Exit1(currentThread);
return NULL;
}
}
if (cpeTableAddHeader(currentThread, name, nameLen, newItem, isToken) == NULL) {
Trc_SHR_CMI_cpeTableAdd_Exit3(currentThread);
return NULL;
}
Trc_SHR_CMI_cpeTableAdd_Exit5(currentThread, newItem);
return newItem;
}
/* Finds a header entry in the hashtable, based on the data given. Will return NULL if the header is not found or if there is an error. */
SH_ClasspathManagerImpl2::CpLinkedListHdr*
SH_ClasspathManagerImpl2::cpeTableLookup(J9VMThread* currentThread, const char* key, U_16 keySize, U_8 isToken)
{
CpLinkedListHdr dummy(key, keySize, isToken, NULL);
CpLinkedListHdr* returnVal = NULL;
Trc_SHR_CMI_cpeTableLookup_Entry(currentThread, keySize, key, isToken);
if (lockHashTable(currentThread, "cpeTableLookup")) {
returnVal = cpeTableLookupHelper(currentThread, &dummy);
unlockHashTable(currentThread, "cpeTableLookup");
} else {
PORT_ACCESS_FROM_PORT(_portlib);
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_ENTER_CPEMUTEX);
Trc_SHR_CMI_cpeTableLookup_Exit1(currentThread, MONITOR_ENTER_RETRY_TIMES);
return NULL;
}
Trc_SHR_CMI_cpeTableLookup_Exit2(currentThread, returnVal);
return returnVal;
}
/* Finds a header entry in the hashtable, based on the data given. Will return NULL if the header is not found or if there is an error. */
SH_ClasspathManagerImpl2::CpLinkedListHdr*
SH_ClasspathManagerImpl2::cpeTableLookupHelper(J9VMThread* currentThread, const char* key, U_16 keySize, U_8 isToken)
{
CpLinkedListHdr dummy(key, keySize, isToken, NULL);
CpLinkedListHdr* returnVal = NULL;
returnVal = cpeTableLookupHelper(currentThread, &dummy);
return returnVal;
}
SH_ClasspathManagerImpl2::CpLinkedListHdr*
SH_ClasspathManagerImpl2::cpeTableLookupHelper(J9VMThread* currentThread, CpLinkedListHdr* searchItem)
{
CpLinkedListHdr* returnVal = NULL;
returnVal = (CpLinkedListHdr*)hashTableFind(_hashTable, (void*)searchItem);
Trc_SHR_CMI_cpeTableLookup_HashtableFind(currentThread, returnVal);
return returnVal;
}
/* Updates the hashtable with new data. Creates a new link and will also create a new header if required.
* ASSUMPTION: There cannot be 2 URLs with the same name, but different protocols. This would not make sense.
* However, there can be a token and a URL with the same name. These are treated as entirely different entries.
* Returns the new link created, or NULL if there is an error. */
SH_ClasspathManagerImpl2::CpLinkedListImpl*
SH_ClasspathManagerImpl2::cpeTableUpdate(J9VMThread* currentThread, const char* name, U_16 nameLen,
I_16 CPEIndex, const ShcItem* item, U_8 isToken, bool doTag,
SH_CompositeCache* cachelet)
{
CpLinkedListHdr* addToList = NULL;
CpLinkedListImpl* returnVal = NULL;
Trc_SHR_CMI_cpeTableUpdate_Entry(currentThread, nameLen, name, CPEIndex, item, isToken);
addToList = cpeTableLookupHelper(currentThread, name, nameLen, isToken);
if (addToList==NULL) {
returnVal = cpeTableAdd(currentThread, name, nameLen, CPEIndex, item, isToken, doTag, cachelet);
} else {
returnVal = CpLinkedListImpl::link(addToList->_list, CPEIndex, item, doTag, cachelet, _linkedListImplPool);
if (addToList->_list == NULL) {
addToList->_list = returnVal;
}
}
Trc_SHR_CMI_cpeTableUpdate_Exit(currentThread, returnVal);
return returnVal;
}
/* This function entirely resets the classpath cache. The mechanism currently uses runtimeFlags
* so that the JNI natives can tell the cache that a change has potentially invalidated the classpath cache.
* Assumes that identifiedClasspaths has been initialized and exists.
* THREADING: This function must only be called with _identifiedMutex already held
* Assumes that identifiedClasspaths has been initialized and exists.
*/
UDATA
SH_ClasspathManagerImpl2::testForClasspathReset(J9VMThread* currentThread)
{
J9JavaVM* vm = currentThread->javaVM;
if (getState() != MANAGER_STATE_STARTED) {
return 1;
}
Trc_SHR_CMI_testForClasspathReset_Entry(currentThread);
if ((*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_DO_RESET_CLASSPATH_CACHE) && (_identifiedClasspaths != NULL)) {
UDATA currentSize = _identifiedClasspaths->size;
*_runtimeFlagsPtr &= ~J9SHR_RUNTIMEFLAG_DO_RESET_CLASSPATH_CACHE;
freeIdentifiedClasspathArray(vm->portLibrary, _identifiedClasspaths);
_identifiedClasspaths = NULL;
_identifiedClasspaths = initializeIdentifiedClasspathArray(vm->portLibrary, currentSize, NULL, 0, 0);
/* If re-allocation fails, don't bomb out. Just disable classpath cacheing to ensure we don't crash. */
if (!_identifiedClasspaths) {
*_runtimeFlagsPtr &= ~J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING;
}
Trc_SHR_CMI_testForClasspathReset_ExitReset(currentThread);
return 0;
}
Trc_SHR_CMI_testForClasspathReset_ExitDoNothing(currentThread);
return 1;
}
/* Private function used exclusively by update(...)
* Looks for identified classpath in identified array. Takes a local classpath. Returns a ClasspathWrapper or null.
* Note that since the modified context does not change for a single JVM, it is irrelevant to classpath cacheing.
*/
ClasspathWrapper*
SH_ClasspathManagerImpl2::localUpdate_FindIdentified(J9VMThread* currentThread, ClasspathItem* localCP)
{
ClasspathWrapper* found = NULL;
Trc_SHR_CMI_localUpdate_FindIdentified_Entry(currentThread, localCP);
if (_cache->enterLocalMutex(currentThread, _identifiedMutex, "identifiedMutex", "localUpdate_FindIdentified")==0) {
if (testForClasspathReset(currentThread)) {
found = (ClasspathWrapper*)getIdentifiedClasspath(currentThread, _identifiedClasspaths, localCP->getHelperID(), localCP->getItemsAdded(), NULL, 0, NULL);
}
_cache->exitLocalMutex(currentThread, _identifiedMutex, "identifiedMutex", "localUpdate_FindIdentified");
} /* If monitor_enter fails, just do manual match */
Trc_SHR_CMI_localUpdate_FindIdentified_Exit(currentThread, found);
return found;
}
/* Private function used exclusively by both update(...) and validate(...)
* Associates a classpath in the cache with a classpath from a local classloader by adding it to the identified array.
* Note that since the modified context does not change for a single JVM, it is irrelevant to classpath cacheing.
* Returns 0 if ok or -1 for failure.
*
* Caller must hold _identifiedMutex.
*/
IDATA
SH_ClasspathManagerImpl2::local_StoreIdentified(J9VMThread* currentThread, ClasspathItem* localCP, ClasspathWrapper* cpInCache)
{
Trc_SHR_CMI_local_StoreIdentified_Entry(currentThread, localCP, cpInCache);
Trc_SHR_Assert_ShouldHaveLocalMutex(_identifiedMutex);
if (testForClasspathReset(currentThread)) {
setIdentifiedClasspath(currentThread, &_identifiedClasspaths, localCP->getHelperID(), localCP->getItemsAdded(), NULL, 0, cpInCache);
}
if ((_identifiedClasspaths == NULL) || (_identifiedClasspaths->size == 0)) {
/* Now that we can choose to make the identified array NULL if we exceed a number of classpaths, this is no longer an error condition */
/* CMI_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_CREATE_IDCPARRAY); */
*_runtimeFlagsPtr &= ~J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING;
Trc_SHR_CMI_local_StoreIdentified_Exit1(currentThread);
return -1;
}
Trc_SHR_CMI_local_StoreIdentified_Exit2(currentThread);
return 0;
}
/* Private function used exclusively by update(...)
* Attempts to match a local classpath with a classpath in the cache.
* Returns a ClasspathWrapper if a match is found, or null.
*/
ClasspathWrapper*
SH_ClasspathManagerImpl2::localUpdate_CheckManually(J9VMThread* currentThread, ClasspathItem* cp, CpLinkedListHdr** knownLLH)
{
CpLinkedListHdr* known = NULL;
ClasspathWrapper* found = NULL;
U_16 pathLen = 0;
const char* path = NULL;
Trc_SHR_CMI_localUpdate_CheckManually_Entry(currentThread, cp);
path = cp->itemAt(0)->getLocation(&pathLen);
known = cpeTableLookup(currentThread, path, pathLen, (cp->getType()==CP_TYPE_TOKEN));
if (known && known->_list) {
CpLinkedListImpl* cpInCache = NULL;
Trc_SHR_CMI_localUpdate_CheckManually_FoundKnown(currentThread, known);
cpInCache = (known->_list)->forCacheItem(currentThread, cp, 0);
if (cpInCache) {
/* forCacheItem only returns an identical classpath, so we have now found our classpath */
found = (ClasspathWrapper*)ITEMDATA(cpInCache->_item);
}
*knownLLH = known;
}
Trc_SHR_CMI_localUpdate_CheckManually_Exit(currentThread, found);
return found;
}
/**
* Main entry point for a store call. Looks for a classpath in the cache which exactly matches the caller's classpath
* and validates that every entry upto and including the entry at cpeIndex has not changed.
*
* May detect a stale classpath and mark the classpath stale, so any caller of this function should be aware
* that the result of calling it could be a stale mark.
* Only returns a classpath if it is an exact match for the caller's classpath and if it is proved to be non-stale.
*
* @see ClasspathManager.hpp
* @warning Must always be called with write mutex held
* param[in] currentThread The current thread
* param[in] localCP The ClasspathItem from the caller classloader
* param[in] cpeIndex The index in localCP that ROMClass was loaded from
* param[out] foundCP A ClasspathItem in the cache that exactly matches localCP and has been proved non-stale
*
* @return 0 for success, non-zero for failure
*/
IDATA
SH_ClasspathManagerImpl2::update(J9VMThread* currentThread, ClasspathItem* localCP, I_16 cpeIndex, ClasspathWrapper** foundCP)
{
I_16 i;
ClasspathWrapper* found = NULL;
bool foundIdentified = false;
CpLinkedListHdr* knownLLH = NULL;
if (getState() != MANAGER_STATE_STARTED) {
return -1;
}
Trc_SHR_CMI_Update_Entry(currentThread, localCP, cpeIndex);
/* Search local cache of known "identified" classpaths */
if (localCP->getType()==CP_TYPE_CLASSPATH && (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING)) {
found = localUpdate_FindIdentified(currentThread, localCP);
}
/* If not found an "identified" classpath, do a full search */
if (found) {
foundIdentified = true;
} else {
found = localUpdate_CheckManually(currentThread, localCP, &knownLLH);
}
/* If classpath was found, walk classpath upto and including cpeIndex, checking timestamps of timestampable entries.
Do not check whole classpath as this will get very expensive... also, post-cpeIndex staleness doesn't matter */
if (found && (localCP->getType()!=CP_TYPE_TOKEN) && (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_TIMESTAMP_CHECKS)) {
for (i=0; i<=cpeIndex; i++) {
ClasspathEntryItem* foundItem = ((ClasspathItem*)CPWDATA(found))->itemAt(i);
IDATA rc = hasTimestampChanged(currentThread, foundItem, knownLLH, true);
if ((rc == 1) && (_cache->markStale(currentThread, foundItem, true))) {
Trc_SHR_CMI_Update_Exit3(currentThread);
PORT_ACCESS_FROM_PORT(_portlib);
M_ERR_TRACE(J9NLS_SHRC_CMI_FAILED_MARKSTALE_UPDATE);
return -1;
} else if (rc == -1) {
Trc_SHR_CMI_Update_Exit4(currentThread);
return -1;
}
}
}
/* Classpath could have become stale above! */
if (!found || isStale(found)) {
*foundCP = NULL; /* Tells caller to create new classpath */
} else {
*foundCP = found;
}
/* If we found the classpath in the cache, it wasn't stale and it hasn't already been identified, add it to the identified array */
if ((*foundCP && !foundIdentified) && (localCP->getType()==CP_TYPE_CLASSPATH) && (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING)) {
if (0 == _cache->enterLocalMutex(currentThread, _identifiedMutex, "identifiedMutex", "update")) {
if (local_StoreIdentified(currentThread, localCP, *foundCP)==-1) {
Trc_SHR_CMI_Update_Exit1(currentThread);
_cache->exitLocalMutex(currentThread, _identifiedMutex, "identifiedMutex", "update");
return -1; /* Error already reported */
}
_cache->exitLocalMutex(currentThread, _identifiedMutex, "identifiedMutex", "update");
} else {
Trc_SHR_CMI_Update_Exit5(currentThread);
return -1;
}
}
Trc_SHR_CMI_Update_Exit2(currentThread, (*foundCP));
return 0; /* Indicates that there were no errors */
}
/* Private function used exclusively by validate(...)
* Looks for identified classpath in identified array.
* Note that since the modified context does not change for a single JVM, it is irrelevant to classpath cacheing.
* Returns helperID of identified classpath if one is found. Else returns ID_NOT_FOUND.
*
* Caller must hold _identifiedMutex.
*/
IDATA
SH_ClasspathManagerImpl2::localValidate_FindIdentified(J9VMThread* currentThread, ClasspathWrapper* cpInCache, IDATA walkFromID)
{
IDATA identifiedID = ID_NOT_FOUND;
Trc_SHR_CMI_localValidate_FindIdentified_Entry(currentThread, cpInCache);
Trc_SHR_Assert_ShouldHaveLocalMutex(_identifiedMutex);
if (testForClasspathReset(currentThread)) {
identifiedID = getIDForIdentified(_portlib, _identifiedClasspaths, cpInCache, walkFromID);
}
if (identifiedID==ID_NOT_FOUND) {
Trc_SHR_CMI_localValidate_FindIdentified_ExitNotFound(currentThread);
} else {
Trc_SHR_CMI_localValidate_FindIdentified_ExitFound(currentThread, identifiedID);
}
return identifiedID;
}
/* Private function used exclusively by validate(...)
* Attempts to "validate" a classpath in the cache against a classpath from a caller classloader.
* cpInCache is the cache classpath and testCPIndex is the index of the test ROMClass in that classpath.
* May try to "identify" a classpath if it seems worthwhile. Sets *addToIdentified=true if it successfully matches the classpath with a classpath in the cache.
* As part of the validation, timestamps appropriate entries and sets *staleItem if it finds a stale item.
* Returns the index in the caller's classpath (compareTo) that the ROMClass is found at, or -1 if not found.
*/
I_16
SH_ClasspathManagerImpl2::localValidate_CheckAndTimestampManually(J9VMThread* currentThread, ClasspathWrapper* cpInCache, I_16 testCPIndex, ClasspathItem* compareTo, IDATA foundIdentified, bool* addToIdentified, ClasspathEntryItem** staleItem)
{
ClasspathItem* testCPI = NULL;
ClasspathEntryItem* testItem = NULL;
I_16 indexInCompare = 0;
I_16 walkToIndex;
bool doTryIdentify;
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_Entry(currentThread, cpInCache, compareTo, testCPIndex);
testCPI = (ClasspathItem*)CPWDATA(cpInCache);
testItem = testCPI->itemAt(testCPIndex); /* testItem is classpath entry the ROMClass was stored against */
*addToIdentified = false;
*staleItem = NULL;
/* ClasspathEntryItem of stored romclass should exist in compareTo
* If so, then if the index of the testItem in compareTo is greater than that in the cpInCache,
* then there is clearly more items to the left of it in the cpInCache, so we know to fail
*/
indexInCompare = compareTo->find(currentThread->javaVM->internalVMFunctions, testItem);
if ((indexInCompare < 0) || (indexInCompare > testCPIndex)) {
if (!(foundIdentified & (ID_NOT_FOUND | ID_NOT_SET)) && (compareTo->getType()==CP_TYPE_CLASSPATH) && (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING)) {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_RegisterFailed(currentThread);
Trc_SHR_Assert_ShouldHaveLocalMutex(_identifiedMutex);
registerFailedMatch(currentThread, _identifiedClasspaths, compareTo->getHelperID(), foundIdentified, testCPIndex, NULL, 0);
}
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_Exit1(currentThread, indexInCompare);
return -1;
}
/* If token, this is all we need to prove success. Will only ever have one entry. */
if (compareTo->getType()==CP_TYPE_TOKEN) {
if (indexInCompare==0) {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_ExitTokenFound(currentThread);
return 0;
} else {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_ExitTokenNotFound(currentThread);
return -1;
}
}
/* If this is an as-yet unidentified classpath, is it worth us trying to identify it?
* Yes if classpaths have same hashcode and number of items, if testItem is at same index in both and if classpath is not part-stale
* Note: Hashcode is no guarantee of equality.
*/
if (compareTo->getType()==CP_TYPE_CLASSPATH
&& (testCPI->getType()==CP_TYPE_CLASSPATH)
&& (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_LOCAL_CACHEING)
&& (indexInCompare == testCPIndex)
&& (compareTo->getItemsAdded() == testCPI->getItemsAdded())
&& (compareTo->getHashCode() == testCPI->getHashCode()) && !isStale(cpInCache)) {
/* Try to identify - walk whole classpath to see if it is the same */
doTryIdentify = true;
walkToIndex = (compareTo->getItemsAdded()-1);
} else {
/* Not going to identify - walk only those ClasspathEntryItems to left of indexInCompare */
doTryIdentify = false;
walkToIndex = indexInCompare;
}
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_DoTryIdentifySet(currentThread, doTryIdentify, walkToIndex);
/* Walk the test classpath, checking consistency with the real one */
for (I_16 i=walkToIndex; i>=0; i--) {
ClasspathEntryItem* walk = compareTo->itemAt(i);
I_16 indexInTestCP = 0;
U_16 pathLen = 0;
const char* cpeiPath = walk->getPath(&pathLen);
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_TestEntry(currentThread, pathLen, cpeiPath, i);
if (doTryIdentify) {
/* We expect to find walk at index i in cpInCache */
indexInTestCP = testCPI->find(currentThread->javaVM->internalVMFunctions, walk, i);
if (indexInTestCP != i) {
/* We failed to identify the classpath. Revert to normal "match" mode. */
doTryIdentify = false;
}
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_DoTryIdentify(currentThread, indexInTestCP);
}
/* Not "else" because if doTryIdentify = false above, need to re-find indexInTestCP */
if (!doTryIdentify) {
if (i > indexInCompare) {
/* Once we have failed to identify, skip classpath entries which don't matter */
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_SkippingEntry(currentThread, i);
continue;
}
/* Searches the cpInCache upto testCPIndex for testItem */
indexInTestCP = testCPI->find(currentThread->javaVM->internalVMFunctions, walk, testCPIndex);
}
if ((indexInTestCP < 0)) {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_Exit2(currentThread);
return -1;
} else if (*_runtimeFlagsPtr & J9SHR_RUNTIMEFLAG_ENABLE_TIMESTAMP_CHECKS) {
/* Check the timestamp of classpath entry IN THE CACHE */
ClasspathEntryItem* foundItem = testCPI->itemAt(indexInTestCP);
IDATA rc = hasTimestampChanged(currentThread, foundItem, NULL, (compareTo->getHelperID()==0));
/* THREADING: If we find that the timestamp has changed between us finding the class
* and running this check, store the stale item (markStale happens later) and return -1
* which will cause the FIND to fail.
*/
/* doTryLockJar = false for non-bootstrap because we are trying to load from the cache, not from disk, so JARs may not yet be locked by the classloader.
Bootstrap loader is always helperID==0 and it DOES lock its jars, so this is safe. */
if (rc == 1) {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_DetectedStaleCPEI(currentThread, foundItem);
if (_cache->getCompositeCacheAPI()->isRunningReadOnly()) {
/* If we're running in read-only mode, disable sharing for this local classpath as it's too expensive to keep checking */
compareTo->flags |= MARKED_STALE_FLAG;
}
if (!(*staleItem)) {
*staleItem = foundItem;
}
/* Ensure we don't try to store this classpath as "identified" if we've just discovered it is stale! */
doTryIdentify = false;
/* Only fail the find if the stale entry is indexInCompare or earlier */
if (i <= indexInCompare) {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_Exit3(currentThread);
return -1;
}
} else if (rc == -1) {
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_Exit4(currentThread);
return -1;
}
}
}
*addToIdentified = doTryIdentify;
Trc_SHR_CMI_localValidate_CheckAndTimestampManually_ExitSuccess(currentThread, indexInCompare, (*addToIdentified), (*staleItem));
return indexInCompare;
}
/**
* Main entry point for a find call. Compares the classpath of a found ROMClass to that of the caller classloader
* to determine whether the ROMClass should be returned by the find call.
*
* Note that the classpath of the foundROMClass and that of the caller classloader do not have to be an exact match.