1 /*
2 * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
2386 if (opcode == JVM_OPC_invokestatic ||
2387 opcode == JVM_OPC_invokedynamic) {
2388 item = 0;
2389 } else if (opcode == JVM_OPC_invokeinit) {
2390 fullinfo_type init_type = this_idata->operand2.fi;
2391 fullinfo_type object_type = stack_extra_info[0];
2392 context->swap_table[0] = object_type; /* save value */
2393 if (GET_ITEM_TYPE(stack_extra_info[0]) == ITEM_NewObject) {
2394 /* We better be calling the appropriate init. Find the
2395 * inumber of the "JVM_OPC_new" instruction", and figure
2396 * out what the type really is.
2397 */
2398 unsigned int new_inumber = GET_EXTRA_INFO(stack_extra_info[0]);
2399 fullinfo_type target_type = idata[new_inumber].operand2.fi;
2400 context->swap_table[1] = target_type;
2401
2402 if (target_type != init_type) {
2403 CCerror(context, "Call to wrong initialization method");
2404 }
2405 if (this_idata->protected
2406 && context->major_version > LDC_CLASS_MAJOR_VERSION
2407 && !isAssignableTo(context, object_type,
2408 context->currentclass_info)) {
2409 CCerror(context, "Bad access to protected data");
2410 }
2411 } else {
2412 /* We better be calling super() or this(). */
2413 if (init_type != context->superclass_info &&
2414 init_type != context->currentclass_info) {
2415 CCerror(context, "Call to wrong initialization method");
2416 }
2417 context->swap_table[1] = context->currentclass_info;
2418 }
2419 item = 1;
2420 } else {
2421 fullinfo_type target_type = this_idata->operand2.fi;
2422 fullinfo_type object_type = stack_extra_info[0];
2423 if (!isAssignableTo(context, object_type, target_type)){
2424 CCerror(context,
2425 "Incompatible object argument for function call");
2426 }
|
1 /*
2 * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
2386 if (opcode == JVM_OPC_invokestatic ||
2387 opcode == JVM_OPC_invokedynamic) {
2388 item = 0;
2389 } else if (opcode == JVM_OPC_invokeinit) {
2390 fullinfo_type init_type = this_idata->operand2.fi;
2391 fullinfo_type object_type = stack_extra_info[0];
2392 context->swap_table[0] = object_type; /* save value */
2393 if (GET_ITEM_TYPE(stack_extra_info[0]) == ITEM_NewObject) {
2394 /* We better be calling the appropriate init. Find the
2395 * inumber of the "JVM_OPC_new" instruction", and figure
2396 * out what the type really is.
2397 */
2398 unsigned int new_inumber = GET_EXTRA_INFO(stack_extra_info[0]);
2399 fullinfo_type target_type = idata[new_inumber].operand2.fi;
2400 context->swap_table[1] = target_type;
2401
2402 if (target_type != init_type) {
2403 CCerror(context, "Call to wrong initialization method");
2404 }
2405 if (this_idata->protected
2406 && !isAssignableTo(context, object_type,
2407 context->currentclass_info)) {
2408 CCerror(context, "Bad access to protected data");
2409 }
2410 } else {
2411 /* We better be calling super() or this(). */
2412 if (init_type != context->superclass_info &&
2413 init_type != context->currentclass_info) {
2414 CCerror(context, "Call to wrong initialization method");
2415 }
2416 context->swap_table[1] = context->currentclass_info;
2417 }
2418 item = 1;
2419 } else {
2420 fullinfo_type target_type = this_idata->operand2.fi;
2421 fullinfo_type object_type = stack_extra_info[0];
2422 if (!isAssignableTo(context, object_type, target_type)){
2423 CCerror(context,
2424 "Incompatible object argument for function call");
2425 }
|