author | martin |
Tue, 15 Sep 2015 21:56:04 -0700 | |
changeset 32649 | 2ee9017c7597 |
parent 17487 | 77566e5979d1 |
permissions | -rw-r--r-- |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
1 |
/* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
4 |
* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
8 |
* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
13 |
* accompanied this code). |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
14 |
* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
18 |
* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
21 |
* questions. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
22 |
*/ |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
23 |
import java.util.MissingResourceException; |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
24 |
import java.util.logging.Logger; |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
25 |
|
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
26 |
/* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
27 |
* This class is loaded onto the call stack by LoadItUp2Invoker from a separate |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
28 |
* classloader. LoadItUp2Invoker was loaded by a class loader that does have |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
29 |
* access to the bundle, but the class loader used to load this class does not. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
30 |
* Thus the logging code should not be able to see the resource bundle unless |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
31 |
* it has more than a single level stack crawl, which is not allowed. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
32 |
* |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
33 |
* @author Jim Gish |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
34 |
*/ |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
35 |
public class LoadItUp2 { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
36 |
|
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
17487
diff
changeset
|
37 |
private static final boolean DEBUG = false; |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
38 |
|
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
39 |
public Boolean test(String rbName) throws Exception { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
40 |
// we should not be able to find the resource in this directory via |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
41 |
// getLogger calls. The only way that would be possible given this setup |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
42 |
// is that if Logger.getLogger searched up the call stack |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
43 |
return lookupBundle(rbName); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
44 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
45 |
|
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
46 |
private boolean lookupBundle(String rbName) { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
47 |
// See if Logger.getLogger can find the resource in this directory |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
48 |
try { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
49 |
Logger aLogger = Logger.getLogger("NestedLogger2", rbName); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
50 |
} catch (MissingResourceException re) { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
51 |
if (DEBUG) { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
52 |
System.out.println( |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
53 |
"As expected, LoadItUp2.lookupBundle() did not find the bundle " |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
54 |
+ rbName); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
55 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
56 |
return false; |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
57 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
58 |
System.out.println("FAILED: LoadItUp2.lookupBundle() found the bundle " |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
59 |
+ rbName + " using a stack search."); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
60 |
return true; |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
61 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
diff
changeset
|
62 |
} |