1 /*
   2  * Copyright (c) 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.
   8  * 
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  * 
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  * 
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  *
  26  JDK-8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
  27  *
  28  * @test
  29  * @run
  30  */
  31 
  32 Object.defineProperty(Object.prototype, "accessor", {
  33     set: function(value) {
  34         print("Setting accessor on " + this + " to " + value);
  35     }
  36 });
  37 
  38 Object.defineProperty(Object.prototype, "getterOnly", {
  39     get: function() {
  40         return 1;
  41     }
  42 });
  43 
  44 function set(o) {
  45     o.foo = 1;
  46     o.constructor = 1;
  47     o.accessor = 1;
  48     o.getterOnly = 1;
  49 }
  50 
  51 function setStrict(o) {
  52     "use strict";
  53     try {
  54         o.foo = 1;
  55     } catch (e) {
  56         print(e);
  57     }
  58     try {
  59         o.constructor = 1;
  60     } catch (e) {
  61         print(e);
  62     }
  63     try {
  64         o.accessor = 1;
  65     } catch (e) {
  66         print(e);
  67     }
  68     try {
  69         o.getterOnly = 1;
  70     } catch (e) {
  71         print(e);
  72     }
  73 }
  74 
  75 function setAttr(o, id) {
  76     o[id] = 1;
  77 }
  78 
  79 function setAttrStrict(o, id) {
  80     "use strict";
  81     try {
  82         o[id] = 1;
  83     } catch (e) {
  84         print(e);
  85     }
  86 }
  87 
  88 set(1);
  89 set("str");
  90 set(true);
  91 set({});
  92 set([]);
  93 
  94 setStrict(1);
  95 setStrict("str");
  96 setStrict(true);
  97 setStrict({});
  98 setStrict([]);
  99 
 100 setAttr(1, "foo");
 101 setAttr(1, "constructor");
 102 setAttr(1, "accessor");
 103 setAttr(1, "getterOnly");
 104 setAttr("str", "foo");
 105 setAttr("str", "constructor");
 106 setAttr("str", "accessor");
 107 setAttr("str", "getterOnly");
 108 setAttr(true, "foo");
 109 setAttr(true, "constructor");
 110 setAttr(true, "accessor");
 111 setAttr(true, "getterOnly");
 112 
 113 setAttrStrict(1, "foo");
 114 setAttrStrict(1, "constructor");
 115 setAttrStrict(1, "accessor");
 116 setAttrStrict(1, "getterOnly");
 117 setAttrStrict("str", "foo");
 118 setAttrStrict("str", "constructor");
 119 setAttrStrict("str", "accessor");
 120 setAttrStrict("str", "getterOnly");
 121 setAttrStrict(true, "foo");
 122 setAttrStrict(true, "constructor");
 123 setAttrStrict(true, "accessor");
 124 setAttrStrict(true, "getterOnly");