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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
|
--- hotspot/src/share/vm/memory/allocation.cpp 2011-01-20 18:51:20.000000000 -0500
+++ hotspot/src/share/vm/memory/allocation.cpp 2011-02-17 18:15:34.000000000 -0500
@@ -377,6 +377,9 @@ size_t Arena::used() const {
return sum; // Return total consumed space.
}
+void Arena::signal_out_of_memory(size_t sz, const char* whence) const {
+ vm_exit_out_of_memory(sz, whence);
+}
// Grow a new Chunk
void* Arena::grow( size_t x ) {
@@ -386,8 +389,9 @@ void* Arena::grow( size_t x ) {
Chunk *k = _chunk; // Get filled-up chunk address
_chunk = new (len) Chunk(len);
- if (_chunk == NULL)
- vm_exit_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow");
+ if (_chunk == NULL) {
+ signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow");
+ }
if (k) k->set_next(_chunk); // Append new chunk to end of linked list
else _first = _chunk;
@@ -484,6 +488,7 @@ void* Arena::malloc(size_t size) {
// for debugging with UseMallocOnly
void* Arena::internal_malloc_4(size_t x) {
assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
+ check_for_overflow(x, "Arena::internal_malloc_4");
if (_hwm + x > _max) {
return grow(x);
} else {
--- hotspot/src/share/vm/memory/allocation.hpp 2011-01-20 18:51:20.000000000 -0500
+++ hotspot/src/share/vm/memory/allocation.hpp 2011-02-17 18:15:34.000000000 -0500
@@ -194,6 +194,15 @@ protected:
friend class AllocStats;
debug_only(void* malloc(size_t size);)
debug_only(void* internal_malloc_4(size_t x);)
+
+ void signal_out_of_memory(size_t request, const char* whence) const;
+
+ void check_for_overflow(size_t request, const char* whence) const {
+ if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
+ signal_out_of_memory(request, whence);
+ }
+ }
+
public:
Arena();
Arena(size_t init_size);
@@ -207,6 +216,7 @@ protected:
assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
x = ARENA_ALIGN(x);
debug_only(if (UseMallocOnly) return malloc(x);)
+ check_for_overflow(x, "Arena::Amalloc");
NOT_PRODUCT(_bytes_allocated += x);
if (_hwm + x > _max) {
return grow(x);
@@ -220,6 +230,7 @@ protected:
void *Amalloc_4(size_t x) {
assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
debug_only(if (UseMallocOnly) return malloc(x);)
+ check_for_overflow(x, "Arena::Amalloc_4");
NOT_PRODUCT(_bytes_allocated += x);
if (_hwm + x > _max) {
return grow(x);
@@ -240,6 +251,7 @@ protected:
size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm;
x += delta;
#endif
+ check_for_overflow(x, "Arena::Amalloc_D");
NOT_PRODUCT(_bytes_allocated += x);
if (_hwm + x > _max) {
return grow(x); // grow() returns a result aligned >= 8 bytes.
--- hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp 2011-01-20 18:51:22.000000000 -0500
+++ hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp 2011-02-17 18:15:34.000000000 -0500
@@ -143,6 +143,17 @@ typedef unsigned int uintptr_
#endif
#endif
+// On solaris 8, UINTPTR_MAX is defined as empty.
+// Everywhere else it's an actual value.
+#if UINTPTR_MAX - 1 == -1
+#undef UINTPTR_MAX
+#ifdef _LP64
+#define UINTPTR_MAX UINT64_MAX
+#else
+#define UINTPTR_MAX UINT32_MAX
+#endif /* ifdef _LP64 */
+#endif
+
// Additional Java basic types
typedef unsigned char jubyte;
--- hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp 2011-01-20 18:51:22.000000000 -0500
+++ hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp 2011-02-17 18:15:34.000000000 -0500
@@ -36,6 +36,7 @@
# include <stdio.h> // for va_list
# include <time.h>
# include <fcntl.h>
+# include <limits.h>
// Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES
# include <math.h>
@@ -94,6 +95,14 @@ typedef signed int intptr_t;
typedef signed int ssize_t;
#endif
+#ifndef UINTPTR_MAX
+#ifdef _WIN64
+#define UINTPTR_MAX _UI64_MAX
+#else
+#define UINTPTR_MAX _UI32_MAX
+#endif
+#endif
+
//----------------------------------------------------------------------------------------------------
// Additional Java basic types
--- jaxp/build.properties 2011-01-20 18:51:34.000000000 -0500
+++ jaxp/build.properties 2011-02-17 18:15:35.000000000 -0500
@@ -77,6 +77,9 @@
# Where patches to drop bundle sources live
patches.dir=patches
+# Patches to apply
+jaxp_src.patch.list=6927050.patch
+
# Sanity information
sanity.info= Sanity Settings:${line.separator}\
ant.home=${ant.home}${line.separator}\
--- jaxp/patches/jaxp_src/6927050.patch 2011-02-18 18:33:00.000000000 -0500
+++ jaxp/patches/jaxp_src/6927050.patch 2011-02-18 18:34:31.000000000 -0500
@@ -0,0 +1,311 @@
+--- src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java 2010-08-26 17:50:55.000000000 -0400
++++ src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java 2011-02-18 18:14:28.000000000 -0500
+@@ -20,6 +20,8 @@
+
+ package com.sun.org.apache.xerces.internal.jaxp.validation;
+
++import java.util.HashMap;
++
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator;
+ import javax.xml.validation.ValidatorHandler;
+@@ -32,6 +34,16 @@
+ abstract class AbstractXMLSchema extends Schema implements
+ XSGrammarPoolContainer {
+
++ /**
++ * Map containing the initial values of features for
++ * validators created using this grammar pool container.
++ */
++ private final HashMap fFeatures;
++
++ public AbstractXMLSchema() {
++ fFeatures = new HashMap();
++ }
++
+ /*
+ * Schema methods
+ */
+@@ -50,4 +62,25 @@
+ return new ValidatorHandlerImpl(this);
+ }
+
++ /*
++ * XSGrammarPoolContainer methods
++ */
++
++ /**
++ * Returns the initial value of a feature for validators created
++ * using this grammar pool container or null if the validators
++ * should use the default value.
++ */
++ public final Boolean getFeature(String featureId) {
++ return (Boolean) fFeatures.get(featureId);
++ }
++
++ /*
++ * Other methods
++ */
++
++ final void setFeature(String featureId, boolean state) {
++ fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
++ }
++
+ } // AbstractXMLSchema
+--- src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java 2010-08-26 17:50:55.000000000 -0400
++++ src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java 2011-02-18 18:33:41.000000000 -0500
+@@ -32,17 +32,10 @@
+ */
+ final class EmptyXMLSchema extends AbstractXMLSchema implements XMLGrammarPool {
+
+- private static EmptyXMLSchema EMPTY_XML_SCHEMA_INSTANCE = new EmptyXMLSchema();
+-
+ /** Zero length grammar array. */
+ private static final Grammar [] ZERO_LENGTH_GRAMMAR_ARRAY = new Grammar [0];
+
+- /** Returns the one and only instance of this class. */
+- public static EmptyXMLSchema getInstance() {
+- return EMPTY_XML_SCHEMA_INSTANCE;
+- }
+-
+- private EmptyXMLSchema() {}
++ public EmptyXMLSchema() {}
+
+ /*
+ * XMLGrammarPool methods
+--- src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java 2010-08-27 16:13:40.000000000 -0400
++++ src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java 2011-02-18 18:14:28.000000000 -0500
+@@ -228,21 +228,26 @@
+
+ // Select Schema implementation based on grammar count.
+ final int grammarCount = pool.getGrammarCount();
++ AbstractXMLSchema schema = null;
+ if (grammarCount > 1) {
+- return new XMLSchema(new ReadOnlyGrammarPool(pool));
++ schema = new XMLSchema(new ReadOnlyGrammarPool(pool));
+ }
+ else if (grammarCount == 1) {
+ Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
+- return new SimpleXMLSchema(grammars[0]);
++ schema = new SimpleXMLSchema(grammars[0]);
+ }
+ else {
+- return EmptyXMLSchema.getInstance();
++ schema = new EmptyXMLSchema();
+ }
++ propagateFeatures(schema);
++ return schema;
+ }
+
+ public Schema newSchema() throws SAXException {
+ // Use a Schema that uses the system id as the equality source.
+- return new WeakReferenceXMLSchema();
++ AbstractXMLSchema schema = new WeakReferenceXMLSchema();
++ propagateFeatures(schema);
++ return schema;
+ }
+
+ public boolean getFeature(String name)
+@@ -371,6 +376,15 @@
+ }
+ }
+ }
++
++ private void propagateFeatures(AbstractXMLSchema schema) {
++ schema.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fSecurityManager != null);
++ String[] features = fXMLSchemaLoader.getRecognizedFeatures();
++ for (int i = 0; i < features.length; ++i) {
++ boolean state = fXMLSchemaLoader.getFeature(features[i]);
++ schema.setFeature(features[i], state);
++ }
++ }
+
+ /**
+ * Extension of XMLGrammarPoolImpl which exposes the number of
+--- src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java 2010-08-27 16:13:39.000000000 -0400
++++ src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java 2011-02-18 18:14:28.000000000 -0500
+@@ -22,6 +22,8 @@
+
+ import java.util.HashMap;
+ import java.util.Locale;
++import java.util.Iterator;
++import java.util.Map;
+
+ import javax.xml.XMLConstants;
+
+@@ -159,6 +161,19 @@
+
+ /** Validation manager. */
+ private ValidationManager fValidationManager;
++
++ //
++ // Configuration
++ //
++
++ /** Stores initial feature values for validator reset. */
++ private final HashMap fInitFeatures = new HashMap();
++
++ /** Stores initial property values for validator reset. */
++ private final HashMap fInitProperties = new HashMap();
++
++ /** Stores the initial security manager. */
++ private final SecurityManager fInitSecurityManager;
+
+ //
+ // User Objects
+@@ -211,9 +226,20 @@
+ fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
+
+ // add all recognized features and properties and apply their defaults
+- addRecognizedParamsAndSetDefaults(fEntityManager);
+- addRecognizedParamsAndSetDefaults(fErrorReporter);
+- addRecognizedParamsAndSetDefaults(fSchemaValidator);
++ addRecognizedParamsAndSetDefaults(fEntityManager, grammarContainer);
++ addRecognizedParamsAndSetDefaults(fErrorReporter, grammarContainer);
++ addRecognizedParamsAndSetDefaults(fSchemaValidator, grammarContainer);
++
++ // if the secure processing feature is set to true, add a security manager to the configuration
++ Boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
++ if (Boolean.TRUE.equals(secureProcessing)) {
++ fInitSecurityManager = new SecurityManager();
++ }
++ else {
++ fInitSecurityManager = null;
++ }
++ fComponents.put(SECURITY_MANAGER, fInitSecurityManager);
++
+ }
+
+ /**
+@@ -266,7 +292,6 @@
+ else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) {
+ throw new XMLConfigurationException(XMLConfigurationException.NOT_SUPPORTED, featureId);
+ }
+- fConfigUpdated = true;
+ if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
+ if (_isSecureMode && !value) {
+ throw new XMLConfigurationException(XMLConfigurationException.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
+@@ -274,9 +299,14 @@
+ setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null);
+ return;
+ }
++ fConfigUpdated = true;
+ fEntityManager.setFeature(featureId, value);
+ fErrorReporter.setFeature(featureId, value);
+ fSchemaValidator.setFeature(featureId, value);
++ if (!fInitFeatures.containsKey(featureId)) {
++ boolean current = super.getFeature(featureId);
++ fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE);
++ }
+ super.setFeature(featureId, value);
+ }
+
+@@ -336,6 +366,9 @@
+ fComponents.put(propertyId, value);
+ return;
+ }
++ if (!fInitProperties.containsKey(propertyId)) {
++ fInitProperties.put(propertyId, super.getProperty(propertyId));
++ }
+ super.setProperty(propertyId, value);
+ }
+
+@@ -348,7 +381,7 @@
+ * @param component The component whose recognized features
+ * and properties will be added to the configuration
+ */
+- public void addRecognizedParamsAndSetDefaults(XMLComponent component) {
++ public void addRecognizedParamsAndSetDefaults(XMLComponent component, XSGrammarPoolContainer grammarContainer) {
+
+ // register component's recognized features
+ final String[] recognizedFeatures = component.getRecognizedFeatures();
+@@ -359,7 +392,7 @@
+ addRecognizedProperties(recognizedProperties);
+
+ // set default values
+- setFeatureDefaults(component, recognizedFeatures);
++ setFeatureDefaults(component, recognizedFeatures, grammarContainer);
+ setPropertyDefaults(component, recognizedProperties);
+ }
+
+@@ -406,10 +439,6 @@
+ void restoreInitialState() {
+ fConfigUpdated = true;
+
+- // Clear feature and property tables.
+- fFeatures.clear();
+- fProperties.clear();
+-
+ // Remove error resolver and error handler
+ fComponents.put(ENTITY_RESOLVER, null);
+ fComponents.put(ERROR_HANDLER, null);
+@@ -418,21 +447,46 @@
+ setLocale(null);
+ fComponents.put(LOCALE, null);
+
+- // Restore component defaults.
+- setFeatureDefaults(fEntityManager, fEntityManager.getRecognizedFeatures());
+- setPropertyDefaults(fEntityManager, fEntityManager.getRecognizedProperties());
+- setFeatureDefaults(fErrorReporter, fErrorReporter.getRecognizedFeatures());
+- setPropertyDefaults(fErrorReporter, fErrorReporter.getRecognizedProperties());
+- setFeatureDefaults(fSchemaValidator, fSchemaValidator.getRecognizedFeatures());
+- setPropertyDefaults(fSchemaValidator, fSchemaValidator.getRecognizedProperties());
++ // Restore initial security manager
++ fComponents.put(SECURITY_MANAGER, fInitSecurityManager);
++
++ // Set the Locale back to null.
++ setLocale(null);
++ fComponents.put(LOCALE, null);
++
++ // Reset feature and property values to their initial values
++ if (!fInitFeatures.isEmpty()) {
++ Iterator iter = fInitFeatures.entrySet().iterator();
++ while (iter.hasNext()) {
++ Map.Entry entry = (Map.Entry) iter.next();
++ String name = (String) entry.getKey();
++ boolean value = ((Boolean) entry.getValue()).booleanValue();
++ super.setFeature(name, value);
++ }
++ fInitFeatures.clear();
++ }
++ if (!fInitProperties.isEmpty()) {
++ Iterator iter = fInitProperties.entrySet().iterator();
++ while (iter.hasNext()) {
++ Map.Entry entry = (Map.Entry) iter.next();
++ String name = (String) entry.getKey();
++ Object value = entry.getValue();
++ super.setProperty(name, value);
++ }
++ fInitProperties.clear();
++ }
+ }
+
+ /** Sets feature defaults for the given component on this configuration. */
+- private void setFeatureDefaults(final XMLComponent component, final String [] recognizedFeatures) {
++ private void setFeatureDefaults(final XMLComponent component,
++ final String [] recognizedFeatures, XSGrammarPoolContainer grammarContainer) {
+ if (recognizedFeatures != null) {
+ for (int i = 0; i < recognizedFeatures.length; ++i) {
+ String featureId = recognizedFeatures[i];
+- Boolean state = component.getFeatureDefault(featureId);
++ Boolean state = grammarContainer.getFeature(featureId);
++ if (state == null) {
++ state = component.getFeatureDefault(featureId);
++ }
+ if (state != null) {
+ // Do not overwrite values already set on the configuration.
+ if (!fFeatures.containsKey(featureId)) {
+--- src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java 2010-08-26 17:50:55.000000000 -0400
++++ src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java 2011-02-18 18:14:28.000000000 -0500
+@@ -47,4 +47,11 @@
+ */
+ public boolean isFullyComposed();
+
++ /**
++ * Returns the initial value of a feature for validators created
++ * using this grammar pool container or null if the validators
++ * should use the default value.
++ */
++ public Boolean getFeature(String featureId);
++
+ }
--- jdk/make/sun/net/FILES_java.gmk 2011-01-20 18:54:06.000000000 -0500
+++ jdk/make/sun/net/FILES_java.gmk 2011-02-17 18:15:35.000000000 -0500
@@ -34,6 +34,7 @@ FILES_java = \
sun/net/ProgressEvent.java \
sun/net/ProgressListener.java \
sun/net/ProgressMeteringPolicy.java \
+ sun/net/ResourceManager.java \
sun/net/TelnetInputStream.java \
sun/net/TelnetOutputStream.java \
sun/net/TelnetProtocolException.java \
--- jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java 2011-01-20 18:54:12.000000000 -0500
+++ jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java 2011-02-17 18:15:35.000000000 -0500
@@ -247,6 +247,8 @@ public final class Transform extends Sig
if (!_alreadyInitialized) {
_transformHash = new HashMap(10);
+ // make sure builtin algorithms are all registered first
+ com.sun.org.apache.xml.internal.security.Init.init();
_alreadyInitialized = true;
}
}
@@ -274,19 +276,13 @@ public final class Transform extends Sig
"algorithm.alreadyRegistered", exArgs);
}
- ClassLoader cl = (ClassLoader) AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return Thread.currentThread().getContextClassLoader();
- }
- });
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Transform._transformHash.put
(algorithmURI, Class.forName(implementingClass, true, cl));
} catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new RuntimeException(e);
}
}
}
--- jdk/src/share/classes/java/awt/AWTEvent.java 2011-01-20 18:54:13.000000000 -0500
+++ jdk/src/share/classes/java/awt/AWTEvent.java 2011-02-17 18:15:34.000000000 -0500
@@ -33,6 +33,12 @@ import java.lang.reflect.Field;
import java.util.logging.Logger;
import java.util.logging.Level;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import sun.awt.AWTAccessor;
+
/**
* The root event class for all AWT events.
* This class and its subclasses supercede the original
@@ -97,10 +103,33 @@ public abstract class AWTEvent extends E
*/
protected boolean consumed = false;
+ /*
+ * The event's AccessControlContext.
+ */
+ private transient volatile AccessControlContext acc =
+ AccessController.getContext();
+
+ /*
+ * Returns the acc this event was constructed with.
+ */
+ final AccessControlContext getAccessControlContext() {
+ if (acc == null) {
+ throw new SecurityException("AWTEvent is missing AccessControlContext");
+ }
+ return acc;
+ }
+
transient boolean focusManagerIsDispatching = false;
transient boolean isPosted;
/**
+ * Indicates whether this AWTEvent was generated by the system as
+ * opposed to by user code.
+ */
+ private transient boolean isSystemGenerated;
+
+
+ /**
* The event mask for selecting component events.
*/
public final static long COMPONENT_EVENT_MASK = 0x01;
@@ -230,6 +259,19 @@ public abstract class AWTEvent extends E
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
+ AWTAccessor.setAWTEventAccessor(new AWTAccessor.AWTEventAccessor() {
+ public void setSystemGenerated(AWTEvent ev) {
+ ev.isSystemGenerated = true;
+ }
+
+ public boolean isSystemGenerated(AWTEvent ev) {
+ return ev.isSystemGenerated;
+ }
+
+ public AccessControlContext getAccessControlContext(AWTEvent ev) {
+ return ev.getAccessControlContext();
+ }
+ });
}
private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
@@ -564,4 +606,11 @@ public abstract class AWTEvent extends E
}
}
}
+
+ private void readObject(ObjectInputStream in)
+ throws ClassNotFoundException, IOException
+ {
+ this.acc = AccessController.getContext();
+ in.defaultReadObject();
+ }
} // class AWTEvent
--- jdk/src/share/classes/java/awt/Component.java 2011-01-20 18:54:13.000000000 -0500
+++ jdk/src/share/classes/java/awt/Component.java 2011-02-17 18:15:35.000000000 -0500
@@ -58,9 +58,11 @@ import java.lang.reflect.InvocationTarge
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.security.AccessControlContext;
import javax.accessibility.*;
import java.util.logging.*;
import java.applet.Applet;
+import sun.awt.AWTAccessor;
import sun.security.action.GetPropertyAction;
import sun.awt.AppContext;
@@ -451,6 +453,12 @@ public abstract class Component implemen
static final Object LOCK = new AWTTreeLock();
static class AWTTreeLock {}
+ /*
+ * The component's AccessControlContext.
+ */
+ private transient volatile AccessControlContext acc =
+ AccessController.getContext();
+
/**
* Minimum size.
* (This field perhaps should have been transient).
@@ -641,6 +649,16 @@ public abstract class Component implemen
return changeSupportLock;
}
+ /*
+ * Returns the acc this component was constructed with.
+ */
+ final AccessControlContext getAccessControlContext() {
+ if (acc == null) {
+ throw new SecurityException("Component is missing AccessControlContext");
+ }
+ return acc;
+ }
+
boolean isPacked = false;
/**
@@ -778,6 +796,16 @@ public abstract class Component implemen
}
}
+ static {
+ AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
+ public AccessControlContext getAccessControlContext(Component comp) {
+ return comp.getAccessControlContext();
+ }
+
+ });
+ }
+
+
/**
* Constructs a new component. Class <code>Component</code> can be
* extended directly to create a lightweight component that does not
@@ -8317,6 +8345,8 @@ public abstract class Component implemen
{
changeSupportLock = new Object();
+ acc = AccessController.getContext();
+
s.defaultReadObject();
appContext = AppContext.getAppContext();
--- jdk/src/share/classes/java/awt/EventDispatchThread.java 2011-01-20 18:54:13.000000000 -0500
+++ jdk/src/share/classes/java/awt/EventDispatchThread.java 2011-02-17 18:15:35.000000000 -0500
@@ -284,10 +284,7 @@ class EventDispatchThread extends Thread
// Threads in the AppContext
}
- // Can get and throw only unchecked exceptions
- catch (RuntimeException e) {
- processException(e, modalFiltersCount > 0);
- } catch (Error e) {
+ catch (Throwable e) {
processException(e, modalFiltersCount > 0);
}
return true;
--- jdk/src/share/classes/java/awt/EventQueue.java 2011-01-20 18:54:13.000000000 -0500
+++ jdk/src/share/classes/java/awt/EventQueue.java 2011-02-17 18:15:35.000000000 -0500
@@ -43,6 +43,12 @@ import sun.awt.AWTAutoShutdown;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
+import java.security.AccessControlContext;
+import java.security.ProtectionDomain;
+
+import sun.misc.SharedSecrets;
+import sun.misc.JavaSecurityAccess;
+
/**
* <code>EventQueue</code> is a platform-independent class
* that queues events, both from the underlying peer classes
@@ -554,6 +560,9 @@ public class EventQueue {
return null;
}
+ private static final JavaSecurityAccess javaSecurityAccess =
+ SharedSecrets.getJavaSecurityAccess();
+
/**
* Dispatches an event. The manner in which the event is
* dispatched depends upon the type of the event and the
@@ -592,13 +601,49 @@ public class EventQueue {
* @throws NullPointerException if <code>event</code> is <code>null</code>
* @since 1.2
*/
- protected void dispatchEvent(AWTEvent event) {
+ protected void dispatchEvent(final AWTEvent event) {
+ final Object src = event.getSource();
+ final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
+ public Void run() {
+ dispatchEventImpl(event, src);
+ return null;
+ }
+ };
+
+ final AccessControlContext stack = AccessController.getContext();
+ final AccessControlContext srcAcc = getAccessControlContextFrom(src);
+ final AccessControlContext eventAcc = event.getAccessControlContext();
+ if (srcAcc == null) {
+ javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
+ } else {
+ javaSecurityAccess.doIntersectionPrivilege(
+ new PrivilegedAction<Void>() {
+ public Void run() {
+ javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
+ return null;
+ }
+ }, stack, srcAcc);
+ }
+ }
+
+ private static AccessControlContext getAccessControlContextFrom(Object src) {
+ return src instanceof Component ?
+ ((Component)src).getAccessControlContext() :
+ src instanceof MenuComponent ?
+ ((MenuComponent)src).getAccessControlContext() :
+ src instanceof TrayIcon ?
+ ((TrayIcon)src).getAccessControlContext() :
+ null;
+ }
+
+ /**
+ * Called from dispatchEvent() under a correct AccessControlContext
+ */
+ private void dispatchEventImpl(final AWTEvent event, final Object src) {
event.isPosted = true;
- Object src = event.getSource();
if (event instanceof ActiveEvent) {
// This could become the sole method of dispatching in time.
setCurrentEventAndMostRecentTimeImpl(event);
-
((ActiveEvent)event).dispatch();
} else if (src instanceof Component) {
((Component)src).dispatchEvent(event);
--- jdk/src/share/classes/java/awt/MenuComponent.java 2011-01-20 18:54:14.000000000 -0500
+++ jdk/src/share/classes/java/awt/MenuComponent.java 2011-02-17 18:15:35.000000000 -0500
@@ -32,6 +32,9 @@ import sun.awt.AppContext;
import sun.awt.SunToolkit;
import javax.accessibility.*;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+
/**
* The abstract class <code>MenuComponent</code> is the superclass
* of all menu-related components. In this respect, the class
@@ -99,6 +102,23 @@ public abstract class MenuComponent impl
boolean newEventsOnly = false;
/*
+ * The menu's AccessControlContext.
+ */
+ private transient volatile AccessControlContext acc =
+ AccessController.getContext();
+
+ /*
+ * Returns the acc this menu component was constructed with.
+ */
+ final AccessControlContext getAccessControlContext() {
+ if (acc == null) {
+ throw new SecurityException(
+ "MenuComponent is missing AccessControlContext");
+ }
+ return acc;
+ }
+
+ /*
* Internal constants for serialization.
*/
final static String actionListenerK = Component.actionListenerK;
@@ -385,6 +405,9 @@ public abstract class MenuComponent impl
throws ClassNotFoundException, IOException, HeadlessException
{
GraphicsEnvironment.checkHeadless();
+
+ acc = AccessController.getContext();
+
s.defaultReadObject();
appContext = AppContext.getAppContext();
--- jdk/src/share/classes/java/awt/TrayIcon.java 2011-01-20 18:54:14.000000000 -0500
+++ jdk/src/share/classes/java/awt/TrayIcon.java 2011-02-17 18:15:35.000000000 -0500
@@ -39,6 +39,8 @@ import java.awt.peer.TrayIconPeer;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import java.util.EventObject;
+import java.security.AccessControlContext;
+import java.security.AccessController;
/**
* A <code>TrayIcon</code> object represents a tray icon that can be
@@ -89,6 +91,7 @@ import java.util.EventObject;
* @author Anton Tarasov
*/
public class TrayIcon {
+
private Image image;
private String tooltip;
private PopupMenu popup;
@@ -102,6 +105,24 @@ public class TrayIcon {
transient MouseMotionListener mouseMotionListener;
transient ActionListener actionListener;
+ /*
+ * The tray icon's AccessControlContext.
+ *
+ * Unlike the acc in Component, this field is made final
+ * because TrayIcon is not serializable.
+ */
+ private final AccessControlContext acc = AccessController.getContext();
+
+ /*
+ * Returns the acc this tray icon was constructed with.
+ */
+ final AccessControlContext getAccessControlContext() {
+ if (acc == null) {
+ throw new SecurityException("TrayIcon is missing AccessControlContext");
+ }
+ return acc;
+ }
+
static {
Toolkit.loadLibraries();
if (!GraphicsEnvironment.isHeadless()) {
--- jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java 2011-01-20 18:54:16.000000000 -0500
+++ jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java 2011-02-17 18:15:35.000000000 -0500
@@ -28,6 +28,7 @@ import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.Enumeration;
+import sun.net.ResourceManager;
/**
* Abstract datagram and multicast socket implementation base class.
@@ -65,8 +66,15 @@ abstract class AbstractPlainDatagramSock
* Creates a datagram socket
*/
protected synchronized void create() throws SocketException {
+ ResourceManager.beforeUdpCreate();
fd = new FileDescriptor();
- datagramSocketCreate();
+ try {
+ datagramSocketCreate();
+ } catch (SocketException ioe) {
+ ResourceManager.afterUdpClose();
+ fd = null;
+ throw ioe;
+ }
}
/**
@@ -211,6 +219,7 @@ abstract class AbstractPlainDatagramSock
protected void close() {
if (fd != null) {
datagramSocketClose();
+ ResourceManager.afterUdpClose();
fd = null;
}
}
--- jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java 2011-01-20 18:54:16.000000000 -0500
+++ jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java 2011-02-17 18:15:35.000000000 -0500
@@ -33,6 +33,7 @@ import java.io.FileDescriptor;
import java.io.ByteArrayOutputStream;
import sun.net.ConnectionResetException;
+import sun.net.ResourceManager;
/**
* Default Socket Implementation. This implementation does
@@ -69,6 +70,10 @@ abstract class AbstractPlainSocketImpl e
private int resetState;
private Object resetLock = new Object();
+ /* whether this Socket is a stream (TCP) socket or not (UDP)
+ */
+ private boolean stream;
+
/**
* Load net library into runtime.
*/
@@ -83,7 +88,19 @@ abstract class AbstractPlainSocketImpl e
*/
protected synchronized void create(boolean stream) throws IOException {
fd = new FileDescriptor();
- socketCreate(stream);
+ this.stream = stream;
+ if (!stream) {
+ ResourceManager.beforeUdpCreate();
+ try {
+ socketCreate(false);
+ } catch (IOException ioe) {
+ ResourceManager.afterUdpClose();
+ fd = null;
+ throw ioe;
+ }
+ } else {
+ socketCreate(true);
+ }
if (socket != null)
socket.setCreated();
if (serverSocket != null)
@@ -458,6 +475,9 @@ abstract class AbstractPlainSocketImpl e
protected void close() throws IOException {
synchronized(fdLock) {
if (fd != null) {
+ if (!stream) {
+ ResourceManager.afterUdpClose();
+ }
if (fdUseCount == 0) {
if (closePending) {
return;
--- jdk/src/share/classes/java/security/AccessControlContext.java 2011-01-20 18:54:16.000000000 -0500
+++ jdk/src/share/classes/java/security/AccessControlContext.java 2011-02-17 18:15:35.000000000 -0500
@@ -29,6 +29,9 @@ import java.util.ArrayList;
import java.util.List;
import sun.security.util.Debug;
import sun.security.util.SecurityConstants;
+import sun.misc.JavaSecurityAccess;
+import sun.misc.SharedSecrets;
+
/**
* An AccessControlContext is used to make system resource access decisions
@@ -87,6 +90,36 @@ public final class AccessControlContext
private static boolean debugInit = false;
private static Debug debug = null;
+ static {
+ // Set up JavaSecurityAccess in SharedSecrets
+ SharedSecrets.setJavaSecurityAccess(
+ new JavaSecurityAccess() {
+ public <T> T doIntersectionPrivilege(
+ PrivilegedAction<T> action,
+ final AccessControlContext stack,
+ final AccessControlContext context)
+ {
+ if (action == null) {
+ throw new NullPointerException();
+ }
+ return AccessController.doPrivileged(
+ action,
+ new AccessControlContext(
+ stack.getContext(), context).optimize()
+ );
+ }
+
+ public <T> T doIntersectionPrivilege(
+ PrivilegedAction<T> action,
+ AccessControlContext context)
+ {
+ return doIntersectionPrivilege(action,
+ AccessController.getContext(), context);
+ }
+ }
+ );
+ }
+
static Debug getDebug()
{
if (debugInit)
@@ -194,6 +227,24 @@ public final class AccessControlContext
}
/**
+ * Constructor for JavaSecurityAccess.doIntersectionPrivilege()
+ */
+ AccessControlContext(ProtectionDomain[] context,
+ AccessControlContext privilegedContext)
+ {
+ this.context = context;
+ this.privilegedContext = privilegedContext;
+ this.isPrivileged = true;
+ }
+
+ /**
+ * Returns this context's context.
+ */
+ ProtectionDomain[] getContext() {
+ return context;
+ }
+
+ /**
* Returns true if this context is privileged.
*/
boolean isPrivileged()
--- jdk/src/share/classes/javax/swing/Timer.java 2011-01-20 18:54:21.000000000 -0500
+++ jdk/src/share/classes/javax/swing/Timer.java 2011-02-17 18:15:35.000000000 -0500
@@ -35,6 +35,10 @@ import java.util.concurrent.locks.*;
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
+import java.io.*;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import javax.swing.event.EventListenerList;
@@ -174,6 +178,23 @@ public class Timer implements Serializab
private transient final Lock lock = new ReentrantLock();
+ /*
+ * The timer's AccessControlContext.
+ */
+ private transient volatile AccessControlContext acc =
+ AccessController.getContext();
+
+ /**
+ * Returns the acc this timer was constructed with.
+ */
+ final AccessControlContext getAccessControlContext() {
+ if (acc == null) {
+ throw new SecurityException(
+ "Timer is missing AccessControlContext");
+ }
+ return acc;
+ }
+
// This field is maintained by TimerQueue.
// eventQueued can also be reset by the TimerQueue, but will only ever
// happen in applet case when TimerQueues thread is destroyed.
@@ -191,7 +212,7 @@ public class Timer implements Serializab
*
* @param delay milliseconds for the initial and between-event delay
* @param listener an initial listener; can be <code>null</code>
- *
+
* @see #addActionListener
* @see #setInitialDelay
* @see #setRepeats
@@ -208,7 +229,6 @@ public class Timer implements Serializab
}
}
-
/**
* DoPostEvent is a runnable class that fires actionEvents to
* the listeners on the EventDispatchThread, via invokeLater.
@@ -589,7 +609,12 @@ public class Timer implements Serializab
void post() {
if (notify.compareAndSet(false, true) || !coalesce) {
- SwingUtilities.invokeLater(doPostEvent);
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ SwingUtilities.invokeLater(doPostEvent);
+ return null;
+ }
+ }, getAccessControlContext());
}
}
@@ -611,4 +636,11 @@ public class Timer implements Serializab
timer.actionCommand = actionCommand;
return timer;
}
+
+ private void readObject(ObjectInputStream in)
+ throws ClassNotFoundException, IOException
+ {
+ this.acc = AccessController.getContext();
+ in.defaultReadObject();
+ }
}
--- jdk/src/share/classes/javax/swing/TransferHandler.java 2011-01-20 18:54:21.000000000 -0500
+++ jdk/src/share/classes/javax/swing/TransferHandler.java 2011-02-17 18:15:35.000000000 -0500
@@ -41,6 +41,16 @@ import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import sun.swing.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import java.security.AccessControlContext;
+import java.security.ProtectionDomain;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaSecurityAccess;
+
+import sun.awt.AWTAccessor;
+
/**
* This class is used to handle the transfer of a <code>Transferable</code>
* to and from Swing components. The <code>Transferable</code> is used to
@@ -1640,7 +1650,37 @@ public class TransferHandler implements
return true;
}
- public void actionPerformed(ActionEvent e) {
+ private static final JavaSecurityAccess javaSecurityAccess =
+ SharedSecrets.getJavaSecurityAccess();
+
+ public void actionPerformed(final ActionEvent e) {
+ final Object src = e.getSource();
+
+ final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
+ public Void run() {
+ actionPerformedImpl(e);
+ return null;
+ }
+ };
+
+ final AccessControlContext stack = AccessController.getContext();
+ final AccessControlContext srcAcc = AWTAccessor.getComponentAccessor().getAccessControlContext((Component)src);
+ final AccessControlContext eventAcc = AWTAccessor.getAWTEventAccessor().getAccessControlContext(e);
+
+ if (srcAcc == null) {
+ javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
+ } else {
+ javaSecurityAccess.doIntersectionPrivilege(
+ new PrivilegedAction<Void>() {
+ public Void run() {
+ javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
+ return null;
+ }
+ }, stack, srcAcc);
+ }
+ }
+
+ private void actionPerformedImpl(ActionEvent e) {
Object src = e.getSource();
if (src instanceof JComponent) {
JComponent c = (JComponent) src;
--- jdk/src/share/classes/sun/awt/AWTAccessor.java 2011-02-17 18:15:35.000000000 -0500
+++ jdk/src/share/classes/sun/awt/AWTAccessor.java 2011-02-17 18:15:35.000000000 -0500
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.awt;
+
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
+import sun.misc.Unsafe;
+import java.awt.peer.ComponentPeer;
+
+import java.security.AccessController;
+import java.security.AccessControlContext;
+
+/**
+ * The AWTAccessor utility class.
+ * The main purpose of this class is to enable accessing
+ * private and package-private fields of classes from
+ * different classes/packages. See sun.misc.SharedSecretes
+ * for another example.
+ */
+public final class AWTAccessor {
+
+ private static final Unsafe unsafe = Unsafe.getUnsafe();
+
+ /*
+ * We don't need any objects of this class.
+ * It's rather a collection of static methods
+ * and interfaces.
+ */
+ private AWTAccessor() {
+ }
+
+ /*
+ * An interface of accessor for the java.awt.Component class.
+ */
+ public interface ComponentAccessor {
+ /*
+ * Returns the acc this component was constructed with.
+ */
+ AccessControlContext getAccessControlContext(Component comp);
+ }
+
+ /*
+ * An accessor for the AWTEvent class.
+ */
+ public interface AWTEventAccessor {
+ /**
+ * Sets the flag on this AWTEvent indicating that it was
+ * generated by the system.
+ */
+ void setSystemGenerated(AWTEvent ev);
+
+ /**
+ * Indicates whether this AWTEvent was generated by the system.
+ */
+ boolean isSystemGenerated(AWTEvent ev);
+
+
+ /*
+ * Returns the acc this event was constructed with.
+ */
+ AccessControlContext getAccessControlContext(AWTEvent ev);
+
+ }
+
+ /*
+ * Accessor instances are initialized in the static initializers of
+ * corresponding AWT classes by using setters defined below.
+ */
+ private static ComponentAccessor componentAccessor;
+ private static AWTEventAccessor awtEventAccessor;
+
+ /*
+ * Set an accessor object for the java.awt.Component class.
+ */
+ public static void setComponentAccessor(ComponentAccessor ca) {
+ componentAccessor = ca;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.Component class.
+ */
+ public static ComponentAccessor getComponentAccessor() {
+ if (componentAccessor == null) {
+ unsafe.ensureClassInitialized(Component.class);
+ }
+
+ return componentAccessor;
+ }
+
+ /*
+ * Set an accessor object for the java.awt.AWTEvent class.
+ */
+ public static void setAWTEventAccessor(AWTEventAccessor aea) {
+ awtEventAccessor = aea;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.AWTEvent class.
+ */
+ public static AWTEventAccessor getAWTEventAccessor() {
+ if (awtEventAccessor == null) {
+ unsafe.ensureClassInitialized(AWTEvent.class);
+ }
+ return awtEventAccessor;
+ }
+}
--- jdk/src/share/classes/sun/font/FileFont.java 2011-01-20 18:54:25.000000000 -0500
+++ jdk/src/share/classes/sun/font/FileFont.java 2011-02-17 18:15:35.000000000 -0500
@@ -48,6 +48,9 @@ import java.nio.channels.ClosedChannelEx
import java.util.HashSet;
import java.util.HashMap;
import java.awt.Font;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
public abstract class FileFont extends PhysicalFont {
@@ -284,4 +287,49 @@ public abstract class FileFont extends P
});
}
}
+
+ protected String getPublicFileName() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null) {
+ return platName;
+ }
+ boolean canReadProperty = true;
+
+ try {
+ sm.checkPropertyAccess("java.io.tmpdir");
+ } catch (SecurityException e) {
+ canReadProperty = false;
+ }
+
+ if (canReadProperty) {
+ return platName;
+ }
+
+ final File f = new File(platName);
+
+ Boolean isTmpFile = Boolean.FALSE;
+ try {
+ isTmpFile = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<Boolean>() {
+ public Boolean run() {
+ File tmp = new File(System.getProperty("java.io.tmpdir"));
+ try {
+ String tpath = tmp.getCanonicalPath();
+ String fpath = f.getCanonicalPath();
+
+ return (fpath == null) || fpath.startsWith(tpath);
+ } catch (IOException e) {
+ return Boolean.TRUE;
+ }
+ }
+ }
+ );
+ } catch (PrivilegedActionException e) {
+ // unable to verify whether value of java.io.tempdir will be
+ // exposed, so return only a name of the font file.
+ isTmpFile = Boolean.TRUE;
+ }
+
+ return isTmpFile ? "temp file" : platName;
+ }
}
--- jdk/src/share/classes/sun/font/TrueTypeFont.java 2011-01-20 18:54:25.000000000 -0500
+++ jdk/src/share/classes/sun/font/TrueTypeFont.java 2011-02-17 18:15:35.000000000 -0500
@@ -504,7 +504,8 @@ public class TrueTypeFont extends FileFo
break;
default:
- throw new FontFormatException("Unsupported sfnt " + platName);
+ throw new FontFormatException("Unsupported sfnt " +
+ getPublicFileName());
}
/* Now have the offset of this TT font (possibly within a TTC)
@@ -1369,6 +1370,6 @@ public class TrueTypeFont extends FileFo
public String toString() {
return "** TrueType Font: Family="+familyName+ " Name="+fullName+
- " style="+style+" fileName="+platName;
+ " style="+style+" fileName="+getPublicFileName();
}
}
--- jdk/src/share/classes/sun/font/Type1Font.java 2011-01-20 18:54:25.000000000 -0500
+++ jdk/src/share/classes/sun/font/Type1Font.java 2011-02-17 18:15:35.000000000 -0500
@@ -677,7 +677,7 @@ public class Type1Font extends FileFont
public String toString() {
return "** Type1 Font: Family="+familyName+ " Name="+fullName+
- " style="+style+" fileName="+platName;
+ " style="+style+" fileName="+getPublicFileName();
}
}
--- jdk/src/share/classes/sun/misc/SharedSecrets.java 2011-01-20 18:54:27.000000000 -0500
+++ jdk/src/share/classes/sun/misc/SharedSecrets.java 2011-02-17 18:15:35.000000000 -0500
@@ -31,6 +31,8 @@ import java.io.File;
import java.io.FileDescriptor;
import java.security.ProtectionDomain;
+import java.security.AccessController;
+
/** A repository of "shared secrets", which are a mechanism for
calling implementation-private methods in another package without
using reflection. A package-private class implements a public
@@ -49,6 +51,7 @@ public class SharedSecrets {
private static JavaNetAccess javaNetAccess;
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
+ private static JavaSecurityAccess javaSecurityAccess;
public static JavaUtilJarAccess javaUtilJarAccess() {
if (javaUtilJarAccess == null) {
@@ -124,4 +127,15 @@ public class SharedSecrets {
return javaSecurityProtectionDomainAccess;
}
+
+ public static void setJavaSecurityAccess(JavaSecurityAccess jsa) {
+ javaSecurityAccess = jsa;
+ }
+
+ public static JavaSecurityAccess getJavaSecurityAccess() {
+ if (javaSecurityAccess == null) {
+ unsafe.ensureClassInitialized(AccessController.class);
+ }
+ return javaSecurityAccess;
+ }
}
--- jdk/src/share/classes/sun/misc/JavaSecurityAccess.java 2011-02-17 18:15:35.000000000 -0500
+++ jdk/src/share/classes/sun/misc/JavaSecurityAccess.java 2011-02-17 18:15:35.000000000 -0500
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.misc;
+
+import java.security.AccessControlContext;
+import java.security.PrivilegedAction;
+
+public interface JavaSecurityAccess {
+
+ <T> T doIntersectionPrivilege(PrivilegedAction<T> action,
+ AccessControlContext stack,
+ AccessControlContext context);
+
+ <T> T doIntersectionPrivilege(PrivilegedAction<T> action,
+ AccessControlContext context);
+
+}
--- jdk/src/share/classes/sun/misc/FloatingDecimal.java 2011-01-20 18:54:27.000000000 -0500
+++ jdk/src/share/classes/sun/misc/FloatingDecimal.java 2011-02-17 18:17:01.000000000 -0500
@@ -1547,7 +1547,7 @@ public class FloatingDecimal{
if ( (cmpResult = bigB.cmp( bigD ) ) > 0 ){
overvalue = true; // our candidate is too big.
diff = bigB.sub( bigD );
- if ( (bigIntNBits == 1) && (bigIntExp > -expBias) ){
+ if ( (bigIntNBits == 1) && (bigIntExp > -expBias+1) ){
// candidate is a normalized exact power of 2 and
// is too big. We will be subtracting.
// For our purposes, ulp is the ulp of the
--- jdk/src/share/classes/sun/net/ResourceManager.java 2011-02-17 18:15:35.000000000 -0500
+++ jdk/src/share/classes/sun/net/ResourceManager.java 2011-02-17 18:15:35.000000000 -0500
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.net;
+
+import java.net.SocketException;
+import java.util.concurrent.atomic.AtomicInteger;
+import sun.security.action.GetPropertyAction;
+
+/**
+ * Manages count of total number of UDP sockets and ensures
+ * that exception is thrown if we try to create more than the
+ * configured limit.
+ *
+ * This functionality could be put in NetHooks some time in future.
+ */
+
+public class ResourceManager {
+
+ /* default maximum number of udp sockets per VM
+ * when a security manager is enabled.
+ * The default is 1024 which is high enough to be useful
+ * but low enough to be well below the maximum number
+ * of port numbers actually available on all OSes for
+ * such sockets (5000 on some versions of windows)
+ */
+
+ private static final int DEFAULT_MAX_SOCKETS = 1024;
+ private static final int maxSockets;
+ private static final AtomicInteger numSockets;
+
+ static {
+ String prop = java.security.AccessController.doPrivileged(
+ new GetPropertyAction("sun.net.maxDatagramSockets")
+ );
+ int defmax = DEFAULT_MAX_SOCKETS;
+ try {
+ if (prop != null) {
+ defmax = Integer.parseInt(prop);
+ }
+ } catch (NumberFormatException e) {}
+ maxSockets = defmax;
+ numSockets = new AtomicInteger(0);
+ }
+
+ public static void beforeUdpCreate() throws SocketException {
+ if (System.getSecurityManager() != null) {
+ if (numSockets.incrementAndGet() > maxSockets) {
+ numSockets.decrementAndGet();
+ throw new SocketException("maximum number of DatagramSockets reached");
+ }
+ }
+ }
+
+ public static void afterUdpClose() {
+ if (System.getSecurityManager() != null) {
+ numSockets.decrementAndGet();
+ }
+ }
+}
--- jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java 2011-01-20 18:54:27.000000000 -0500
+++ jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java 2011-02-17 18:15:35.000000000 -0500
@@ -32,6 +32,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.lang.ref.SoftReference;
+import sun.net.ResourceManager;
/**
@@ -98,9 +99,15 @@ class DatagramChannelImpl
throws IOException
{
super(sp);
- this.fd = Net.socket(false);
- this.fdVal = IOUtil.fdVal(fd);
- this.state = ST_UNCONNECTED;
+ ResourceManager.beforeUdpCreate();
+ try {
+ this.fd = Net.socket(false);
+ this.fdVal = IOUtil.fdVal(fd);
+ this.state = ST_UNCONNECTED;
+ } catch (IOException ioe) {
+ ResourceManager.afterUdpClose();
+ throw ioe;
+ }
}
public DatagramChannelImpl(SelectorProvider sp, FileDescriptor fd)
@@ -587,6 +594,7 @@ class DatagramChannelImpl
protected void implCloseSelectableChannel() throws IOException {
synchronized (stateLock) {
nd.preClose(fd);
+ ResourceManager.afterUdpClose();
long th;
if ((th = readerThread) != 0)
NativeThread.signal(th);
--- jdk/src/share/classes/sun/nio/ch/Net.java 2011-01-20 18:54:27.000000000 -0500
+++ jdk/src/share/classes/sun/nio/ch/Net.java 2011-02-17 18:15:35.000000000 -0500
@@ -111,7 +111,7 @@ class Net {
// -- Socket operations --
- static FileDescriptor socket(boolean stream) {
+ static FileDescriptor socket(boolean stream) throws IOException {
return IOUtil.newFD(socket0(stream, false));
}
--- jdk/src/solaris/bin/java_md.c 2011-01-20 18:54:40.000000000 -0500
+++ jdk/src/solaris/bin/java_md.c 2011-02-17 18:15:35.000000000 -0500
@@ -484,7 +484,7 @@ CreateExecutionEnvironment(int *_argcp,
* LD_LIBRARY_PATH. Note that this prevents any possible infinite
* loop of execv() because we test for the prefix, above.
*/
- if (runpath != 0) {
+ if (runpath != NULL && (runpath[0] != '\0')) {
strcat(new_runpath, ":");
strcat(new_runpath, runpath);
}
--- jdk/test/java/lang/Double/ParseDouble.java 2011-01-20 18:54:49.000000000 -0500
+++ jdk/test/java/lang/Double/ParseDouble.java 2011-02-17 18:17:01.000000000 -0500
@@ -23,11 +23,12 @@
/*
* @test
- * @bug 4160406 4705734 4707389 4826774 4895911
+ * @bug 4160406 4705734 4707389 4826774 4895911 4421494
* @summary Test for Double.parseDouble method and acceptance regex
*/
import java.util.regex.*;
+import java.math.BigDecimal;
public class ParseDouble {
@@ -416,7 +417,15 @@ public class ParseDouble {
"0x00100p1",
"0x00.100p1",
- "0x001.100p1"
+ "0x001.100p1",
+
+ // Limits
+
+ "1.7976931348623157E308", // Double.MAX_VALUE
+ "4.9e-324", // Double.MIN_VALUE
+ "2.2250738585072014e-308", // Double.MIN_NORMAL
+
+ "2.2250738585072012e-308", // near Double.MIN_NORMAL
};
static String paddedBadStrings[];
@@ -546,6 +555,42 @@ public class ParseDouble {
}
+ /**
+ * For each subnormal power of two, test at boundaries of
+ * region that should convert to that value.
+ */
+ private static void testSubnormalPowers() {
+ BigDecimal TWO = BigDecimal.valueOf(2);
+ // An ulp is the same for all subnormal values
+ BigDecimal ulp_BD = new BigDecimal(Double.MIN_VALUE);
+
+ System.out.println("Testing subnormal powers of two.");
+ for(int i = -1074; i <= -1022; i++) {
+ double d = Math.scalb(1.0, i);
+
+ /*
+ * The region [d - ulp/2, d + ulp/2] should round to d.
+ */
+ BigDecimal d_BD = new BigDecimal(d);
+
+ BigDecimal lowerBound = d_BD.subtract(ulp_BD.divide(TWO));
+ BigDecimal upperBound = d_BD.add(ulp_BD.divide(TWO));
+
+ double convertedLowerBound = Double.parseDouble(lowerBound.toString());
+ double convertedUpperBound = Double.parseDouble(upperBound.toString());
+
+ if (convertedLowerBound != d) {
+ System.out.printf("Exponent %d, unexpected lower bound converted to %a, not %a.%n",
+ i, convertedLowerBound, d);
+ }
+
+ if (convertedUpperBound != d) {
+ System.out.printf("Exponent %d, unexpected upper bound converted to %a, not %a.%n",
+ i, convertedUpperBound, d);
+ }
+ }
+ }
+
public static void main(String[] args) throws Exception {
rudimentaryTest();
@@ -558,5 +603,7 @@ public class ParseDouble {
testRegex(paddedGoodStrings, false);
testRegex(badStrings, true);
testRegex(paddedBadStrings, true);
+
+ testSubnormalPowers();
}
}
|