equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2004, 2017, 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 |
188 try { |
188 try { |
189 Class<?> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader); |
189 Class<?> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader); |
190 if (!type.isAssignableFrom(providerClass)) { |
190 if (!type.isAssignableFrom(providerClass)) { |
191 throw new ClassCastException(className + " cannot be cast to " + type.getName()); |
191 throw new ClassCastException(className + " cannot be cast to " + type.getName()); |
192 } |
192 } |
193 Object instance = providerClass.newInstance(); |
193 Object instance = providerClass.getConstructor().newInstance(); |
194 final ClassLoader clD = cl; |
194 final ClassLoader clD = cl; |
195 dPrint(()->"created new instance of " + providerClass + |
195 dPrint(()->"created new instance of " + providerClass + |
196 " using ClassLoader: " + clD); |
196 " using ClassLoader: " + clD); |
197 return type.cast(instance); |
197 return type.cast(instance); |
198 } |
198 } |