1 #!/bin/sh
   2 
   3 #
   4 # Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
   5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6 #
   7 # This code is free software; you can redistribute it and/or modify it
   8 # under the terms of the GNU General Public License version 2 only, as
   9 # published by the Free Software Foundation.
  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
  23 # questions.
  24 #
  25 
  26 #
  27 # @test
  28 # @bug 4467887 4913748
  29 # @key intermittent
  30 # @summary TTY: NullPointerException at
  31 #          com.sun.tools.jdi.MirrorImpl.validateMirrors
  32 # @author Tim Bell
  33 #
  34 # @run shell NotAField.sh
  35 #
  36 
  37 createJavaFile()
  38 {
  39     cat <<EOF > $classname.java.1
  40 public class $classname {
  41     public static void main(String args[]) {
  42         System.out.println("Hello, world!");
  43     }
  44 }
  45 
  46 EOF
  47 }
  48 
  49 # This is called to feed cmds to jdb.
  50 dojdbCmds()
  51 {
  52    #set -x
  53    cmd stop in $classname.main
  54    runToBkpt
  55    #This works:
  56    cmd print "java.lang.Class.reflectionFactory.hashCode()"
  57    #This should result in a ParseException: ("No such field in ..."):
  58    cmd print "java.lang.Class.reflectionFactory.hashCode"
  59    cmd allowExit cont
  60 }
  61 
  62 mysetup()
  63 {
  64    if [ -z "${TESTJAVA}" ] ; then
  65       # TESTJAVA is not set, so the test is running stand-alone.
  66       # TESTJAVA holds the path to the root directory of the build of the JDK
  67       # to be tested.  That is, any java files run explicitly in this shell
  68       # should use TESTJAVA in the path to the java interpreter.
  69       # So, we'll set this to the JDK spec'd on the command line.  If none
  70       # is given on the command line, tell the user that and use a default.
  71       # THIS IS THE JDK BEING TESTED.
  72       if [ -n "$1" ] ; then
  73              TESTJAVA=$1
  74          else
  75              TESTJAVA=$JAVA_HOME
  76       fi
  77       TESTSRC=.
  78       TESTCLASSES=.
  79    fi
  80    echo "JDK under test is: $TESTJAVA"
  81 
  82    if [ -z "$TESTSRC" ] ; then
  83         TESTSRC=.
  84    fi
  85 
  86    if [ -r $TESTSRC/ShellScaffold.sh ] ; then
  87         . $TESTSRC/ShellScaffold.sh
  88    elif [ -r $TESTSRC/../ShellScaffold.sh ] ; then
  89         . $TESTSRC/../ShellScaffold.sh
  90    fi
  91 }
  92 
  93 # You could replace this next line with the contents
  94 # of ShellScaffold.sh and this script will run just the same.
  95 mysetup
  96 
  97 runit
  98 jdbFailIfNotPresent "com.sun.tools.example.debug.expr.ParseException" 50
  99 pass