1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8140650
* @summary Method::is_accessor should cover getters and setters for all types
* @modules java.base/jdk.internal.misc
* @library /test/lib
*
* @run driver compiler.inlining.InlineAccessors
*/
package compiler.inlining;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class InlineAccessors {
public static void main(String[] args) throws Exception {
// try some sanity checks first
doTest();
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
"-server", "-XX:-TieredCompilation", "-Xbatch",
"-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining",
Launcher.class.getName());
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(0);
// The test is applicable only to C2 (present in Server VM).
if (analyzer.getStderr().contains("Server VM")) {
analyzer.shouldContain("InlineAccessors::setBool (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setByte (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setChar (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setShort (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setInt (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setFloat (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setLong (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setDouble (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setObject (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::setArray (6 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getBool (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getByte (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getChar (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getShort (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getInt (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getFloat (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getLong (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getDouble (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getObject (5 bytes) accessor");
analyzer.shouldContain("InlineAccessors::getArray (5 bytes) accessor");
}
}
boolean bool;
byte b;
char c;
short s;
int i;
float f;
long l;
double d;
Object o;
Object[] a;
public void setBool(boolean v) { bool = v; }
public void setByte(byte v) { b = v; }
public void setChar(char v) { c = v; }
public void setShort(short v) { s = v; }
public void setInt(int v) { i = v; }
public void setFloat(float v) { f = v; }
public void setLong(long v) { l = v; }
public void setDouble(double v) { d = v; }
public void setObject(Object v) { o = v; }
public void setArray(Object[] v) { a = v; }
public boolean getBool() { return bool; }
public byte getByte() { return b; }
public char getChar() { return c; }
public short getShort() { return s; }
public int getInt() { return i; }
public float getFloat() { return f; }
public long getLong() { return l; }
public double getDouble() { return d; }
public Object getObject() { return o; }
public Object[] getArray() { return a; }
static void doTest() {
InlineAccessors o = new InlineAccessors();
o.setBool(false);
o.setByte((byte)0);
o.setChar('a');
o.setShort((short)0);
o.setInt(0);
o.setFloat(0F);
o.setLong(0L);
o.setDouble(0D);
o.setObject(new Object());
o.setArray(new Object[1]);
o.getBool();
o.getByte();
o.getChar();
o.getShort();
o.getInt();
o.getFloat();
o.getLong();
o.getDouble();
o.getObject();
o.getArray();
}
static class Launcher {
public static void main(String[] args) throws Exception {
for (int c = 0; c < 20_000; c++) {
doTest();
}
}
}
}
|