diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk index 7eaf5119a0f..23c61f4bb7d 100644 --- a/make/lib/Awt2dLibraries.gmk +++ b/make/lib/Awt2dLibraries.gmk @@ -571,7 +571,8 @@ else # noexcept-type required for GCC 7 builds. Not required for GCC 8+. # expansion-to-defined required for GCC 9 builds. Not required for GCC 10+. HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \ - maybe-uninitialized class-memaccess unused-result extra noexcept-type expansion-to-defined + maybe-uninitialized class-memaccess unused-result extra use-after-free noexcept-type \ + expansion-to-defined HARFBUZZ_DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \ tautological-constant-out-of-range-compare int-to-pointer-cast \ undef missing-field-initializers deprecated-declarations c++11-narrowing range-loop-analysis diff --git a/src/hotspot/share/oops/array.hpp b/src/hotspot/share/oops/array.hpp index d6f68dce9c5..3f44705f916 100644 --- a/src/hotspot/share/oops/array.hpp +++ b/src/hotspot/share/oops/array.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2022, 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 @@ -94,7 +94,7 @@ class Array: public MetaspaceObj { Array(int length, T init) : _length(length) { assert(length >= 0, "illegal length"); for (int i = 0; i < length; i++) { - _data[i] = init; + data()[i] = init; } } @@ -102,12 +102,22 @@ class Array: public MetaspaceObj { // standard operations int length() const { return _length; } - T* data() { return _data; } + + T* data() { + return reinterpret_cast( + reinterpret_cast(this) + base_offset_in_bytes()); + } + + const T* data() const { + return reinterpret_cast( + reinterpret_cast(this) + base_offset_in_bytes()); + } + bool is_empty() const { return length() == 0; } int index_of(const T& x) const { int i = length(); - while (i-- > 0 && _data[i] != x) ; + while (i-- > 0 && data()[i] != x) ; return i; } @@ -115,9 +125,9 @@ class Array: public MetaspaceObj { // sort the array. bool contains(const T& x) const { return index_of(x) >= 0; } - T at(int i) const { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return _data[i]; } - void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); _data[i] = x; } - T* adr_at(const int i) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return &_data[i]; } + T at(int i) const { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return data()[i]; } + void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); data()[i] = x; } + T* adr_at(const int i) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return &data()[i]; } int find(const T& x) { return index_of(x); } T at_acquire(const int which); diff --git a/src/hotspot/share/utilities/globalDefinitions.cpp b/src/hotspot/share/utilities/globalDefinitions.cpp index 6a74d4252e6..9b446fe06b7 100644 --- a/src/hotspot/share/utilities/globalDefinitions.cpp +++ b/src/hotspot/share/utilities/globalDefinitions.cpp @@ -199,6 +199,17 @@ const char* type2name_tab[T_CONFLICT+1] = { "*narrowklass*", "*conflict*" }; +const char* type2name(BasicType t) { + if (t < ARRAY_SIZE(type2name_tab)) { + return type2name_tab[t]; + } else if (t == T_ILLEGAL) { + return "*illegal*"; + } else { + fatal("invalid type %d", t); + return "invalid type"; + } +} + BasicType name2type(const char* name) { diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index c758fc57432..cf3be060ab8 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -681,10 +681,11 @@ inline BasicType char2type(char c) { extern char type2char_tab[T_CONFLICT+1]; // Map a BasicType to a jchar inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; } extern int type2size[T_CONFLICT+1]; // Map BasicType to result stack elements -extern const char* type2name_tab[T_CONFLICT+1]; // Map a BasicType to a jchar -inline const char* type2name(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2name_tab[t] : NULL; } +extern const char* type2name_tab[T_CONFLICT+1]; // Map a BasicType to a char* extern BasicType name2type(const char* name); +const char* type2name(BasicType t); + // Auxiliary math routines // least common multiple extern size_t lcm(size_t a, size_t b); diff --git a/src/java.base/unix/native/libjli/java_md_common.c b/src/java.base/unix/native/libjli/java_md_common.c index 48e57e380ff..012c49c68e4 100644 --- a/src/java.base/unix/native/libjli/java_md_common.c +++ b/src/java.base/unix/native/libjli/java_md_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022, 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 @@ -125,10 +125,13 @@ ProgramExists(char *name) static char * Resolve(char *indir, char *cmd) { - char name[PATH_MAX + 2], *real; + char name[PATH_MAX + 1], *real; + int snprintf_result; - if ((JLI_StrLen(indir) + JLI_StrLen(cmd) + 1) > PATH_MAX) return 0; - JLI_Snprintf(name, sizeof(name), "%s%c%s", indir, FILE_SEPARATOR, cmd); + snprintf_result = JLI_Snprintf(name, sizeof(name), "%s%c%s", indir, FILE_SEPARATOR, cmd); + if ((snprintf_result < 0) || (snprintf_result >= (int)sizeof(name))) { + return NULL; + } if (!ProgramExists(name)) return 0; real = JLI_MemAlloc(PATH_MAX + 2); if (!realpath(name, real))