[RFA/JVMTI] New JVMTI Environment Initialization/Allocation

Andrew Haley aph@redhat.com
Fri Sep 1 09:18:00 GMT 2006


Tom Tromey writes:
 > >>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
 > 
 > Keith> I've also snuck in another little patch which adds another common test
 > Keith> macro, this time for JVMTI_ERROR_ILLEGAL_ARGUMENT.
 > 
 > I noticed that this macro has no trailing ';' but NULL_CHECK does have
 > one.  The semicolon should probably be removed from NULL_CHECK.

These macros are dangerous because of hidden dangling else:

#define NULL_CHECK(Ptr)					\
  if (Ptr == NULL) return JVMTI_ERROR_NULL_POINTER;

They should be, e.g.,

#define NULL_CHECK(Ptr)
do						\
  {						\
    if (Ptr == NULL)				\
      return JVMTI_ERROR_NULL_POINTER;		\
  }						\
while (0)

Otherwise, something like

  if (poo)
    NULL_CHECK (p);
  else
    barf ();

may not do as you expected.

Andrew.



More information about the Java-patches mailing list