1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, 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 |
61 |
61 |
62 try { |
62 try { |
63 ClassLoader cl = SecureLoader.getClassClassLoader(beanClass); |
63 ClassLoader cl = SecureLoader.getClassClassLoader(beanClass); |
64 if(cl==null) return null; // how do I inject classes to this "null" class loader? for now, back off. |
64 if(cl==null) return null; // how do I inject classes to this "null" class loader? for now, back off. |
65 |
65 |
66 Class c = null; |
66 Class c = Injector.find(cl,newClassName); |
67 synchronized (AccessorInjector.class) { |
67 if (c==null) { |
68 c = Injector.find(cl,newClassName); |
68 byte[] image = tailor(templateClassName,newClassName,replacements); |
69 if(c==null) { |
69 if (image==null) { |
70 byte[] image = tailor(templateClassName,newClassName,replacements); |
70 return null; |
71 // try { |
71 } |
72 // new FileOutputStream("debug.class").write(image); |
72 c = Injector.inject(cl,newClassName,image); |
73 // } catch (IOException e) { |
73 if (c == null) { |
74 // e.printStackTrace(); |
74 Injector.find(cl, newClassName); |
75 // } |
|
76 if(image==null) |
|
77 return null; |
|
78 c = Injector.inject(cl,newClassName,image); |
|
79 } |
75 } |
80 } |
76 } |
81 return c; |
77 return c; |
82 } catch(SecurityException e) { |
78 } catch(SecurityException e) { |
83 // we don't have enough permission to do this |
79 // we don't have enough permission to do this |