1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
34 |
34 |
35 import javax.xml.bind.JAXBContext; |
35 import javax.xml.bind.JAXBContext; |
36 |
36 |
37 import com.sun.istack.internal.tools.MaskingClassLoader; |
37 import com.sun.istack.internal.tools.MaskingClassLoader; |
38 import com.sun.istack.internal.tools.ParallelWorldClassLoader; |
38 import com.sun.istack.internal.tools.ParallelWorldClassLoader; |
39 import com.sun.tools.internal.xjc.SecureLoader; |
|
40 |
39 |
41 /** |
40 /** |
42 * Creates a class loader configured to run XJC 1.0/2.0 safely without |
41 * Creates a class loader configured to run XJC 1.0/2.0 safely without |
43 * interference with JAXB 2.0 API in Mustang. |
42 * interference with JAXB 2.0 API in Mustang. |
44 * |
43 * |
60 |
59 |
61 if (SecureLoader.getClassClassLoader(JAXBContext.class) == null) { |
60 if (SecureLoader.getClassClassLoader(JAXBContext.class) == null) { |
62 // JAXB API is loaded from the bootstrap. We need to override one with ours |
61 // JAXB API is loaded from the bootstrap. We need to override one with ours |
63 mustang = true; |
62 mustang = true; |
64 |
63 |
65 List mask = new ArrayList(Arrays.asList(maskedPackages)); |
64 List<String> mask = new ArrayList<String>(Arrays.asList(maskedPackages)); |
66 mask.add("javax.xml.bind."); |
65 mask.add("javax.xml.bind."); |
67 |
66 |
68 cl = new MaskingClassLoader(cl,mask); |
67 cl = new MaskingClassLoader(cl,mask); |
69 |
68 |
70 URL apiUrl = cl.getResource("javax/xml/bind/JAXBPermission.class"); |
69 URL apiUrl = cl.getResource("javax/xml/bind/JAXBPermission.class"); |
78 // and then isolate XJC1 in a child class loader, |
77 // and then isolate XJC1 in a child class loader, |
79 // then use a MaskingClassLoader |
78 // then use a MaskingClassLoader |
80 // so that the XJC2 classes in the parent class loader |
79 // so that the XJC2 classes in the parent class loader |
81 // won't interfere with loading XJC1 classes in a child class loader |
80 // won't interfere with loading XJC1 classes in a child class loader |
82 |
81 |
83 if (v.equals("1.0")) { |
82 if ("1.0".equals(v)) { |
84 if(!mustang) |
83 if(!mustang) |
85 // if we haven't used Masking ClassLoader, do so now. |
84 // if we haven't used Masking ClassLoader, do so now. |
86 cl = new MaskingClassLoader(cl,toolPackages); |
85 cl = new MaskingClassLoader(cl,toolPackages); |
87 cl = new ParallelWorldClassLoader(cl,"1.0/"); |
86 cl = new ParallelWorldClassLoader(cl,"1.0/"); |
88 } else { |
87 } else { |