From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21803 invoked by alias); 20 Sep 2004 20:19:58 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 21785 invoked from network); 20 Sep 2004 20:19:55 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 20 Sep 2004 20:19:55 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i8KKJtwV029948 for ; Mon, 20 Sep 2004 16:19:55 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i8KKJor27609; Mon, 20 Sep 2004 16:19:50 -0400 Received: from touchme.toronto.redhat.com (IDENT:postfix@touchme.toronto.redhat.com [172.16.14.9]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id i8KKJo1l031086; Mon, 20 Sep 2004 16:19:50 -0400 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id A8427800143; Mon, 20 Sep 2004 16:19:49 -0400 (EDT) Message-ID: <414F3B65.3040908@redhat.com> Date: Mon, 20 Sep 2004 20:19:00 -0000 From: Jeff Johnston User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 MIME-Version: 1.0 To: Jim Blandy Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA]: Java Inferior Call Take 3 References: <40A9264C.4060404@redhat.com> <20040617030603.GC23443@nevyn.them.org> <40D20494.2020608@redhat.com> <20040619235857.GA18759@nevyn.them.org> <16598.64375.217285.743094@cuddles.cambridge.redhat.com> <16601.25623.949217.642524@cuddles.cambridge.redhat.com> <20040623134742.GA24612@nevyn.them.org> <40D9FC3B.3030700@redhat.com> <20040623230138.GA6426@nevyn.them.org> <40EB1DDD.4070603@redhat.com> <20040816203502.GB14885@nevyn.them.org> <412B8EA3.3090406@redhat.com> <4140EA35.9080009@redhat.com> <4148C8F1.6070007@redhat.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------090507020704070403070102" X-SW-Source: 2004-09/txt/msg00323.txt.bz2 This is a multi-part message in MIME format. --------------090507020704070403070102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1876 Jim Blandy wrote: > Jeff Johnston writes: > >>Ok now? >> >>Retested on x86-linux with up to date compiler with needed gcj >>fixes. > > > Yep, looks great. Thanks! > > Thanks. With that, all parts have been approved and checked in. I have included the final patches and ChangeLogs that were checked in. -- Jeff J. gdb/ChangeLog: 2004-09-20 Jeff Johnston * dwarf2read.c (typename_concat): Change prototype to accept obstack and dwarf2_cu struct pointer as arguments. Change function to use obstack if provided and use dwarf2_cu to determine language-specific separator. (partial_die_parent_scope): Change comment to include java. Use new version of typename_concat instead of obconcat. (partial_die_full_name): Use typename_concat. (read_namespace): Ditto. (read_enumeration_type): Use typename_concat instead of obconcat. (new_symbol): Ditto. (add_partial_symbol): Enhance tests for C++ to also test for Java. (guess_structure_name): Ditto. (read_subroutine_type): Ditto. (read_structure_type): Ditto. (is_vtable_name): Add Java support. (determine_class_name): Switch to new typename_concat call. (determine_prefix): Switch to new typename_concat call. * jv-exp.y (FuncStart): New pattern. (MethodInvocation): Add support for simple function calls. Change warning message for other forms of inferior call currently not supported. * valarith.c (value_subscript): Treat an array with upper-bound of -1 as unknown size. gdb/testsuite/ChangeLog: 2004-09-20 Jeff Johnston * gdb.java/jprint.exp: New test case for java inferior call. * gdb.java/jprint.java: Ditto. --------------090507020704070403070102 Content-Type: text/plain; name="java-call-final.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="java-call-final.patch" Content-length: 16727 Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.160 diff -u -p -r1.160 dwarf2read.c --- dwarf2read.c 1 Sep 2004 04:19:21 -0000 1.160 +++ dwarf2read.c 20 Sep 2004 20:02:11 -0000 @@ -791,7 +791,8 @@ static void read_type_die (struct die_in static char *determine_prefix (struct die_info *die, struct dwarf2_cu *); -static char *typename_concat (const char *prefix, const char *suffix); +static char *typename_concat (struct obstack *, const char *prefix, const char *suffix, + struct dwarf2_cu *); static void read_typedef (struct die_info *, struct dwarf2_cu *); @@ -1511,7 +1512,8 @@ scan_partial_symbols (struct partial_die /* Functions used to compute the fully scoped name of a partial DIE. Normally, this is simple. For C++, the parent DIE's fully scoped - name is concatenated with "::" and the partial DIE's name. + name is concatenated with "::" and the partial DIE's name. For + Java, the same thing occurs except that "." is used instead of "::". Enumerators are an exception; they use the scope of their parent enumeration type, i.e. the name of the enumeration type is not prepended to the enumerator. @@ -1566,8 +1568,8 @@ partial_die_parent_scope (struct partial if (grandparent_scope == NULL) parent->scope = parent->name; else - parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope, - "::", parent->name); + parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope, + parent->name, cu); } else if (parent->tag == DW_TAG_enumeration_type) /* Enumerators should not get the name of the enumeration as a prefix. */ @@ -1599,7 +1601,7 @@ partial_die_full_name (struct partial_di if (parent_scope == NULL) return NULL; else - return concat (parent_scope, "::", pdi->name, NULL); + return typename_concat (NULL, parent_scope, pdi->name, cu); } static void @@ -1717,14 +1719,16 @@ add_partial_symbol (struct partial_die_i return; add_psymbol_to_list (actual_name, strlen (actual_name), STRUCT_DOMAIN, LOC_TYPEDEF, - cu->language == language_cplus + (cu->language == language_cplus + || cu->language == language_java) ? &objfile->global_psymbols : &objfile->static_psymbols, 0, (CORE_ADDR) 0, cu->language, objfile); - if (cu->language == language_cplus) + if (cu->language == language_cplus + || cu->language == language_java) { - /* For C++, these implicitly act as typedefs as well. */ + /* For C++ and Java, these implicitly act as typedefs as well. */ add_psymbol_to_list (actual_name, strlen (actual_name), VAR_DOMAIN, LOC_TYPEDEF, &objfile->global_psymbols, @@ -1734,7 +1738,8 @@ add_partial_symbol (struct partial_die_i case DW_TAG_enumerator: add_psymbol_to_list (actual_name, strlen (actual_name), VAR_DOMAIN, LOC_CONST, - cu->language == language_cplus + (cu->language == language_cplus + || cu->language == language_java) ? &objfile->global_psymbols : &objfile->static_psymbols, 0, (CORE_ADDR) 0, cu->language, objfile); @@ -1814,7 +1819,8 @@ static void guess_structure_name (struct partial_die_info *struct_pdi, struct dwarf2_cu *cu) { - if (cu->language == language_cplus + if ((cu->language == language_cplus + || cu->language == language_java) && cu->has_namespace_info == 0 && struct_pdi->has_children) { @@ -2474,7 +2480,8 @@ read_func_scope (struct die_info *die, s if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu)) return; - if (cu->language == language_cplus) + if (cu->language == language_cplus + || cu->language == language_java) { struct die_info *spec_die = die_specification (die, cu); @@ -3272,10 +3279,13 @@ static int is_vtable_name (const char *name, struct dwarf2_cu *cu) { static const char vptr[] = "_vptr"; + static const char vtable[] = "vtable"; - /* C++ and some implementations of Java use this name. */ - if (strncmp (name, vptr, sizeof (vptr) - 1) == 0 - && is_cplus_marker (name[sizeof (vptr) - 1])) + /* Look for the C++ and Java forms of the vtable. */ + if ((cu->language == language_java + && strncmp (name, vtable, sizeof (vtable) - 1) == 0) + || (strncmp (name, vptr, sizeof (vptr) - 1) == 0 + && is_cplus_marker (name[sizeof (vptr) - 1]))) return 1; return 0; @@ -3316,7 +3326,8 @@ read_structure_type (struct die_info *di attr = dwarf2_attr (die, DW_AT_name, cu); if (attr && DW_STRING (attr)) { - if (cu->language == language_cplus) + if (cu->language == language_cplus + || cu->language == language_java) { char *new_prefix = determine_class_name (die, cu); TYPE_TAG_NAME (type) = obsavestring (new_prefix, @@ -3518,11 +3529,9 @@ read_enumeration_type (struct die_info * if (processing_has_namespace_info) { - TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack, - processing_current_prefix, - processing_current_prefix[0] == '\0' - ? "" : "::", - name); + TYPE_TAG_NAME (type) = typename_concat (&objfile->objfile_obstack, + processing_current_prefix, + name, cu); } else { @@ -3546,7 +3555,7 @@ read_enumeration_type (struct die_info * } /* Determine the name of the type represented by DIE, which should be - a named C++ compound type. Return the name in question; the caller + a named C++ or Java compound type. Return the name in question; the caller is responsible for xfree()'ing it. */ static char * @@ -3593,8 +3602,9 @@ determine_class_name (struct die_info *d if (new_prefix == NULL) { const char *name = dwarf2_name (die, cu); - new_prefix = typename_concat (processing_current_prefix, - name ? name : "<>"); + new_prefix = typename_concat (NULL, processing_current_prefix, + name ? name : "<>", + cu); } if (back_to != NULL) @@ -3861,6 +3871,7 @@ read_namespace (struct die_info *die, st const char *name; int is_anonymous; struct die_info *current_die; + struct cleanup *back_to = make_cleanup (null_cleanup, 0); name = namespace_name (die, &is_anonymous, cu); @@ -3872,14 +3883,8 @@ read_namespace (struct die_info *die, st } else { - /* We need temp_name around because processing_current_prefix - is a const char *. */ - char *temp_name = alloca (strlen (previous_prefix) - + 2 + strlen(name) + 1); - strcpy (temp_name, previous_prefix); - strcat (temp_name, "::"); - strcat (temp_name, name); - + char *temp_name = typename_concat (NULL, previous_prefix, name, cu); + make_cleanup (xfree, temp_name); processing_current_prefix = temp_name; } @@ -3919,6 +3924,7 @@ read_namespace (struct die_info *die, st } processing_current_prefix = previous_prefix; + do_cleanups (back_to); } /* Return the name of the namespace represented by DIE. Set @@ -4166,10 +4172,11 @@ read_subroutine_type (struct die_info *d type = die_type (die, cu); ftype = lookup_function_type (type); - /* All functions in C++ have prototypes. */ + /* All functions in C++ and Java have prototypes. */ attr = dwarf2_attr (die, DW_AT_prototyped, cu); if ((attr && (DW_UNSND (attr) != 0)) - || cu->language == language_cplus) + || cu->language == language_cplus + || cu->language == language_java) TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED; if (die->child != NULL) @@ -4820,7 +4827,8 @@ load_partial_dies (bfd *abfd, char *info else if (building_psymtab) add_psymbol_to_list (part_die->name, strlen (part_die->name), VAR_DOMAIN, LOC_CONST, - cu->language == language_cplus + (cu->language == language_cplus + || cu->language == language_java) ? &cu->objfile->global_psymbols : &cu->objfile->static_psymbols, 0, (CORE_ADDR) 0, cu->language, cu->objfile); @@ -6431,7 +6439,8 @@ new_symbol (struct die_info *die, struct read_structure_type, and the correct name is saved in the type. */ - if (cu->language == language_cplus) + if (cu->language == language_cplus + || cu->language == language_java) { struct type *type = SYMBOL_TYPE (sym); @@ -6448,7 +6457,7 @@ new_symbol (struct die_info *die, struct } { - /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't + /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't really ever be static objects: otherwise, if you try to, say, break of a class's method and you're in a file which doesn't mention that class, it won't work unless @@ -6459,15 +6468,18 @@ new_symbol (struct die_info *die, struct struct pending **list_to_add; list_to_add = (cu->list_in_scope == &file_symbols - && cu->language == language_cplus + && (cu->language == language_cplus + || cu->language == language_java) ? &global_symbols : cu->list_in_scope); add_symbol_to_list (sym, list_to_add); /* The semantics of C++ state that "struct foo { ... }" also - defines a typedef for "foo". Synthesize a typedef symbol so - that "ptype foo" works as expected. */ - if (cu->language == language_cplus) + defines a typedef for "foo". A Java class declaration also + defines a typedef for the class. Synthesize a typedef symbol + so that "ptype foo" works as expected. */ + if (cu->language == language_cplus + || cu->language == language_java) { struct symbol *typedef_sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack, @@ -6487,10 +6499,9 @@ new_symbol (struct die_info *die, struct if (processing_has_namespace_info && processing_current_prefix[0] != '\0') { - SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack, - processing_current_prefix, - "::", - name); + SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack, + processing_current_prefix, + name, cu); } SYMBOL_CLASS (sym) = LOC_TYPEDEF; SYMBOL_DOMAIN (sym) = VAR_DOMAIN; @@ -6506,10 +6517,9 @@ new_symbol (struct die_info *die, struct if (processing_has_namespace_info && processing_current_prefix[0] != '\0') { - SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack, - processing_current_prefix, - "::", - name); + SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack, + processing_current_prefix, + name, cu); } attr = dwarf2_attr (die, DW_AT_const_value, cu); if (attr) @@ -6523,7 +6533,8 @@ new_symbol (struct die_info *die, struct struct pending **list_to_add; list_to_add = (cu->list_in_scope == &file_symbols - && cu->language == language_cplus + && (cu->language == language_cplus + || cu->language == language_java) ? &global_symbols : cu->list_in_scope); add_symbol_to_list (sym, list_to_add); @@ -6832,7 +6843,8 @@ determine_prefix (struct die_info *die, { struct die_info *parent; - if (cu->language != language_cplus) + if (cu->language != language_cplus + && cu->language != language_java) return NULL; parent = die->parent; @@ -6856,9 +6868,10 @@ determine_prefix (struct die_info *die, { int dummy; char *parent_prefix = determine_prefix (parent, cu); - char *retval = typename_concat (parent_prefix, + char *retval = typename_concat (NULL, parent_prefix, namespace_name (parent, &dummy, - cu)); + cu), + cu); xfree (parent_prefix); return retval; } @@ -6891,25 +6904,47 @@ determine_prefix (struct die_info *die, } } -/* Return a newly-allocated string formed by concatenating PREFIX, - "::", and SUFFIX, except that if PREFIX is NULL or the empty - string, just return a copy of SUFFIX. */ +/* Return a newly-allocated string formed by concatenating PREFIX and + SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then + simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null, + perform an obconcat, otherwise allocate storage for the result. The CU argument + is used to determine the language and hence, the appropriate separator. */ + +#define MAX_SEP_LEN 2 /* sizeof ("::") */ static char * -typename_concat (const char *prefix, const char *suffix) +typename_concat (struct obstack *obs, const char *prefix, const char *suffix, + struct dwarf2_cu *cu) { - if (prefix == NULL || prefix[0] == '\0') - return xstrdup (suffix); - else - { - char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1); + char *sep; - strcpy (retval, prefix); - strcat (retval, "::"); - strcat (retval, suffix); + if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0') + sep = ""; + else if (cu->language == language_java) + sep = "."; + else + sep = "::"; + if (obs == NULL) + { + char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1); + retval[0] = '\0'; + + if (prefix) + { + strcpy (retval, prefix); + strcat (retval, sep); + } + if (suffix) + strcat (retval, suffix); + return retval; } + else + { + /* We have an obstack. */ + return obconcat (obs, prefix, sep, suffix); + } } static struct type * Index: jv-exp.y =================================================================== RCS file: /cvs/src/src/gdb/jv-exp.y,v retrieving revision 1.18 diff -u -p -r1.18 jv-exp.y --- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18 +++ jv-exp.y 20 Sep 2004 20:02:11 -0000 @@ -446,13 +446,22 @@ FieldAccess: /*| SUPER '.' SimpleName { FIXME } */ ; +FuncStart: + Name '(' + { push_expression_name ($1); } +; + MethodInvocation: - Name '(' ArgumentList_opt ')' - { error (_("Method invocation not implemented")); } + FuncStart + { start_arglist(); } + ArgumentList_opt ')' + { write_exp_elt_opcode (OP_FUNCALL); + write_exp_elt_longcst ((LONGEST) end_arglist ()); + write_exp_elt_opcode (OP_FUNCALL); } | Primary '.' SimpleName '(' ArgumentList_opt ')' - { error (_("Method invocation not implemented")); } + { error (_("Form of method invocation not implemented")); } | SUPER '.' SimpleName '(' ArgumentList_opt ')' - { error (_("Method invocation not implemented")); } + { error (_("Form of method invocation not implemented")); } ; ArrayAccess: Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.138 diff -u -p -r1.138 symtab.c --- symtab.c 20 Sep 2004 18:31:02 -0000 1.138 +++ symtab.c 20 Sep 2004 20:02:11 -0000 @@ -998,7 +998,7 @@ lookup_symbol (const char *name, const s modified_name = name; - /* If we are using C++ language, demangle the name before doing a lookup, so + /* If we are using C++ or Java, demangle the name before doing a lookup, so we can always binary search. */ if (current_language->la_language == language_cplus) { @@ -1010,6 +1010,17 @@ lookup_symbol (const char *name, const s needtofreename = 1; } } + else if (current_language->la_language == language_java) + { + demangled_name = cplus_demangle (name, + DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA); + if (demangled_name) + { + mangled_name = name; + modified_name = demangled_name; + needtofreename = 1; + } + } if (case_sensitivity == case_sensitive_off) { Index: valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.23 diff -u -p -r1.23 valarith.c --- valarith.c 27 Jun 2004 07:57:15 -0000 1.23 +++ valarith.c 20 Sep 2004 20:02:11 -0000 @@ -202,7 +202,10 @@ value_subscript (struct value *array, st LONGEST index = value_as_long (idx); if (index >= lowerbound && index <= upperbound) return value_subscripted_rvalue (array, idx, lowerbound); - warning ("array or string index out of range"); + /* Emit warning unless we have an array of unknown size. + An array of unknown size has lowerbound 0 and upperbound -1. */ + if (upperbound > -1) + warning ("array or string index out of range"); /* fall doing C stuff */ c_style = 1; } --------------090507020704070403070102 Content-Type: text/plain; name="java-call-test-final.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="java-call-test-final.patch" Content-length: 4892 Index: gdb.java/jprint.exp =================================================================== RCS file: gdb.java/jprint.exp diff -N gdb.java/jprint.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb.java/jprint.exp 20 Sep 2004 20:03:02 -0000 @@ -0,0 +1,80 @@ +# Copyright 2004 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was written by Jeff Johnston. (jjohnstn@redhat.com) +# + +if $tracelevel then { + strace $tracelevel +} + +load_lib "java.exp" + +set testfile "jprint" +set srcfile ${srcdir}/$subdir/${testfile}.java +set binfile ${objdir}/${subdir}/${testfile} +if { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +# Set the current language to java. This counts as a test. If it +# fails, then we skip the other tests. + +proc set_lang_java {} { + global gdb_prompt + global binfile objdir subdir + + verbose "loading file '$binfile'" + gdb_load $binfile + + send_gdb "set language java\n" + gdb_expect { + -re ".*$gdb_prompt $" {} + timeout { fail "set language java (timeout)" ; return 0 } + } + + return [gdb_test "show language" ".* source language is \"java\".*" \ + "set language to \"java\""] +} + +set prms_id 0 +set bug_id 0 + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +gdb_test "set print sevenbit-strings" ".*" + +if ![set_lang_java] then { + # Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main". + # As of 2004-02-24 it wasn't working and is being tested separatly. + runto "\'${testfile}.main(java.lang.String\[\])\'" + + gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call" + + gdb_test "next" "" + gdb_test "next" "" + + gdb_test "p x.print(44)" "x is 44\r\n.*" "single argument print call" + gdb_test "p x.print(22,33)" "y is 33\r\n.*" "double argument print call" + gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call" + gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call" + gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call" +} Index: gdb.java/jprint.java =================================================================== RCS file: gdb.java/jprint.java diff -N gdb.java/jprint.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb.java/jprint.java 20 Sep 2004 20:03:02 -0000 @@ -0,0 +1,62 @@ +// jprint.java test program. +// +// Copyright 2004 +// Free Software Foundation, Inc. +// +// Written by Jeff Johnston +// Contributed by Red Hat +// +// This file is part of GDB. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +class jvclass { + public static int k; + static { + k = 77; + } + public static void addprint (int x, int y, int z) { + int sum = x + y + z; + System.out.println ("sum is " + sum); + } + + public int addk (int x) { + int sum = x + k; + System.out.println ("adding k gives " + sum); + return sum; + } +} + +public class jprint extends jvclass { + public int dothat (int x) { + int y = x + 3; + System.out.println ("new value is " + y); + return y + 4; + } + public static void print (int x) { + System.out.println("x is " + x); + } + public static void print (int x, int y) { + System.out.println("y is " + y); + } + public static void main(String[] args) { + jprint x = new jprint (); + x.print (44); + print (k, 33); + } +} + + --------------090507020704070403070102--