test/compiler/jsr292/methodHandleExceptions/ByteClassLoader.java

Fri, 27 Sep 2013 13:36:25 -0400

author
drchase
date
Fri, 27 Sep 2013 13:36:25 -0400
changeset 5800
dc261f466b6d
child 6134
9d15b81d5d1b
permissions
-rw-r--r--

8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
Summary: Copied null-checks from templateInterpreter_CPU into methodHandles_CPU
Reviewed-by: jrose, twisti

drchase@5800 1 /*
drchase@5800 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
drchase@5800 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
drchase@5800 4 *
drchase@5800 5 * This code is free software; you can redistribute it and/or modify it
drchase@5800 6 * under the terms of the GNU General Public License version 2 only, as
drchase@5800 7 * published by the Free Software Foundation.
drchase@5800 8 *
drchase@5800 9 * This code is distributed in the hope that it will be useful, but WITHOUT
drchase@5800 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
drchase@5800 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
drchase@5800 12 * version 2 for more details (a copy is included in the LICENSE file that
drchase@5800 13 * accompanied this code).
drchase@5800 14 *
drchase@5800 15 * You should have received a copy of the GNU General Public License version
drchase@5800 16 * 2 along with this work; if not, write to the Free Software Foundation,
drchase@5800 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
drchase@5800 18 *
drchase@5800 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
drchase@5800 20 * or visit www.oracle.com if you need additional information or have any
drchase@5800 21 * questions.
drchase@5800 22 *
drchase@5800 23 */
drchase@5800 24
drchase@5800 25 /**
drchase@5800 26 * A minimal classloader for loading bytecodes that could not result from
drchase@5800 27 * properly compiled Java.
drchase@5800 28 *
drchase@5800 29 * @author dr2chase
drchase@5800 30 */
drchase@5800 31 public class ByteClassLoader extends ClassLoader {
drchase@5800 32 /**
drchase@5800 33 * (pre)load class name using classData for the definition.
drchase@5800 34 *
drchase@5800 35 * @param name
drchase@5800 36 * @param classData
drchase@5800 37 * @return
drchase@5800 38 */
drchase@5800 39 public Class<?> loadBytes(String name, byte[] classData) {
drchase@5800 40 Class<?> clazz = defineClass(name, classData, 0, classData.length);
drchase@5800 41 resolveClass(clazz);
drchase@5800 42 return clazz;
drchase@5800 43 }
drchase@5800 44 }

mercurial