This commit is contained in:
Jesper Wilhelmsson 2021-01-07 21:17:35 +00:00
commit 555641ede5
68 changed files with 815 additions and 2206 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, 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
@ -41,14 +41,13 @@ class CopyrightHeaders {
" * Copyright (c) 2012, %d, Oracle and/or its affiliates. All rights reserved.\n" +
" */\n";
// Last updated: - 6/06/2016, 1:42:31 PM
// Last updated: - 1/04/2021
private static final String UNICODE =
"/*\n" +
" * COPYRIGHT AND PERMISSION NOTICE\n" +
" *\n" +
" * Copyright (C) 1991-2016 Unicode, Inc. All rights reserved.\n" +
" * Distributed under the Terms of Use in \n" +
" * http://www.unicode.org/copyright.html.\n" +
" * Copyright (c) 1991-2020 Unicode, Inc. All rights reserved.\n" +
" * Distributed under the Terms of Use in https://www.unicode.org/copyright.html.\n" +
" *\n" +
" * Permission is hereby granted, free of charge, to any person obtaining\n" +
" * a copy of the Unicode data files and any associated documentation\n" +
@ -57,14 +56,11 @@ class CopyrightHeaders {
" * without restriction, including without limitation the rights to use,\n" +
" * copy, modify, merge, publish, distribute, and/or sell copies of\n" +
" * the Data Files or Software, and to permit persons to whom the Data Files\n" +
" * or Software are furnished to do so, provided that\n" +
" * (a) this copyright and permission notice appear with all copies \n" +
" * of the Data Files or Software,\n" +
" * (b) this copyright and permission notice appear in associated \n" +
" * documentation, and\n" +
" * (c) there is clear notice in each modified Data File or in the Software\n" +
" * as well as in the documentation associated with the Data File(s) or\n" +
" * Software that the data or software has been modified.\n" +
" * or Software are furnished to do so, provided that either\n" +
" * (a) this copyright and permission notice appear with all copies\n" +
" * of the Data Files or Software, or\n" +
" * (b) this copyright and permission notice appear in associated\n" +
" * Documentation.\n" +
" *\n" +
" * THE DATA FILES AND SOFTWARE ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF\n" +
" * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n" +

View File

@ -315,18 +315,19 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_ve
}
if (restore_vectors) {
off = additional_frame_bytes - ymm_bytes;
// Restore upper half of YMM registers.
for (int n = 0; n < num_xmm_regs; n++) {
__ vinsertf128_high(as_XMMRegister(n), Address(rsp, n*16+off));
}
if (UseAVX > 2) {
// Restore upper half of ZMM registers.
for (int n = 0; n < num_xmm_regs; n++) {
__ vinsertf64x4_high(as_XMMRegister(n), Address(rsp, n*32));
}
__ addptr(rsp, zmm_bytes);
}
// Restore upper half of YMM registers.
for (int n = 0; n < num_xmm_regs; n++) {
__ vinsertf128_high(as_XMMRegister(n), Address(rsp, n*16));
}
__ addptr(rsp, ymm_bytes);
__ addptr(rsp, additional_frame_bytes);
}
__ pop_FPU_state();

View File

@ -230,8 +230,6 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) {
break;
case vmIntrinsics::_getObjectSize:
break;
case vmIntrinsics::_blackhole:
break;
default:
return false; // Intrinsics not on the previous list are not available.
}

View File

@ -3416,7 +3416,7 @@ bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, bool ignore_r
// handle intrinsics
if (callee->intrinsic_id() != vmIntrinsics::_none &&
callee->check_intrinsic_candidate()) {
(CheckIntrinsics ? callee->intrinsic_candidate() : true)) {
if (try_inline_intrinsics(callee, ignore_return)) {
print_inlining(callee, "intrinsic");
if (callee->has_reserved_stack_access()) {

View File

@ -3206,10 +3206,6 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) {
do_vectorizedMismatch(x);
break;
case vmIntrinsics::_blackhole:
do_blackhole(x);
break;
default: ShouldNotReachHere(); break;
}
}
@ -3629,23 +3625,6 @@ void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) {
}
}
void LIRGenerator::do_blackhole(Intrinsic *x) {
// If we have a receiver, then null-check and handle it separately
bool handle_receiver = x->needs_null_check();
if (handle_receiver) {
CodeEmitInfo* info = state_for(x);
LIRItem vitem(x->receiver(), this);
vitem.load_item();
__ null_check(vitem.result(), info);
}
for (int c = (handle_receiver ? 1 : 0); c < x->number_of_arguments(); c++) {
// Load the argument
LIRItem vitem(x->argument_at(c), this);
vitem.load_item();
// ...and leave it unused.
}
}
LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) {
LIRItemList args(1);

View File

@ -265,7 +265,6 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {
void do_update_CRC32(Intrinsic* x);
void do_update_CRC32C(Intrinsic* x);
void do_vectorizedMismatch(Intrinsic* x);
void do_blackhole(Intrinsic* x);
public:
LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);

View File

@ -156,10 +156,6 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
ciReplay::initialize(this);
}
#endif
if (CompilerOracle::should_blackhole(h_m)) {
h_m->set_intrinsic_id(vmIntrinsics::_blackhole);
}
}

View File

@ -202,15 +202,6 @@ class ciMethod : public ciMetadata {
bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
bool is_static_initializer() const { return get_Method()->is_static_initializer(); }
bool check_intrinsic_candidate() const {
if (intrinsic_id() == vmIntrinsics::_blackhole) {
// This is the intrinsic without an associated method, so no intrinsic_candidate
// flag is set. The intrinsic is still correct.
return true;
}
return (CheckIntrinsics ? intrinsic_candidate() : true);
}
int highest_osr_comp_level();
Bytecodes::Code java_code_at_bci(int bci) {

View File

@ -5309,11 +5309,6 @@ static void check_methods_for_intrinsics(const InstanceKlass* ik,
// is defined for it.
continue;
}
if (vmIntrinsics::_blackhole == id) {
// The _blackhole intrinsic is a special marker. No explicit method
// is defined for it.
continue;
}
if (vmIntrinsics::class_for(id) == klass_id) {
// Check if the current class contains a method with the same

View File

@ -151,7 +151,6 @@ bool vmIntrinsics::should_be_pinned(vmIntrinsics::ID id) {
#endif
case vmIntrinsics::_currentTimeMillis:
case vmIntrinsics::_nanoTime:
case vmIntrinsics::_blackhole:
return true;
default:
return false;

View File

@ -534,9 +534,6 @@ class methodHandle;
do_name( getObjectSize_name, "getObjectSize0") \
do_alias( getObjectSize_signature, long_object_long_signature) \
\
/* special marker for blackholed methods: */ \
do_intrinsic(_blackhole, java_lang_Object, blackhole_name, star_name, F_S) \
\
/* unsafe memory references (there are a lot of them...) */ \
do_signature(getReference_signature, "(Ljava/lang/Object;J)Ljava/lang/Object;") \
do_signature(putReference_signature, "(Ljava/lang/Object;JLjava/lang/Object;)V") \

View File

@ -283,7 +283,6 @@
template(signature_name, "signature") \
template(slot_name, "slot") \
template(trusted_final_name, "trustedFinal") \
template(blackhole_name, "<blackhole>") /*fake name*/ \
\
/* Support for annotations (JDK 1.5 and above) */ \
\

View File

@ -287,11 +287,6 @@ static void register_command(TypedMethodOptionMatcher* matcher,
}
assert(CompilerOracle::option_matches_type(option, value), "Value must match option type");
if (option == CompileCommand::Blackhole && !UnlockDiagnosticVMOptions) {
warning("Blackhole compile option is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions");
return;
}
matcher->init(option, option_list);
matcher->set_value<T>(value);
option_list = matcher;

View File

@ -2459,6 +2459,21 @@ bool MemoryGraphFixer::mem_is_valid(Node* m, Node* c) const {
Node* MemoryGraphFixer::find_mem(Node* ctrl, Node* n) const {
assert(n == NULL || _phase->ctrl_or_self(n) == ctrl, "");
assert(!ctrl->is_Call() || ctrl == n, "projection expected");
#ifdef ASSERT
if ((ctrl->is_Proj() && ctrl->in(0)->is_Call()) ||
(ctrl->is_Catch() && ctrl->in(0)->in(0)->is_Call())) {
CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_Call() : ctrl->in(0)->in(0)->as_Call();
int mems = 0;
for (DUIterator_Fast imax, i = call->fast_outs(imax); i < imax; i++) {
Node* u = call->fast_out(i);
if (u->bottom_type() == Type::MEMORY) {
mems++;
}
}
assert(mems <= 1, "No node right after call if multiple mem projections");
}
#endif
Node* mem = _memory_nodes[ctrl->_idx];
Node* c = ctrl;
while (!mem_is_valid(mem, c) &&

View File

@ -676,8 +676,6 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
case vmIntrinsics::_VectorInsert:
case vmIntrinsics::_VectorExtract:
return EnableVectorSupport;
case vmIntrinsics::_blackhole:
break;
default:
return false;

View File

@ -44,7 +44,6 @@ macro(ArrayCopy)
macro(AryEq)
macro(AtanD)
macro(Binary)
macro(Blackhole)
macro(Bool)
macro(BoxLock)
macro(ReverseBytesI)

View File

@ -3558,8 +3558,6 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f
}
break;
}
case Op_Blackhole:
break;
case Op_RangeCheck: {
RangeCheckNode* rc = n->as_RangeCheck();
Node* iff = new IfNode(rc->in(0), rc->in(1), rc->_prob, rc->_fcnt);

View File

@ -111,7 +111,7 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
const int bci = kit.bci();
// Try to inline the intrinsic.
if (callee->check_intrinsic_candidate() &&
if ((CheckIntrinsics ? callee->intrinsic_candidate() : true) &&
kit.try_to_inline(_last_predicate)) {
const char *inline_msg = is_virtual() ? "(intrinsic, virtual)"
: "(intrinsic)";
@ -668,9 +668,6 @@ bool LibraryCallKit::try_to_inline(int predicate) {
case vmIntrinsics::_getObjectSize:
return inline_getObjectSize();
case vmIntrinsics::_blackhole:
return inline_blackhole();
default:
// If you get here, it may be that someone has added a new intrinsic
// to the list in vmIntrinsics.hpp without implementing it here.
@ -6851,33 +6848,3 @@ bool LibraryCallKit::inline_getObjectSize() {
return true;
}
//------------------------------- inline_blackhole --------------------------------------
//
// Make sure all arguments to this node are alive.
// This matches methods that were requested to be blackholed through compile commands.
//
bool LibraryCallKit::inline_blackhole() {
// To preserve the semantics of Java call, we need to null-check the receiver,
// if present. Shortcut if receiver is unconditionally null.
Node* receiver = NULL;
bool has_receiver = !callee()->is_static();
if (has_receiver) {
receiver = null_check_receiver();
if (stopped()) {
return true;
}
}
// Bind call arguments as blackhole arguments to keep them alive
Node* bh = insert_mem_bar(Op_Blackhole);
if (has_receiver) {
bh->add_req(receiver);
}
uint nargs = callee()->arg_size();
for (uint i = has_receiver ? 1 : 0; i < nargs; i++) {
bh->add_req(argument(i));
}
return true;
}

View File

@ -344,7 +344,5 @@ class LibraryCallKit : public GraphKit {
}
bool inline_getObjectSize();
bool inline_blackhole();
};

View File

@ -4968,18 +4968,18 @@ Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) {
if (n->is_Load() && LCA != early) {
int load_alias_idx = C->get_alias_index(n->adr_type());
if (C->alias_type(load_alias_idx)->is_rewritable()) {
Unique_Node_List worklist;
Node_List worklist;
Node *mem = n->in(MemNode::Memory);
Node* mem = n->in(MemNode::Memory);
for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) {
Node* s = mem->fast_out(i);
worklist.push(s);
}
while(worklist.size() != 0 && LCA != early) {
Node* s = worklist.pop();
for (uint i = 0; i < worklist.size() && LCA != early; i++) {
Node* s = worklist.at(i);
if (s->is_Load() || s->Opcode() == Op_SafePoint ||
(s->is_CallStaticJava() && s->as_CallStaticJava()->uncommon_trap_request() != 0)) {
(s->is_CallStaticJava() && s->as_CallStaticJava()->uncommon_trap_request() != 0) ||
s->is_Phi()) {
continue;
} else if (s->is_MergeMem()) {
for (DUIterator_Fast imax, i = s->fast_outs(imax); i < imax; i++) {
@ -4987,7 +4987,7 @@ Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) {
worklist.push(s1);
}
} else {
Node *sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
Node* sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
assert(sctrl != NULL || !s->is_reachable_from_root(), "must have control");
if (sctrl != NULL && !sctrl->is_top() && is_dominator(early, sctrl)) {
const TypePtr* adr_type = s->adr_type();
@ -5011,6 +5011,22 @@ Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) {
}
}
}
// For Phis only consider Region's inputs that were reached by following the memory edges
if (LCA != early) {
for (uint i = 0; i < worklist.size(); i++) {
Node* s = worklist.at(i);
if (s->is_Phi() && C->can_alias(s->adr_type(), load_alias_idx)) {
Node* r = s->in(0);
for (uint j = 1; j < s->req(); j++) {
Node* in = s->in(j);
Node* r_in = r->in(j);
if (worklist.member(in) && is_dominator(early, r_in)) {
LCA = dom_lca_for_get_late_ctrl(LCA, r_in, n);
}
}
}
}
}
}
}

View File

@ -34,7 +34,6 @@
#include "opto/addnode.hpp"
#include "opto/arraycopynode.hpp"
#include "opto/cfgnode.hpp"
#include "opto/regalloc.hpp"
#include "opto/compile.hpp"
#include "opto/connode.hpp"
#include "opto/convertnode.hpp"
@ -3225,7 +3224,6 @@ MemBarNode* MemBarNode::make(Compile* C, int opcode, int atp, Node* pn) {
case Op_OnSpinWait: return new OnSpinWaitNode(C, atp, pn);
case Op_Initialize: return new InitializeNode(C, atp, pn);
case Op_MemBarStoreStore: return new MemBarStoreStoreNode(C, atp, pn);
case Op_Blackhole: return new BlackholeNode(C, atp, pn);
default: ShouldNotReachHere(); return NULL;
}
}
@ -3460,27 +3458,6 @@ MemBarNode* MemBarNode::leading_membar() const {
return mb;
}
#ifndef PRODUCT
void BlackholeNode::format(PhaseRegAlloc* ra, outputStream* st) const {
st->print("blackhole ");
bool first = true;
for (uint i = 0; i < req(); i++) {
Node* n = in(i);
if (n != NULL && OptoReg::is_valid(ra->get_reg_first(n))) {
if (first) {
first = false;
} else {
st->print(", ");
}
char buf[128];
ra->dump_register(n, buf);
st->print("%s", buf);
}
}
st->cr();
}
#endif
//===========================InitializeNode====================================
// SUMMARY:
// This node acts as a memory barrier on raw memory, after some raw stores.

View File

@ -1335,26 +1335,6 @@ public:
virtual int Opcode() const;
};
//------------------------------BlackholeNode----------------------------
// Blackhole all arguments. This node would survive through the compiler
// the effects on its arguments, and would be finally matched to nothing.
class BlackholeNode : public MemBarNode {
public:
BlackholeNode(Compile* C, int alias_idx, Node* precedent)
: MemBarNode(C, alias_idx, precedent) {}
virtual int Opcode() const;
virtual uint ideal_reg() const { return 0; } // not matched in the AD file
const RegMask &in_RegMask(uint idx) const {
// Fake the incoming arguments mask for blackholes: accept all registers
// and all stack slots. This would avoid moving the arguments for the
// call that never happens.
return RegMask::All;
}
#ifndef PRODUCT
virtual void format(PhaseRegAlloc* ra, outputStream* st) const;
#endif
};
// Isolation of object setup after an AllocateNode and before next safepoint.
// (See comment in memnode.cpp near InitializeNode::InitializeNode for semantics.)
class InitializeNode: public MemBarNode {

View File

@ -44,7 +44,6 @@ class AllocateNode;
class ArrayCopyNode;
class BaseCountedLoopNode;
class BaseCountedLoopEndNode;
class BlackholeNode;
class Block;
class BoolNode;
class BoxLockNode;

View File

@ -51,13 +51,6 @@ void OptoReg::dump(int r, outputStream *st) {
//=============================================================================
const RegMask RegMask::Empty;
const RegMask RegMask::All(
# define BODY(I) -1,
FORALL_BODY
# undef BODY
0
);
//=============================================================================
bool RegMask::is_vector(uint ireg) {
return (ireg == Op_VecA || ireg == Op_VecS || ireg == Op_VecD ||

View File

@ -356,7 +356,6 @@ class RegMask {
#endif
static const RegMask Empty; // Common empty mask
static const RegMask All; // Common all mask
static bool can_represent(OptoReg::Name reg) {
// NOTE: -1 in computation reflects the usage of the last

View File

@ -1436,7 +1436,7 @@ bool LibraryCallKit::inline_vector_convert() {
} else if (num_elem_from > num_elem_to) {
// Since number elements from input is larger than output, simply reduce size of input (we are supposed to
// drop top elements anyway).
int num_elem_for_resize = MAX2(num_elem_to, Matcher::min_vector_size(elem_bt_to));
int num_elem_for_resize = MAX2(num_elem_to, Matcher::min_vector_size(elem_bt_from));
// It is possible that arch does not support this intermediate vector size
// TODO More complex logic required here to handle this corner case for the sizes.

View File

@ -1597,7 +1597,6 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
declare_c2_type(MemBarVolatileNode, MemBarNode) \
declare_c2_type(MemBarCPUOrderNode, MemBarNode) \
declare_c2_type(OnSpinWaitNode, MemBarNode) \
declare_c2_type(BlackholeNode, MemBarNode) \
declare_c2_type(InitializeNode, MemBarNode) \
declare_c2_type(ThreadLocalNode, Node) \
declare_c2_type(Opaque1Node, Node) \

View File

@ -707,7 +707,9 @@ public abstract class Executable extends AccessibleObject
Class<?> ownerClass = c.getDeclaringClass();
TypeVariable<?>[] typeVars = c.getTypeParameters();
if (ownerClass == null) { // base case
// base case, static nested classes, according to JLS 8.1.3, has no
// enclosing instance, therefore its owner is not generified.
if (ownerClass == null || Modifier.isStatic(c.getModifiers())) {
if (typeVars.length == 0)
return c;
else

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -237,7 +237,8 @@ class Direct$Type$Buffer$RW$$BO$
0,
length,
length,
index, segment);
index << $LG_BYTES_PER_VALUE$,
segment);
}
public $Type$Buffer duplicate() {

View File

@ -889,7 +889,7 @@ public class FileChannelImpl
@Override
public long address() {
return address;
return address + pagePosition;
}
@Override

View File

@ -1760,8 +1760,8 @@ final class WPathGraphics extends PathGraphics {
/* Convert the quad path to a bezier.
*/
case PathIterator.SEG_QUADTO:
float lastX = wPrinterJob.getPenX();
float lastY = wPrinterJob.getPenY();
int lastX = wPrinterJob.getPenX();
int lastY = wPrinterJob.getPenY();
float c1x = lastX + (segment[0] - lastX) * 2 / 3;
float c1y = lastY + (segment[1] - lastY) * 2 / 3;
float c2x = segment[2] - (segment[2] - segment[0]) * 2/ 3;

View File

@ -362,10 +362,6 @@ public final class WPrinterJob extends RasterPrinterJob
private java.awt.peer.ComponentPeer dialogOwnerPeer = null;
private static final float precisionScale = 1000.0f;
private int graphicsMode;
private double[] worldTransform = new double[6];
/* Static Initializations */
static {
@ -957,33 +953,11 @@ public final class WPrinterJob extends RasterPrinterJob
}
protected void beginPath() {
precisionScaleBegin();
beginPath(getPrintDC());
}
protected void endPath() {
endPath(getPrintDC());
precisionScaleEnd();
}
protected float precisionScaleUp(float value) {
return value * precisionScale;
}
protected float precisionScaleDown(float value) {
return value / precisionScale;
}
protected void precisionScaleBegin() {
graphicsMode = setAdvancedGraphicsMode();
getWorldTransform(worldTransform);
float invPrecisionScale = 1.0f / precisionScale;
scale(invPrecisionScale, invPrecisionScale);
}
protected void precisionScaleEnd() {
setWorldTransform(worldTransform);
setGraphicsMode(graphicsMode);
}
protected void closeFigure() {
@ -995,23 +969,20 @@ public final class WPrinterJob extends RasterPrinterJob
}
protected void moveTo(float x, float y) {
moveTo(getPrintDC(),
precisionScaleUp(x), precisionScaleUp(y));
moveTo(getPrintDC(), x, y);
}
protected void lineTo(float x, float y) {
lineTo(getPrintDC(),
precisionScaleUp(x), precisionScaleUp(y));
lineTo(getPrintDC(), x, y);
}
protected void polyBezierTo(float control1x, float control1y,
float control2x, float control2y,
float endX, float endY) {
polyBezierTo(getPrintDC(),
precisionScaleUp(control1x), precisionScaleUp(control1y),
precisionScaleUp(control2x), precisionScaleUp(control2y),
precisionScaleUp(endX), precisionScaleUp(endY));
polyBezierTo(getPrintDC(), control1x, control1y,
control2x, control2y,
endX, endY);
}
/**
@ -1024,44 +995,6 @@ public final class WPrinterJob extends RasterPrinterJob
setPolyFillMode(getPrintDC(), fillRule);
}
/**
* Set the GDI graphics mode to {@code GM_ADVANCED}.
*/
private int setAdvancedGraphicsMode() {
return setAdvancedGraphicsMode(getPrintDC());
}
/**
* Set the GDI graphics mode.
* The {@code mode} should
* be one of the following Windows constants:
* {@code GM_COMPATIBLE} or {@code GM_ADVANCED}.
*/
private int setGraphicsMode(int mode) {
return setGraphicsMode(getPrintDC(), mode);
}
/**
* Scale the GDI World Transform.
*/
private void scale(double scaleX, double scaleY) {
scale(getPrintDC(), scaleX, scaleY);
}
/**
* Get the GDI World Transform.
*/
private void getWorldTransform(double[] transform) {
getWorldTransform(getPrintDC(), transform);
}
/**
* Set the GDI World Transform.
*/
private void setWorldTransform(double[] transform) {
setWorldTransform(getPrintDC(), transform);
}
/*
* Create a Window's solid brush for the color specified
* by {@code (red, green, blue)}. Once the brush
@ -1087,9 +1020,9 @@ public final class WPrinterJob extends RasterPrinterJob
* Return the x coordinate of the current pen
* position in the print device context.
*/
protected float getPenX() {
protected int getPenX() {
return precisionScaleDown(getPenX(getPrintDC()));
return getPenX(getPrintDC());
}
@ -1097,9 +1030,9 @@ public final class WPrinterJob extends RasterPrinterJob
* Return the y coordinate of the current pen
* position in the print device context.
*/
protected float getPenY() {
protected int getPenY() {
return precisionScaleDown(getPenY(getPrintDC()));
return getPenY(getPrintDC());
}
/**
@ -1537,39 +1470,6 @@ public final class WPrinterJob extends RasterPrinterJob
*/
protected native void setPolyFillMode(long printDC, int fillRule);
/**
* Set the GDI graphics mode to {@code GM_ADVANCED}
* into the device context {@code printDC}.
*/
protected native int setAdvancedGraphicsMode(long printDC);
/**
* Set the GDI graphics mode to {@code GM_ADVANCED}
* into the device context {@code printDC}.
* The {@code mode} should
* be one of the following Windows constants:
* {@code GM_COMPATIBLE} or {@code GM_ADVANCED}.
*/
protected native int setGraphicsMode(long printDC, int mode);
/**
* Scale the GDI World Transform
* of the device context {@code printDC}.
*/
protected native void scale(long printDC, double scaleX, double scaleY);
/**
* Get the GDI World Transform
* from the device context {@code printDC}.
*/
protected native void getWorldTransform(long printDC, double[] transform);
/**
* Set the GDI World Transform
* into the device context {@code printDC}.
*/
protected native void setWorldTransform(long printDC, double[] transform);
/**
* Create a Window's solid brush for the color specified
* by {@code (red, green, blue)}. Once the brush

View File

@ -1932,111 +1932,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setPolyFillMode
CATCH_BAD_ALLOC;
}
/*
* Class: sun_awt_windows_WPrinterJob
* Method: setAdvancedGraphicsMode
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_sun_awt_windows_WPrinterJob_setAdvancedGraphicsMode
(JNIEnv *env, jobject self, jlong printDC) {
TRY;
return (jint) ::SetGraphicsMode((HDC)printDC, GM_ADVANCED);
CATCH_BAD_ALLOC_RET(0);
}
/*
* Class: sun_awt_windows_WPrinterJob
* Method: setGraphicsMode
* Signature: (JI)I
*/
JNIEXPORT jint JNICALL Java_sun_awt_windows_WPrinterJob_setGraphicsMode
(JNIEnv *env, jobject self, jlong printDC, jint mode) {
TRY;
return (jint) ::SetGraphicsMode((HDC)printDC, mode);
CATCH_BAD_ALLOC_RET(0);
}
/*
* Class: sun_awt_windows_WPrinterJob
* Method: scale
* Signature: (JDD)V
*/
JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_scale
(JNIEnv *env, jobject self, jlong printDC, jdouble scaleX, jdouble scaleY) {
TRY;
XFORM xForm;
xForm.eM11 = (FLOAT) scaleX;
xForm.eM12 = (FLOAT) 0;
xForm.eM21 = (FLOAT) 0;
xForm.eM22 = (FLOAT) scaleY;
xForm.eDx = (FLOAT) 0;
xForm.eDy = (FLOAT) 0;
::ModifyWorldTransform((HDC)printDC, &xForm, MWT_RIGHTMULTIPLY);
CATCH_BAD_ALLOC;
}
/*
* Class: sun_awt_windows_WPrinterJob
* Method: getWorldTransform
* Signature: (J[D)V
*/
JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_getWorldTransform
(JNIEnv* env, jobject self, jlong printDC, jdoubleArray transform) {
TRY;
double elems[6];
XFORM xForm;
::GetWorldTransform((HDC)printDC, &xForm);
elems[0] = (double) xForm.eM11;
elems[1] = (double) xForm.eM12;
elems[2] = (double) xForm.eM21;
elems[3] = (double) xForm.eM22;
elems[4] = (double) xForm.eDx;
elems[5] = (double) xForm.eDy;
env->SetDoubleArrayRegion(transform, 0, 6, elems);
CATCH_BAD_ALLOC;
}
/*
* Class: sun_awt_windows_WPrinterJob
* Method: setWorldTransform
* Signature: (J[D)V
*/
JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setWorldTransform
(JNIEnv* env, jobject self, jlong printDC, jdoubleArray transform) {
TRY;
double *elems;
XFORM xForm;
elems = env->GetDoubleArrayElements(transform, 0);
xForm.eM11 = (FLOAT) elems[0];
xForm.eM12 = (FLOAT) elems[1];
xForm.eM21 = (FLOAT) elems[2];
xForm.eM22 = (FLOAT) elems[3];
xForm.eDx = (FLOAT) elems[4];
xForm.eDy = (FLOAT) elems[5];
::SetWorldTransform((HDC)printDC, &xForm);
env->ReleaseDoubleArrayElements(transform, elems, 0);
CATCH_BAD_ALLOC;
}
/*
* Class: sun_awt_windows_WPrinterJob
* Method: selectSolidBrush

View File

@ -1865,8 +1865,8 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
public static class BindingSymbol extends VarSymbol {
public BindingSymbol(Name name, Type type, Symbol owner) {
super(Flags.HASINIT | Flags.MATCH_BINDING, name, type, owner);
public BindingSymbol(long flags, Name name, Type type, Symbol owner) {
super(flags | Flags.HASINIT | Flags.MATCH_BINDING, name, type, owner);
}
public boolean isAliasFor(BindingSymbol b) {

View File

@ -389,7 +389,8 @@ public class TypeAnnotations {
if (sym.getKind() == ElementKind.PARAMETER ||
sym.getKind() == ElementKind.LOCAL_VARIABLE ||
sym.getKind() == ElementKind.RESOURCE_VARIABLE ||
sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
sym.getKind() == ElementKind.EXCEPTION_PARAMETER ||
sym.getKind() == ElementKind.BINDING_VARIABLE) {
appendTypeAnnotationsToOwner(sym, typeAnnotations);
}
}
@ -1264,6 +1265,11 @@ public class TypeAnnotations {
if (!tree.isImplicitlyTyped()) {
separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
}
} else if (tree.sym.getKind() == ElementKind.BINDING_VARIABLE) {
final TypeAnnotationPosition pos =
TypeAnnotationPosition.localVariable(currentLambda,
tree.pos);
separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
} else if (tree.sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
final TypeAnnotationPosition pos =
TypeAnnotationPosition.exceptionParameter(currentLambda,

View File

@ -4000,12 +4000,13 @@ public class Attr extends JCTree.Visitor {
public void visitBindingPattern(JCBindingPattern tree) {
ResultInfo varInfo = new ResultInfo(KindSelector.TYP, resultInfo.pt, resultInfo.checkContext);
tree.type = tree.var.type = attribTree(tree.var.vartype, env, varInfo);
BindingSymbol v = new BindingSymbol(tree.var.name, tree.var.vartype.type, env.info.scope.owner);
BindingSymbol v = new BindingSymbol(tree.var.mods.flags, tree.var.name, tree.var.vartype.type, env.info.scope.owner);
v.pos = tree.pos;
tree.var.sym = v;
if (chk.checkUnique(tree.var.pos(), v, env.info.scope)) {
chk.checkTransparentVar(tree.var.pos(), v, env.info.scope);
}
annotate.annotateLater(tree.var.mods.annotations, env, v, tree.pos());
annotate.queueScanTreeAndTypeAnnotate(tree.var.vartype, env, v, tree.var.pos());
annotate.flush();
result = tree.type;
@ -5768,7 +5769,7 @@ public class Attr extends JCTree.Visitor {
@Override
public void visitBindingPattern(JCBindingPattern that) {
if (that.var.sym == null) {
that.var.sym = new BindingSymbol(that.var.name, that.var.type, syms.noSymbol);
that.var.sym = new BindingSymbol(0, that.var.name, that.var.type, syms.noSymbol);
that.var.sym.adr = 0;
}
super.visitBindingPattern(that);

View File

@ -968,14 +968,19 @@ public class LambdaToMethod extends TreeTranslator {
for (int i = 0; implPTypes.nonEmpty() && i < last; ++i) {
// By default use the implementation method parameter type
Type parmType = implPTypes.head;
// If the unerased parameter type is a type variable whose
// bound is an intersection (eg. <T extends A & B>) then
// use the SAM parameter type
if (checkForIntersection && descPTypes.head.getKind() == TypeKind.TYPEVAR) {
TypeVar tv = (TypeVar) descPTypes.head;
if (tv.getUpperBound().getKind() == TypeKind.INTERSECTION) {
if (checkForIntersection) {
if (descPTypes.head.getKind() == TypeKind.INTERSECTION) {
parmType = samPTypes.head;
}
// If the unerased parameter type is a type variable whose
// bound is an intersection (eg. <T extends A & B>) then
// use the SAM parameter type
if (descPTypes.head.getKind() == TypeKind.TYPEVAR) {
TypeVar tv = (TypeVar) descPTypes.head;
if (tv.getUpperBound().getKind() == TypeKind.INTERSECTION) {
parmType = samPTypes.head;
}
}
}
addParameter("x$" + i, parmType, true);

View File

@ -490,9 +490,13 @@ public class JavacParser implements Parser {
/** Diagnose a modifier flag from the set, if any. */
protected void checkNoMods(long mods) {
checkNoMods(token.pos, mods);
}
protected void checkNoMods(int pos, long mods) {
if (mods != 0) {
long lowestMod = mods & -mods;
log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.ModNotAllowedHere(Flags.asFlagSet(lowestMod)));
log.error(DiagnosticFlag.SYNTAX, pos, Errors.ModNotAllowedHere(Flags.asFlagSet(lowestMod)));
}
}
@ -932,17 +936,30 @@ public class JavacParser implements Parser {
if (token.kind == INSTANCEOF) {
int pos = token.pos;
nextToken();
int patternPos = token.pos;
JCModifiers mods = optFinal(0);
int typePos = token.pos;
JCExpression type = parseType();
JCExpression type = unannotatedType(false);
JCTree pattern;
if (token.kind == IDENTIFIER) {
checkSourceLevel(token.pos, Feature.PATTERN_MATCHING_IN_INSTANCEOF);
JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
JCVariableDecl var = toP(F.at(token.pos).VarDef(mods, ident(), type, null));
TreeInfo.getStartPos(var);
pattern = toP(F.at(typePos).BindingPattern(var));
TreeInfo.getStartPos(pattern);
pattern = toP(F.at(patternPos).BindingPattern(var));
} else {
checkNoMods(typePos, mods.flags & ~Flags.DEPRECATED);
if (mods.annotations.nonEmpty()) {
checkSourceLevel(mods.annotations.head.pos, Feature.TYPE_ANNOTATIONS);
List<JCAnnotation> typeAnnos =
mods.annotations
.map(decl -> {
JCAnnotation typeAnno = F.at(decl.pos)
.TypeAnnotation(decl.annotationType,
decl.args);
endPosTable.replaceTree(decl, typeAnno);
return typeAnno;
});
type = insertAnnotationsToMostInner(type, typeAnnos, false);
}
pattern = type;
}
odStack[top] = F.at(pos).TypeTest(odStack[top], pattern);

View File

@ -116,13 +116,17 @@ public class MappedMemorySegmentImpl extends NativeMemorySegmentImpl {
if (bytesOffset < 0) throw new IllegalArgumentException("Requested bytes offset must be >= 0.");
try (FileChannelImpl channelImpl = (FileChannelImpl)FileChannel.open(path, openOptions(mapMode))) {
UnmapperProxy unmapperProxy = channelImpl.mapInternal(mapMode, bytesOffset, bytesSize);
MemoryScope scope = MemoryScope.createConfined(null, unmapperProxy::unmap, null);
int modes = defaultAccessModes(bytesSize);
if (mapMode == FileChannel.MapMode.READ_ONLY) {
modes &= ~WRITE;
}
return new MappedMemorySegmentImpl(unmapperProxy.address(), unmapperProxy, bytesSize,
modes, scope);
if (unmapperProxy != null) {
MemoryScope scope = MemoryScope.createConfined(null, unmapperProxy::unmap, null);
return new MappedMemorySegmentImpl(unmapperProxy.address(), unmapperProxy, bytesSize,
modes, scope);
} else {
return new EmptyMappedMemorySegmentImpl(modes);
}
}
}
@ -135,4 +139,32 @@ public class MappedMemorySegmentImpl extends NativeMemorySegmentImpl {
throw new UnsupportedOperationException("Unsupported map mode: " + mapMode);
}
}
static class EmptyMappedMemorySegmentImpl extends MappedMemorySegmentImpl {
public EmptyMappedMemorySegmentImpl(int modes) {
super(0, null, 0, modes,
MemoryScope.createConfined(null, MemoryScope.DUMMY_CLEANUP_ACTION, null));
}
@Override
public void load() {
// do nothing
}
@Override
public void unload() {
// do nothing
}
@Override
public boolean isLoaded() {
return true;
}
@Override
public void force() {
// do nothing
}
};
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, 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
@ -120,6 +120,9 @@ abstract class AbstractShuffle<E> extends VectorShuffle<E> {
@ForceInline
public final VectorShuffle<E> checkIndexes() {
if (VectorIntrinsics.VECTOR_ACCESS_OOB_CHECK == 0) {
return this;
}
// FIXME: vectorize this
for (int index : reorder()) {
if (index < 0) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, 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
@ -312,7 +312,7 @@ abstract class AbstractVector<E> extends Vector<E> {
int origin = shapeChangeOrigin(vsp, rsp, false, part);
//System.out.println("*** origin = "+origin+", part = "+part+", reinterpret");
if (part > 0) { // Expansion: slice first then cast.
return slice(origin, vsp.zero()).convert0('X', rsp);
return slice(origin).convert0('X', rsp);
} else { // Contraction: cast first then unslice.
return rsp.zero().slice(rsp.laneCount() - origin,
convert0('X', rsp));
@ -323,6 +323,9 @@ abstract class AbstractVector<E> extends Vector<E> {
@Override
public abstract AbstractVector<E> slice(int origin, Vector<E> v1);
@Override
public abstract AbstractVector<E> slice(int origin);
/**
* This is the template for Vector::convertShape, to be
* specialized by each distinct vector class.
@ -365,7 +368,7 @@ abstract class AbstractVector<E> extends Vector<E> {
int origin = shapeChangeOrigin(vsp, rsp, true, part);
//System.out.println("*** origin = "+origin+", part = "+part+", lanewise");
if (part > 0) { // Expansion: slice first then cast.
return slice(origin, vsp.zero()).convert0(kind, rsp);
return slice(origin).convert0(kind, rsp);
} else { // Contraction: cast first then unslice.
return rsp.zero().slice(rsp.laneCount() - origin,
convert0(kind, rsp));

View File

@ -46,6 +46,7 @@ import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils;
@ -507,7 +508,10 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
if (null == propertyMethod || null == commentSource) {
return;
}
DocCommentTree docTree = builder.utils.getDocCommentTree(propertyMethod);
Utils utils = builder.utils;
DocCommentTree docTree = utils.hasDocCommentTree(propertyMethod)
? utils.getDocCommentTree(propertyMethod)
: null;
/* The second condition is required for the property buckets. In
* this case the comment is at the property method (not at the field)

View File

@ -550,7 +550,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
return false;
}
if (utils.isSerializable(te)) {
if (!utils.getSerialTrees(te).isEmpty()) {
if (utils.hasDocCommentTree(te) && !utils.getSerialTrees(te).isEmpty()) {
return serialDocInclude(utils, te);
} else if (utils.isPublic(te) || utils.isProtected(te)) {
return true;

View File

@ -2637,14 +2637,16 @@ public class Utils {
}
public boolean hasBlockTag(Element element, DocTree.Kind kind, final String tagName) {
CommentHelper ch = getCommentHelper(element);
String tname = tagName != null && tagName.startsWith("@")
? tagName.substring(1)
: tagName;
for (DocTree dt : getBlockTags(element, kind)) {
if (dt.getKind() == kind) {
if (tname == null || ch.getTagName(dt).equals(tname)) {
return true;
if (hasDocCommentTree(element)) {
CommentHelper ch = getCommentHelper(element);
String tname = tagName != null && tagName.startsWith("@")
? tagName.substring(1)
: tagName;
for (DocTree dt : getBlockTags(element, kind)) {
if (dt.getKind() == kind) {
if (tname == null || ch.getTagName(dt).equals(tname)) {
return true;
}
}
}
}
@ -2685,6 +2687,16 @@ public class Utils {
*/
private final Map<Element, DocCommentInfo> dcTreeCache = new LinkedHashMap<>();
/**
* Checks whether an element has an associated doc comment.
* @param element the element
* @return {@code true} if the element has a comment, and false otherwise
*/
public boolean hasDocCommentTree(Element element) {
DocCommentInfo info = getDocCommentInfo(element);
return info != null && info.dcTree != null;
}
/**
* Retrieves the doc comments for a given element.
* @param element
@ -2692,28 +2704,7 @@ public class Utils {
*/
public DocCommentTree getDocCommentTree0(Element element) {
DocCommentInfo info = null;
ElementKind kind = element.getKind();
if (kind == ElementKind.PACKAGE || kind == ElementKind.OTHER) {
info = dcTreeCache.get(element); // local cache
if (info == null && kind == ElementKind.PACKAGE) {
// package-info.java
info = getDocCommentInfo(element);
}
if (info == null) {
// package.html or overview.html
info = configuration.cmtUtils.getHtmlCommentInfo(element); // html source
}
} else {
info = configuration.cmtUtils.getSyntheticCommentInfo(element);
if (info == null) {
info = dcTreeCache.get(element); // local cache
}
if (info == null) {
info = getDocCommentInfo(element); // get the real mccoy
}
}
DocCommentInfo info = getDocCommentInfo(element);
DocCommentTree docCommentTree = info == null ? null : info.dcTree;
if (!dcTreeCache.containsKey(element)) {
@ -2738,6 +2729,33 @@ public class Utils {
}
private DocCommentInfo getDocCommentInfo(Element element) {
DocCommentInfo info = null;
ElementKind kind = element.getKind();
if (kind == ElementKind.PACKAGE || kind == ElementKind.OTHER) {
info = dcTreeCache.get(element); // local cache
if (info == null && kind == ElementKind.PACKAGE) {
// package-info.java
info = getDocCommentInfo0(element);
}
if (info == null) {
// package.html or overview.html
info = configuration.cmtUtils.getHtmlCommentInfo(element); // html source
}
} else {
info = configuration.cmtUtils.getSyntheticCommentInfo(element);
if (info == null) {
info = dcTreeCache.get(element); // local cache
}
if (info == null) {
info = getDocCommentInfo0(element); // get the real mccoy
}
}
return info;
}
private DocCommentInfo getDocCommentInfo0(Element element) {
// prevent nasty things downstream with overview element
if (element.getKind() != ElementKind.OTHER) {
TreePath path = getTreePath(element);

View File

@ -28,26 +28,3 @@
#############################################################################
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all
compiler/blackhole/BlackholeDiagnosticUnlockTest.java 8258101 generic-all
compiler/blackhole/BlackholeInstanceReturnTest.java#c1 8258101 generic-all
compiler/blackhole/BlackholeInstanceReturnTest.java#c1-no-coops 8258101 generic-all
compiler/blackhole/BlackholeInstanceReturnTest.java#c2 8258101 generic-all
compiler/blackhole/BlackholeInstanceReturnTest.java#c2-no-coops 8258101 generic-all
compiler/blackhole/BlackholeInstanceTest.java#c1 8258101 generic-all
compiler/blackhole/BlackholeInstanceTest.java#c1-no-coops 8258101 generic-all
compiler/blackhole/BlackholeInstanceTest.java#c2 8258101 generic-all
compiler/blackhole/BlackholeInstanceTest.java#c2-no-coops 8258101 generic-all
compiler/blackhole/BlackholeNonVoidWarningTest.java 8258101 generic-all
compiler/blackhole/BlackholeNullCheckTest.java#c1 8258101 generic-all
compiler/blackhole/BlackholeNullCheckTest.java#c1-no-coops 8258101 generic-all
compiler/blackhole/BlackholeNullCheckTest.java#c2 8258101 generic-all
compiler/blackhole/BlackholeNullCheckTest.java#c2-no-coops 8258101 generic-all
compiler/blackhole/BlackholeStaticReturnTest.java#c1 8258101 generic-all
compiler/blackhole/BlackholeStaticReturnTest.java#c1-no-coops 8258101 generic-all
compiler/blackhole/BlackholeStaticReturnTest.java#c2 8258101 generic-all
compiler/blackhole/BlackholeStaticReturnTest.java#c2-no-coops 8258101 generic-all
compiler/blackhole/BlackholeStaticTest.java#c1 8258101 generic-all
compiler/blackhole/BlackholeStaticTest.java#c1-no-coops 8258101 generic-all
compiler/blackhole/BlackholeStaticTest.java#c2 8258101 generic-all
compiler/blackhole/BlackholeStaticTest.java#c2-no-coops 8258101 generic-all

View File

@ -97,7 +97,6 @@ hotspot_slow_compiler = \
tier1_compiler_1 = \
compiler/arraycopy/ \
compiler/blackhole/ \
compiler/c1/ \
compiler/c2/ \
-compiler/c2/Test6850611.java \

View File

@ -1,109 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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
* @library /test/lib
* @build compiler.blackhole.BlackholeTarget
* @run driver compiler.blackhole.BlackholeDiagnosticUnlockTest
*/
package compiler.blackhole;
import java.io.IOException;
import jdk.test.lib.Platform;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class BlackholeDiagnosticUnlockTest {
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void main(String[] args) throws IOException {
if (args.length == 0) {
driver();
} else {
runner();
}
}
public static void driver() throws IOException {
final String msg = "Blackhole compile option is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions";
if (!Platform.isDebugBuild()) { // UnlockDiagnosticVMOptions is true in debug
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-Xbatch",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole",
"compiler.blackhole.BlackholeDiagnosticUnlockTest",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain(msg);
}
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:-PrintWarnings",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole",
"compiler.blackhole.BlackholeDiagnosticUnlockTest",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldNotContain(msg);
}
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole",
"compiler.blackhole.BlackholeDiagnosticUnlockTest",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldNotContain(msg);
}
}
public static void runner() {
for (int t = 0; t < TRIES; t++) {
run();
}
}
public static void run() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_int_1(c);
}
}
}

View File

@ -1,183 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
package compiler.blackhole;
public class BlackholeInstanceReturnTest {
public static void main(String[] args) {
runTries(BlackholeInstanceReturnTest::test_boolean);
runTries(BlackholeInstanceReturnTest::test_byte);
runTries(BlackholeInstanceReturnTest::test_char);
runTries(BlackholeInstanceReturnTest::test_short);
runTries(BlackholeInstanceReturnTest::test_int);
runTries(BlackholeInstanceReturnTest::test_float);
runTries(BlackholeInstanceReturnTest::test_long);
runTries(BlackholeInstanceReturnTest::test_double);
runTries(BlackholeInstanceReturnTest::test_Object);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
BlackholeTarget.shouldBeEntered();
}
}
private static void test_boolean() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_boolean((c & 0x1) == 0) != false) {
throw new AssertionError("Return value error");
}
}
}
private static void test_byte() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_byte((byte)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_char() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_char((char)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_short() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_short((short)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_int() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_int(c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_float() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_float(c) != 0F) {
throw new AssertionError("Return value error");
}
}
}
private static void test_long() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_long(c) != 0L) {
throw new AssertionError("Return value error");
}
}
}
private static void test_double() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_double(c) != 0D) {
throw new AssertionError("Return value error");
}
}
}
private static void test_Object() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
if (t.bh_ir_Object(o) != null) {
throw new AssertionError("Return value error");
}
}
}
}

View File

@ -1,314 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
package compiler.blackhole;
public class BlackholeInstanceTest {
public static void main(String[] args) {
runTries(BlackholeInstanceTest::test_boolean_0);
runTries(BlackholeInstanceTest::test_byte_0);
runTries(BlackholeInstanceTest::test_char_0);
runTries(BlackholeInstanceTest::test_short_0);
runTries(BlackholeInstanceTest::test_int_0);
runTries(BlackholeInstanceTest::test_float_0);
runTries(BlackholeInstanceTest::test_long_0);
runTries(BlackholeInstanceTest::test_double_0);
runTries(BlackholeInstanceTest::test_Object_0);
runTries(BlackholeInstanceTest::test_boolean_1);
runTries(BlackholeInstanceTest::test_byte_1);
runTries(BlackholeInstanceTest::test_char_1);
runTries(BlackholeInstanceTest::test_short_1);
runTries(BlackholeInstanceTest::test_int_1);
runTries(BlackholeInstanceTest::test_float_1);
runTries(BlackholeInstanceTest::test_long_1);
runTries(BlackholeInstanceTest::test_double_1);
runTries(BlackholeInstanceTest::test_Object_1);
runTries(BlackholeInstanceTest::test_boolean_2);
runTries(BlackholeInstanceTest::test_byte_2);
runTries(BlackholeInstanceTest::test_char_2);
runTries(BlackholeInstanceTest::test_short_2);
runTries(BlackholeInstanceTest::test_int_2);
runTries(BlackholeInstanceTest::test_float_2);
runTries(BlackholeInstanceTest::test_long_2);
runTries(BlackholeInstanceTest::test_double_2);
runTries(BlackholeInstanceTest::test_Object_2);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
if (t == TRIES - 1) {
BlackholeTarget.shouldNotBeEntered();
}
}
}
private static void test_boolean_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_boolean_0();
}
}
private static void test_byte_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_byte_0();
}
}
private static void test_char_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_char_0();
}
}
private static void test_short_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_short_0();
}
}
private static void test_int_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_int_0();
}
}
private static void test_float_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_float_0();
}
}
private static void test_long_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_long_0();
}
}
private static void test_double_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_double_0();
}
}
private static void test_Object_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_Object_0();
}
}
private static void test_boolean_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_boolean_1((c & 0x1) == 0);
}
}
private static void test_byte_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_byte_1((byte)c);
}
}
private static void test_char_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_char_1((char)c);
}
}
private static void test_short_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_short_1((short)c);
}
}
private static void test_int_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_int_1(c);
}
}
private static void test_float_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_float_1(c);
}
}
private static void test_long_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_long_1(c);
}
}
private static void test_double_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_double_1(c);
}
}
private static void test_Object_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
t.bh_i_Object_1(o);
}
}
private static void test_boolean_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_boolean_2((c & 0x1) == 0, (c & 0x2) == 0);
}
}
private static void test_byte_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_byte_2((byte)c, (byte)(c + 1));
}
}
private static void test_char_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_char_2((char)c, (char)(c + 1));
}
}
private static void test_short_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_short_2((short)c, (short)(c + 1));
}
}
private static void test_int_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_int_2(c, c + 1);
}
}
private static void test_float_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_float_2(c, c + 1);
}
}
private static void test_long_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_long_2(c, c + 1);
}
}
private static void test_double_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_double_2(c, c + 1);
}
}
private static void test_Object_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
Object o1 = new Object();
Object o2 = new Object();
t.bh_i_Object_2(o1, o2);
}
}
}

View File

@ -1,98 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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
* @library /test/lib
* @build compiler.blackhole.BlackholeTarget
* @run driver compiler.blackhole.BlackholeNonVoidWarningTest
*/
package compiler.blackhole;
import java.io.IOException;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class BlackholeNonVoidWarningTest {
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void main(String[] args) throws IOException {
if (args.length == 0) {
driver();
} else {
runner();
}
}
public static void driver() throws IOException {
final String msg = "Blackhole compile option only works for methods with void type: compiler.blackhole.BlackholeTarget.bh_sr_int(I)I";
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-Xbatch",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarningTest",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain(msg);
}
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:-PrintWarnings",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarningTest",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldNotContain(msg);
}
}
public static void runner() {
for (int t = 0; t < TRIES; t++) {
run();
}
}
public static void run() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_int(c) != 0) {
throw new AssertionError("Return value error");
}
}
}
}

View File

@ -1,173 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
package compiler.blackhole;
public class BlackholeNullCheckTest {
public static void main(String[] args) {
BlackholeNullCheckTest t = new BlackholeNullCheckTest();
runTries(t::test_local_sf);
runTries(t::test_local_s);
runTries(t::test_local);
runTries(t::test_field_sf);
runTries(t::test_field_s);
runTries(t::test_field);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
r.run();
}
}
static final BlackholeTarget BH_SF_TARGET = null;
static BlackholeTarget BH_S_TARGET = null;
BlackholeTarget BH_TARGET = null;
private void test_local_sf() {
test_with(BH_SF_TARGET);
}
private void test_local_s() {
test_with(BH_S_TARGET);
}
private void test_local() {
test_with(BH_TARGET);
}
private void test_with(BlackholeTarget t) {
try {
t.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
t.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
private void test_field_sf() {
try {
BH_SF_TARGET.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
BH_SF_TARGET.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
private void test_field_s() {
try {
BH_S_TARGET.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
BH_S_TARGET.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
private void test_field() {
try {
BH_TARGET.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
BH_TARGET.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
}

View File

@ -1,174 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
package compiler.blackhole;
public class BlackholeStaticReturnTest {
public static void main(String[] args) {
runTries(BlackholeStaticReturnTest::test_boolean);
runTries(BlackholeStaticReturnTest::test_byte);
runTries(BlackholeStaticReturnTest::test_char);
runTries(BlackholeStaticReturnTest::test_short);
runTries(BlackholeStaticReturnTest::test_int);
runTries(BlackholeStaticReturnTest::test_float);
runTries(BlackholeStaticReturnTest::test_long);
runTries(BlackholeStaticReturnTest::test_double);
runTries(BlackholeStaticReturnTest::test_Object);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
BlackholeTarget.shouldBeEntered();
}
}
private static void test_boolean() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_boolean((c & 0x1) == 0) != false) {
throw new AssertionError("Return value error");
}
}
}
private static void test_byte() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_byte((byte)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_char() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_char((char)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_short() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_short((short)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_int() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_int(c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_float() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_float(c) != 0F) {
throw new AssertionError("Return value error");
}
}
}
private static void test_long() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_long(c) != 0L) {
throw new AssertionError("Return value error");
}
}
}
private static void test_double() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_double(c) != 0D) {
throw new AssertionError("Return value error");
}
}
}
private static void test_Object() {
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
if (BlackholeTarget.bh_sr_Object(o) != null) {
throw new AssertionError("Return value error");
}
}
}
}

View File

@ -1,287 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -Xbatch -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
package compiler.blackhole;
public class BlackholeStaticTest {
public static void main(String[] args) {
runTries(BlackholeStaticTest::test_boolean_0);
runTries(BlackholeStaticTest::test_byte_0);
runTries(BlackholeStaticTest::test_char_0);
runTries(BlackholeStaticTest::test_short_0);
runTries(BlackholeStaticTest::test_int_0);
runTries(BlackholeStaticTest::test_float_0);
runTries(BlackholeStaticTest::test_long_0);
runTries(BlackholeStaticTest::test_double_0);
runTries(BlackholeStaticTest::test_Object_0);
runTries(BlackholeStaticTest::test_boolean_1);
runTries(BlackholeStaticTest::test_byte_1);
runTries(BlackholeStaticTest::test_char_1);
runTries(BlackholeStaticTest::test_short_1);
runTries(BlackholeStaticTest::test_int_1);
runTries(BlackholeStaticTest::test_float_1);
runTries(BlackholeStaticTest::test_long_1);
runTries(BlackholeStaticTest::test_double_1);
runTries(BlackholeStaticTest::test_Object_1);
runTries(BlackholeStaticTest::test_boolean_2);
runTries(BlackholeStaticTest::test_byte_2);
runTries(BlackholeStaticTest::test_char_2);
runTries(BlackholeStaticTest::test_short_2);
runTries(BlackholeStaticTest::test_int_2);
runTries(BlackholeStaticTest::test_float_2);
runTries(BlackholeStaticTest::test_long_2);
runTries(BlackholeStaticTest::test_double_2);
runTries(BlackholeStaticTest::test_Object_2);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
if (t == TRIES - 1) {
BlackholeTarget.shouldNotBeEntered();
}
}
}
private static void test_boolean_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_boolean_0();
}
}
private static void test_byte_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_byte_0();
}
}
private static void test_char_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_char_0();
}
}
private static void test_short_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_short_0();
}
}
private static void test_int_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_int_0();
}
}
private static void test_float_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_float_0();
}
}
private static void test_long_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_long_0();
}
}
private static void test_double_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_double_0();
}
}
private static void test_Object_0() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_Object_0();
}
}
private static void test_boolean_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_boolean_1((c & 0x1) == 0);
}
}
private static void test_byte_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_byte_1((byte)c);
}
}
private static void test_char_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_char_1((char)c);
}
}
private static void test_short_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_short_1((short)c);
}
}
private static void test_int_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_int_1(c);
}
}
private static void test_float_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_float_1(c);
}
}
private static void test_long_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_long_1(c);
}
}
private static void test_double_1() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_double_1(c);
}
}
private static void test_Object_1() {
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
BlackholeTarget.bh_s_Object_1(o);
}
}
private static void test_boolean_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_boolean_2((c & 0x1) == 0, (c & 0x2) == 0);
}
}
private static void test_byte_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_byte_2((byte)c, (byte)(c + 1));
}
}
private static void test_char_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_char_2((char)c, (char)(c + 1));
}
}
private static void test_short_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_short_2((short)c, (short)(c + 1));
}
}
private static void test_int_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_int_2(c, c + 1);
}
}
private static void test_float_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_float_2(c, c + 1);
}
}
private static void test_long_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_long_2(c, c + 1);
}
}
private static void test_double_2() {
for (int c = 0; c < CYCLES; c++) {
BlackholeTarget.bh_s_double_2(c, c + 1);
}
}
private static void test_Object_2() {
for (int c = 0; c < CYCLES; c++) {
Object o1 = new Object();
Object o2 = new Object();
BlackholeTarget.bh_s_Object_2(o1, o2);
}
}
}

View File

@ -1,136 +0,0 @@
/*
* Copyright (c) 2020, Red Hat, Inc. 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.
*/
package compiler.blackhole;
import java.lang.reflect.*;
public class BlackholeTarget {
private static String entered;
private static void registerEntered(String label) {
if (entered == null) {
entered = label;
} else if (!entered.equals(label)) {
throw new IllegalStateException("Trying to register enter with overwrite: " + entered + " -> " + label);
}
}
public static void clear() {
entered = null;
}
public static void shouldBeEntered() {
if (entered == null) {
throw new IllegalStateException("Should have been entered");
}
}
public static void shouldNotBeEntered() {
if (entered != null) {
throw new IllegalStateException("Should not have been entered: " + entered);
}
}
public void call_for_null_check() {}
public static void bh_s_boolean_0() { registerEntered("bh_s_boolean_0"); }
public static void bh_s_byte_0() { registerEntered("bh_s_byte_0"); }
public static void bh_s_short_0() { registerEntered("bh_s_short_0"); }
public static void bh_s_char_0() { registerEntered("bh_s_char_0"); }
public static void bh_s_int_0() { registerEntered("bh_s_int_0"); }
public static void bh_s_float_0() { registerEntered("bh_s_float_0"); }
public static void bh_s_long_0() { registerEntered("bh_s_long_0"); }
public static void bh_s_double_0() { registerEntered("bh_s_double_0"); }
public static void bh_s_Object_0() { registerEntered("bh_s_Object_0"); }
public void bh_i_boolean_0() { registerEntered("bh_i_boolean_0"); }
public void bh_i_byte_0() { registerEntered("bh_i_byte_0"); }
public void bh_i_short_0() { registerEntered("bh_i_short_0"); }
public void bh_i_char_0() { registerEntered("bh_i_char_0"); }
public void bh_i_int_0() { registerEntered("bh_i_int_0"); }
public void bh_i_float_0() { registerEntered("bh_i_float_0"); }
public void bh_i_long_0() { registerEntered("bh_i_long_0"); }
public void bh_i_double_0() { registerEntered("bh_i_double_0"); }
public void bh_i_Object_0() { registerEntered("bh_i_Object_0"); }
public static void bh_s_boolean_1(boolean v) { registerEntered("bh_s_boolean_1"); }
public static void bh_s_byte_1(byte v) { registerEntered("bh_s_byte_1"); }
public static void bh_s_short_1(short v) { registerEntered("bh_s_short_1"); }
public static void bh_s_char_1(char v) { registerEntered("bh_s_char_1"); }
public static void bh_s_int_1(int v) { registerEntered("bh_s_int_1"); }
public static void bh_s_float_1(float v) { registerEntered("bh_s_float_1"); }
public static void bh_s_long_1(long v) { registerEntered("bh_s_long_1"); }
public static void bh_s_double_1(double v) { registerEntered("bh_s_double_1"); }
public static void bh_s_Object_1(Object v) { registerEntered("bh_s_Object_1"); }
public void bh_i_boolean_1(boolean v) { registerEntered("bh_i_boolean_1"); }
public void bh_i_byte_1(byte v) { registerEntered("bh_i_byte_1"); }
public void bh_i_short_1(short v) { registerEntered("bh_i_short_1"); }
public void bh_i_char_1(char v) { registerEntered("bh_i_char_1"); }
public void bh_i_int_1(int v) { registerEntered("bh_i_int_1"); }
public void bh_i_float_1(float v) { registerEntered("bh_i_float_1"); }
public void bh_i_long_1(long v) { registerEntered("bh_i_long_1"); }
public void bh_i_double_1(double v) { registerEntered("bh_i_double_1"); }
public void bh_i_Object_1(Object v) { registerEntered("bh_i_Object_1"); }
public static void bh_s_boolean_2(boolean v1, boolean v2) { registerEntered("bh_s_boolean_2"); }
public static void bh_s_byte_2(byte v1, byte v2) { registerEntered("bh_s_byte_2"); }
public static void bh_s_short_2(short v1, short v2) { registerEntered("bh_s_short_2"); }
public static void bh_s_char_2(char v1, char v2) { registerEntered("bh_s_char_2"); }
public static void bh_s_int_2(int v1, int v2) { registerEntered("bh_s_int_2"); }
public static void bh_s_float_2(float v1, float v2) { registerEntered("bh_s_float_2"); }
public static void bh_s_long_2(long v1, long v2) { registerEntered("bh_s_long_2"); }
public static void bh_s_double_2(double v1, double v2) { registerEntered("bh_s_double_2"); }
public static void bh_s_Object_2(Object v1, Object v2) { registerEntered("bh_s_Object_2"); }
public void bh_i_boolean_2(boolean v1, boolean v2) { registerEntered("bh_i_boolean_2"); }
public void bh_i_byte_2(byte v1, byte v2) { registerEntered("bh_i_byte_2"); }
public void bh_i_short_2(short v1, short v2) { registerEntered("bh_i_short_2"); }
public void bh_i_char_2(char v1, char v2) { registerEntered("bh_i_char_2"); }
public void bh_i_int_2(int v1, int v2) { registerEntered("bh_i_int_2"); }
public void bh_i_float_2(float v1, float v2) { registerEntered("bh_i_float_2"); }
public void bh_i_long_2(long v1, long v2) { registerEntered("bh_i_long_2"); }
public void bh_i_double_2(double v1, double v2) { registerEntered("bh_i_double_2"); }
public void bh_i_Object_2(Object v1, Object v2) { registerEntered("bh_i_Object_2"); }
public static boolean bh_sr_boolean(boolean v) { registerEntered("bh_sr_boolean"); return false; }
public static byte bh_sr_byte(byte v) { registerEntered("bh_sr_byte"); return 0; }
public static short bh_sr_short(short v) { registerEntered("bh_sr_short"); return 0; }
public static char bh_sr_char(char v) { registerEntered("bh_sr_char"); return 0; }
public static int bh_sr_int(int v) { registerEntered("bh_sr_int"); return 0; }
public static float bh_sr_float(float v) { registerEntered("bh_sr_float"); return 0; }
public static long bh_sr_long(long v) { registerEntered("bh_sr_long"); return 0; }
public static double bh_sr_double(double v) { registerEntered("bh_sr_double"); return 0; }
public static Object bh_sr_Object(Object v) { registerEntered("bh_sr_Object"); return null; }
public boolean bh_ir_boolean(boolean v) { registerEntered("bh_ir_boolean"); return false; }
public byte bh_ir_byte(byte v) { registerEntered("bh_ir_byte"); return 0; }
public short bh_ir_short(short v) { registerEntered("bh_ir_short"); return 0; }
public char bh_ir_char(char v) { registerEntered("bh_ir_char"); return 0; }
public int bh_ir_int(int v) { registerEntered("bh_ir_int"); return 0; }
public float bh_ir_float(float v) { registerEntered("bh_ir_float"); return 0; }
public long bh_ir_long(long v) { registerEntered("bh_ir_long"); return 0; }
public double bh_ir_double(double v) { registerEntered("bh_ir_double"); return 0; }
public Object bh_ir_Object(Object v) { registerEntered("bh_ir_Object"); return null; }
}

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2021, Red Hat, Inc. 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 8258393
* @summary Shenandoah: "graph should be schedulable" assert failure
* @requires vm.flavor == "server"
* @requires vm.gc.Shenandoah
*
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation TestBadRawMemoryAfterCall
*
*/
public class TestBadRawMemoryAfterCall {
public static void main(String[] args) {
A a = new A();
B b = new B();
C c = new C();
for (int i = 0; i < 20_000; i++) {
test(a);
test(b);
test(c);
}
}
private static Object test(A a) {
if (a.getClass() == A.class) {
}
Object o = null;
try {
a.m();
o = a.getClass();
} catch (Exception e) {
}
return o;
}
private static class A {
void m() throws Exception {
throw new Exception();
}
}
private static class B extends A {
void m() {
}
}
private static class C extends B {
void m() {
}
}
}

View File

@ -1,254 +0,0 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, BELLSOFT. 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 8256264
* @requires (os.family == "windows")
* @summary Check that a GlyphVector outline is printed with good quility on low dpi printers
* @run main/othervm/manual PathPrecisionScaleFactorTest
*/
import javax.print.PrintServiceLookup;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class PathPrecisionScaleFactorTest {
private static final String DESCRIPTION =
" 1. Setup 'Microsoft Print to PDF' printer on Windows.\n" +
" 2. Press Print button to print the text to PDF.\n" +
" 3. Choose 'Microsoft Print to PDF' on the print dialog and press OK\n" +
" Two strings should be printed." +
" The first line is printed using drawString() method" +
" and the second line is printed using filling glyph vector outline.\n" +
" 3. Open the PDF file, zoom in the text and check that chars on the second line " +
" (especially 'a' and 's') are not distorted and have the similar quality" +
" as on the first line.\n" +
" 4. If so, press PASS button, otherwise press FAIL button.\n";
private static final CountDownLatch testEndedSignal = new CountDownLatch(1);
private static final int testTimeout = 300000;
private static volatile String testFailureMsg;
private static volatile boolean testPassed;
private static volatile boolean testFinished;
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(() -> createAndShowTestDialog());
try {
if (!testEndedSignal.await(testTimeout, TimeUnit.MILLISECONDS)) {
throw new RuntimeException(String.format(
"Test timeout '%d ms' elapsed.", testTimeout));
}
if (!testPassed) {
String failureMsg = testFailureMsg;
if ((failureMsg != null) && (!failureMsg.trim().isEmpty())) {
throw new RuntimeException(failureMsg);
} else {
throw new RuntimeException("Test failed.");
}
}
} catch (InterruptedException ie) {
throw new RuntimeException(ie);
} finally {
testFinished = true;
}
}
private static void pass() {
testPassed = true;
testEndedSignal.countDown();
}
private static void fail(String failureMsg) {
testFailureMsg = failureMsg;
testPassed = false;
testEndedSignal.countDown();
}
private static String convertMillisToTimeStr(int millis) {
if (millis < 0) {
return "00:00:00";
}
int hours = millis / 3600000;
int minutes = (millis - hours * 3600000) / 60000;
int seconds = (millis - hours * 3600000 - minutes * 60000) / 1000;
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}
private static void createAndShowTestDialog() {
final JDialog dialog = new JDialog();
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
dialog.dispose();
fail("Main dialog was closed.");
}
});
final JLabel testTimeoutLabel = new JLabel(String.format(
"Test timeout: %s", convertMillisToTimeStr(testTimeout)));
final long startTime = System.currentTimeMillis();
final Timer timer = new Timer(0, null);
timer.setDelay(1000);
timer.addActionListener((e) -> {
int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime);
if ((leftTime < 0) || testFinished) {
timer.stop();
dialog.dispose();
}
testTimeoutLabel.setText(String.format(
"Test timeout: %s", convertMillisToTimeStr(leftTime)));
});
timer.start();
JTextArea textArea = new JTextArea(DESCRIPTION);
textArea.setEditable(false);
final JButton testButton = new JButton("Print");
final JButton passButton = new JButton("PASS");
final JButton failButton = new JButton("FAIL");
testButton.addActionListener((e) -> {
testButton.setEnabled(false);
new Thread(() -> {
try {
doTest();
SwingUtilities.invokeLater(() -> {
passButton.setEnabled(true);
failButton.setEnabled(true);
});
} catch (Throwable t) {
t.printStackTrace();
dialog.dispose();
fail("Exception occurred in a thread executing the test.");
}
}).start();
});
passButton.setEnabled(false);
passButton.addActionListener((e) -> {
dialog.dispose();
pass();
});
failButton.setEnabled(false);
failButton.addActionListener((e) -> {
dialog.dispose();
fail("TitledBorder label is cut off");
});
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel labelPanel = new JPanel(new FlowLayout());
labelPanel.add(testTimeoutLabel);
mainPanel.add(labelPanel, BorderLayout.NORTH);
mainPanel.add(textArea, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(testButton);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
dialog.pack();
dialog.setVisible(true);
}
private static void doTest() throws Exception {
SwingUtilities.invokeAndWait(() -> {
try {
new PathPrecisionScaleFactorPrintable();
} catch (PrinterException e) {
throw new RuntimeException(e);
}
});
}
private static class PathPrecisionScaleFactorPrintable implements Printable {
PathPrecisionScaleFactorPrintable() throws PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
job.setPrintable(this);
if (job.printDialog()) {
job.print();
} else {
throw new RuntimeException("Printing was canceled!");
}
}
void paint(Graphics2D g) {
String text = "abcdefghijklmnopqrstuvwxyz";
Font font = new Font("Times New Roman", Font.PLAIN, 8);
drawText(g, font, text);
}
private static void drawText(Graphics2D g, Font font, String text) {
g.setFont(font);
FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, true);
Rectangle clip = g.getClipBounds();
int cx = (int) clip.getCenterX();
int cy = (int) clip.getCenterY();
FontMetrics metrics = g.getFontMetrics();
int w = metrics.stringWidth(text);
int h = metrics.getHeight();
int x = cx - w / 2;
int y = cy - h / 2;
g.drawString(text + " [draw string]", x, y);
GlyphVector gv = font.createGlyphVector(frc, text + " [glyph vector]");
g.fill(gv.getOutline(x, y + h));
}
@Override
public int print(Graphics graphics, PageFormat pageFormat, int index) {
if (index == 0) {
paint((Graphics2D) graphics);
return PAGE_EXISTS;
} else {
return NO_SUCH_PAGE;
}
}
}
}

View File

@ -464,12 +464,52 @@ public class TestByteBuffer {
MemorySegment.mapFile(f.toPath(), -1, 1, FileChannel.MapMode.READ_WRITE);
}
@Test
public void testMapOffset() throws IOException {
File f = new File("testMapOffset.out");
f.createNewFile();
f.deleteOnExit();
int SIZE = Byte.MAX_VALUE;
try (MemorySegment segment = MemorySegment.mapFile(f.toPath(), 0, SIZE, FileChannel.MapMode.READ_WRITE)) {
for (byte offset = 0; offset < SIZE; offset++) {
MemoryAccess.setByteAtOffset(segment, offset, offset);
}
MappedMemorySegments.force(segment);
}
for (int offset = 0 ; offset < SIZE ; offset++) {
try (MemorySegment segment = MemorySegment.mapFile(f.toPath(), offset, SIZE - offset, FileChannel.MapMode.READ_ONLY)) {
assertEquals(MemoryAccess.getByte(segment), offset);
}
}
}
@Test
public void testMapZeroSize() throws IOException {
File f = new File("testPos1.out");
f.createNewFile();
f.deleteOnExit();
//RW
try (MemorySegment segment = MemorySegment.mapFile(f.toPath(), 0L, 0L, FileChannel.MapMode.READ_WRITE)) {
assertEquals(segment.byteSize(), 0);
assertEquals(segment.isMapped(), true);
assertTrue((segment.accessModes() & (READ | WRITE)) == (READ | WRITE));
MappedMemorySegments.force(segment);
MappedMemorySegments.load(segment);
MappedMemorySegments.isLoaded(segment);
MappedMemorySegments.unload(segment);
}
//RO
try (MemorySegment segment = MemorySegment.mapFile(f.toPath(), 0L, 0L, FileChannel.MapMode.READ_ONLY)) {
assertEquals(segment.byteSize(), 0);
assertEquals(segment.isMapped(), true);
assertTrue((segment.accessModes() & (READ | WRITE)) == READ);
MappedMemorySegments.force(segment);
MappedMemorySegments.load(segment);
MappedMemorySegments.isLoaded(segment);
MappedMemorySegments.unload(segment);
}
}

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2021, 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 8259224
* @summary A receiver type's owner type is of the correct type for nested classes.
*/
import java.lang.reflect.AnnotatedParameterizedType;
import java.lang.reflect.AnnotatedType;
public class TestReceiverTypeOwnerType<T> {
public static void main(String[] args) throws Exception {
AnnotatedType nested = Class.forName(TestReceiverTypeOwnerType.class.getTypeName() + "$Nested").getMethod("method").getAnnotatedReceiverType();
if (!(nested instanceof AnnotatedParameterizedType)) {
throw new AssertionError();
} else if (!(nested.getAnnotatedOwnerType() instanceof AnnotatedParameterizedType)) {
throw new AssertionError();
}
AnnotatedType inner = Inner.class.getMethod("method").getAnnotatedReceiverType();
if (inner instanceof AnnotatedParameterizedType) {
throw new AssertionError();
} else if (inner.getAnnotatedOwnerType() instanceof AnnotatedParameterizedType) {
throw new AssertionError();
}
AnnotatedType nestedInner = GenericInner.class.getMethod("method").getAnnotatedReceiverType();
if (!(nestedInner instanceof AnnotatedParameterizedType)) {
throw new AssertionError();
} else if (nestedInner.getAnnotatedOwnerType() instanceof AnnotatedParameterizedType) {
throw new AssertionError();
}
}
public class Nested {
public void method(TestReceiverTypeOwnerType<T>.Nested this) { }
}
public static class Inner {
public void method(TestReceiverTypeOwnerType.Inner this) { }
}
public static class GenericInner<S> {
public void method(TestReceiverTypeOwnerType.GenericInner<S> this) { }
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, 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
@ -23,7 +23,7 @@
/* @test
* @summary Binary data and view tests for byte buffers
* @bug 8159257
* @bug 8159257 8258955
* @run testng ByteBufferViews
*/
@ -174,6 +174,11 @@ public class ByteBufferViews {
bb -> bb.asShortBuffer()),
Map.entry("bb.asShortBuffer().slice()",
bb -> bb.asShortBuffer().slice()),
Map.entry("bb.asShortBuffer().slice(index,length)",
bb -> { var sb = bb.asShortBuffer();
sb = sb.slice(1, sb.limit() - 1);
bb.position(bb.position() + 2);
return sb; }),
Map.entry("bb.asShortBuffer().slice().duplicate()",
bb -> bb.asShortBuffer().slice().duplicate())
);
@ -273,6 +278,11 @@ public class ByteBufferViews {
bb -> bb.asCharBuffer()),
Map.entry("bb.asCharBuffer().slice()",
bb -> bb.asCharBuffer().slice()),
Map.entry("bb.asCharBuffer().slice(index,length)",
bb -> { var cb = bb.asCharBuffer();
cb = cb.slice(1, cb.limit() - 1);
bb.position(bb.position() + 2);
return cb; }),
Map.entry("bb.asCharBuffer().slice().duplicate()",
bb -> bb.asCharBuffer().slice().duplicate())
);
@ -365,6 +375,11 @@ public class ByteBufferViews {
bb -> bb.asIntBuffer()),
Map.entry("bb.asIntBuffer().slice()",
bb -> bb.asIntBuffer().slice()),
Map.entry("bb.asIntBuffer().slice(index,length)",
bb -> { var ib = bb.asIntBuffer();
ib = ib.slice(1, ib.limit() - 1);
bb.position(bb.position() + 4);
return ib; }),
Map.entry("bb.asIntBuffer().slice().duplicate()",
bb -> bb.asIntBuffer().slice().duplicate())
);
@ -467,6 +482,11 @@ public class ByteBufferViews {
bb -> bb.asLongBuffer()),
Map.entry("bb.asLongBuffer().slice()",
bb -> bb.asLongBuffer().slice()),
Map.entry("bb.asLongBuffer().slice(index,length)",
bb -> { var lb = bb.asLongBuffer();
lb = lb.slice(1, lb.limit() - 1);
bb.position(bb.position() + 8);
return lb; }),
Map.entry("bb.asLongBuffer().slice().duplicate()",
bb -> bb.asLongBuffer().slice().duplicate())
);
@ -575,6 +595,11 @@ public class ByteBufferViews {
bb -> bb.asFloatBuffer()),
Map.entry("bb.asFloatBuffer().slice()",
bb -> bb.asFloatBuffer().slice()),
Map.entry("bb.asFloatBuffer().slice(index,length)",
bb -> { var fb = bb.asFloatBuffer();
fb = fb.slice(1, fb.limit() - 1);
bb.position(bb.position() + 4);
return fb; }),
Map.entry("bb.asFloatBuffer().slice().duplicate()",
bb -> bb.asFloatBuffer().slice().duplicate())
);
@ -668,6 +693,11 @@ public class ByteBufferViews {
bb -> bb.asDoubleBuffer()),
Map.entry("bb.asDoubleBuffer().slice()",
bb -> bb.asDoubleBuffer().slice()),
Map.entry("bb.asDoubleBuffer().slice(index,length)",
bb -> { var db = bb.asDoubleBuffer();
db = db.slice(1, db.limit() - 1);
bb.position(bb.position() + 8);
return db; }),
Map.entry("bb.asDoubleBuffer().slice().duplicate()",
bb -> bb.asDoubleBuffer().slice().duplicate())
);

View File

@ -25,7 +25,7 @@
* @test
* @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363
* 8167967 8172528 8175200 8178830 8182257 8186332 8182765 8025091
* 8203791 8184205
* 8203791 8184205 8249633
* @summary Test of the JavaFX doclet features.
* @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@ -33,6 +33,10 @@
* @run main TestJavaFX
*/
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javadoc.tester.JavadocTester;
public class TestJavaFX extends JavadocTester {
@ -366,4 +370,56 @@ public class TestJavaFX extends JavadocTester {
// make sure the doclet indeed emits the warning
checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag <");
}
/*
* Verify that no warnings are produced on methods that may have synthesized comments.
*/
@Test
public void test5() throws IOException {
Path src5 = Files.createDirectories(Path.of("src5").resolve("pkg"));
Files.writeString(src5.resolve("MyClass.java"),
"""
package pkg;
// The following import not required with --disable-javafx-strict-checks
// import javafx.beans.property.*;
/**
* This is my class.
*/
public class MyClass {
/**
* This is my property that enables something
*/
private BooleanProperty something = new SimpleBooleanProperty(false);
public final boolean isSomething() {
return something.get();
}
public final void setSomething(boolean val) {
something.set(val);
}
public final BooleanProperty somethingProperty() {
return something;
}
/** Dummy declaration. */
public class BooleanProperty { }
}
""");
javadoc("-d", "out5",
"--javafx",
"--disable-javafx-strict-checks",
"-Xdoclint:all",
"--source-path", "src5",
"pkg");
checkExit(Exit.OK);
checkOutput(Output.OUT, false,
"warning",
"no comment");
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2018, 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 8251200
* @summary False positive messages about missing comments for serialization
* @library /tools/lib ../../lib/
* @modules jdk.javadoc/jdk.javadoc.internal.api
* jdk.javadoc/jdk.javadoc.internal.tool
* @build javadoc.tester.*
* @build toolbox.ToolBox javadoc.tester.*
* @run main TestSerialMissing
*/
import java.io.IOException;
import java.nio.file.Path;
import javadoc.tester.JavadocTester;
import toolbox.ToolBox;
public class TestSerialMissing extends JavadocTester {
public static void main(String... args) throws Exception {
TestSerialMissing tester = new TestSerialMissing();
tester.runTests(m -> new Object[] { Path.of(m.getName()) } );
}
ToolBox tb = new ToolBox();
@Test
public void testPackagePrivate(Path base) throws IOException {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"""
/** Module m. */
module m { exports p; }
""",
"""
package p;
/** PUBLIC class. */
public class PUBLIC extends Exception { }
""",
"""
package p;
// no comment: class should not be documented
class PACKAGE_PRIVATE extends Exception { }
""");
javadoc("-d", base.resolve("api").toString(),
"-sourcepath", src.toString(),
"--module", "m");
checkExit(Exit.OK);
// should not be any reference to PACKAGE_PRIVATE.java, such as for no comment
checkOutput(Output.OUT, false,
"PACKAGE_PRIVATE");
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2020, 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 8213032
* @summary program fails with LambdaConversionException at execution time
*/
import java.util.stream.*;
public class MethodReferenceIntersection4 {
interface I {}
static abstract class C { }
static class A extends C implements I { }
static class B extends C implements I { }
static String f(I i) { return null; }
public static void main(String[] args) {
Stream.of(new A(), new B())
.map(MethodReferenceIntersection4::f)
.forEach(System.out::println);
}
}

View File

@ -0,0 +1,152 @@
/*
* Copyright (c) 2020, 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 8256266
* @summary Verify annotations work correctly on binding variables
* @library /tools/javac/lib
* @modules java.compiler
* jdk.compiler
* jdk.jdeps/com.sun.tools.classfile
* @build JavacTestingAbstractProcessor
* @compile Annotations.java
* @compile -processor Annotations -proc:only Annotations.java
* @run main Annotations
*/
import com.sun.source.tree.InstanceOfTree;
import com.sun.source.util.TreePath;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Set;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
import com.sun.source.tree.BindingPatternTree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePathScanner;
import com.sun.source.util.Trees;
import com.sun.tools.classfile.*;
import java.io.InputStream;
import java.util.Arrays;
public class Annotations extends JavacTestingAbstractProcessor {
public static void main(String... args) throws Exception {
new Annotations().run();
}
void run() throws Exception {
InputStream annotationsClass =
Annotations.class.getResourceAsStream("Annotations.class");
ClassFile cf = ClassFile.read(annotationsClass);
for (Method m : cf.methods) {
if ("test".equals(cf.constant_pool.getUTF8Value(m.name_index))) {
Code_attribute codeAttr =
(Code_attribute) m.attributes.map.get(Attribute.Code);
Attribute annoAttr =
codeAttr.attributes.map.get(Attribute.RuntimeInvisibleTypeAnnotations);
RuntimeInvisibleTypeAnnotations_attribute annotations =
(RuntimeInvisibleTypeAnnotations_attribute) annoAttr;
String expected = "[@Annotations$DTA; pos: [LOCAL_VARIABLE, {start_pc = 35, length = 7, index = 1}, pos = -1], " +
"@Annotations$TA; pos: [LOCAL_VARIABLE, {start_pc = 56, length = 7, index = 1}, pos = -1]]";
String actual = Arrays.toString(annotations.annotations);
if (!expected.equals(actual)) {
throw new AssertionError("Unexpected type annotations: " +
actual);
}
}
}
}
private static void test(Object o) {
if (o instanceof @DA String da) {
System.err.println(da);
}
if (o instanceof @DTA String dta) {
System.err.println(dta);
}
if (o instanceof @TA String ta) {
System.err.println(ta);
}
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Trees trees = Trees.instance(processingEnv);
for (Element root : roundEnv.getRootElements()) {
TreePath tp = trees.getPath(root);
new TreePathScanner<Void, Void>() {
@Override
public Void visitInstanceOf(InstanceOfTree node, Void p) {
BindingPatternTree bpt = (BindingPatternTree) node.getPattern();
VariableTree var = bpt.getVariable();
Element varEl = trees.getElement(new TreePath(getCurrentPath(), var));
String expectedDeclAnnos;
String expectedType;
switch (var.getName().toString()) {
case "da" -> {
expectedDeclAnnos = "@Annotations.DA";
expectedType = "java.lang.String";
}
case "dta" -> {
expectedDeclAnnos = "@Annotations.DTA";
expectedType = "@Annotations.DTA java.lang.String";
}
case "ta" -> {
expectedDeclAnnos = "";
expectedType = "@Annotations.TA java.lang.String";
}
default -> {
throw new AssertionError("Unexpected variable: " + var);
}
}
String declAnnos = varEl.getAnnotationMirrors().toString();
if (!expectedDeclAnnos.equals(declAnnos)) {
throw new AssertionError("Unexpected modifiers: " + declAnnos +
" for: " + var.getName());
}
TypeMirror varType = varEl.asType();
String type = varType.toString();
if (!expectedType.equals(type)) {
throw new AssertionError("Unexpected type: " + type +
" for: " + var.getName());
}
return super.visitInstanceOf(node, p);
}
}.scan(tp.getCompilationUnit(), null);
}
return false;
}
@Target(ElementType.LOCAL_VARIABLE)
@interface DA {}
@Target({ElementType.TYPE_USE, ElementType.LOCAL_VARIABLE})
@interface DTA {}
@Target(ElementType.TYPE_USE)
@interface TA {}
}

View File

@ -185,6 +185,21 @@ public class BindingsTest1 {
String s2 = s;
}
if (o1 instanceof final String s) {
Runnable r1 = new Runnable() {
@Override
public void run() {
s.length();
}
};
r1.run();
Runnable r2 = () -> {
s.length();
};
r2.run();
String s2 = s;
}
boolean result = (o1 instanceof String a1) ? (o1 instanceof String a2) : (!(o1 instanceof String a3));
boolean result2 = (o1 instanceof String a1) ? (o1 instanceof String a2) : (!(switch (0) { default -> false; }));

View File

@ -241,5 +241,11 @@ public class BindingsTest2 {
s.length();
}
}
{
if (o1 instanceof final String s) {
s = "";
}
}
}
}

View File

@ -46,7 +46,8 @@ BindingsTest2.java:212:13: compiler.err.cant.resolve.location: kindname.variable
BindingsTest2.java:221:17: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
BindingsTest2.java:231:17: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
BindingsTest2.java:241:17: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
BindingsTest2.java:247:17: compiler.err.cant.assign.val.to.final.var: s
BindingsTest2.java:135:17: compiler.err.unreachable.stmt
BindingsTest2.java:160:17: compiler.err.unreachable.stmt
BindingsTest2.java:185:17: compiler.err.unreachable.stmt
51 errors
52 errors

View File

@ -0,0 +1,24 @@
/* @test /nodynamiccopyright/
* @bug 8256266
* @summary Binding variables cannot have (non-annotation) modifiers.
* @compile/fail/ref=NoModifiersOnBinding.out -XDrawDiagnostics NoModifiersOnBinding.java
*/
public class NoModifiersOnBinding {
private static void test(Object o) {
if (o instanceof final String) {
System.err.println(s);
}
if (o instanceof /**@deprecated*/ String) {
System.err.println(s);
}
if (o instanceof static String s) {
System.err.println(s);
}
if (o instanceof /**@deprecated*/ String s) {
System.err.println(s);
}
}
}

View File

@ -0,0 +1,3 @@
NoModifiersOnBinding.java:10:32: compiler.err.mod.not.allowed.here: final
NoModifiersOnBinding.java:16:33: compiler.err.mod.not.allowed.here: static
2 errors