8033758: gcc warnings compiling jdk/src/share/back
Alan Bateman
Alan.Bateman at oracle.com
Thu Feb 6 02:04:13 PST 2014
This is a drive-by fix to the JDWP agent to fix 50+ warnings that have
been annoying me, see:
https://bugs.openjdk.java.net/browse/JDK-8033758
The bulk of the warnings stem from using a switch statement to switch on
JVMTI and JDWP internal "agent" errors. The agent errors are arranged
(in util.h) so that they have integer values beyond the range of the
JVMTI errors.
There are several ways to deal with this, including suppressing the
warning. I toyed with splitting the switch statement into two so that
the JVMTI and agent errors are handled separately. It didn't seem to be
worth and the simplest is just to cast the jvmtiError to an int.
The other warning (in ArrayTypeImpl's writeNewObjectArray) is just that
the compiler doesn't know if componentClass has been set in
getComponentClass. The simplest thing here is just to initialize to NULL.
The proposed changes are below.
-Alan
diff --git a/src/share/back/ArrayTypeImpl.c b/src/share/back/ArrayTypeImpl.c
--- a/src/share/back/ArrayTypeImpl.c
+++ b/src/share/back/ArrayTypeImpl.c
@@ -112,7 +112,7 @@
WITH_LOCAL_REFS(env, 1) {
jarray array;
- jclass componentClass;
+ jclass componentClass = NULL;
jdwpError serror;
serror = getComponentClass(env, arrayClass,
diff --git a/src/share/back/error_messages.c
b/src/share/back/error_messages.c
--- a/src/share/back/error_messages.c
+++ b/src/share/back/error_messages.c
@@ -140,7 +140,7 @@
const char *
jvmtiErrorText(jvmtiError error)
{
- switch (error) {
+ switch ((int)error) {
CASE_RETURN_TEXT(JVMTI_ERROR_NONE)
CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD)
CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD_GROUP)
diff --git a/src/share/back/util.c b/src/share/back/util.c
--- a/src/share/back/util.c
+++ b/src/share/back/util.c
@@ -2122,7 +2122,7 @@
jdwpError
map2jdwpError(jvmtiError error)
{
- switch ( error ) {
+ switch ( (int)error ) {
case JVMTI_ERROR_NONE:
return JDWP_ERROR(NONE);
case AGENT_ERROR_INVALID_THREAD:
More information about the serviceability-dev
mailing list