changeset 33353:b4683c8bf531

eliminate uses of panic_impossible in ov-java.cc * ov-java.cc (error_unexpected): New static function. Use it to replace panic_impossible in functions that should never be called unless HAVE_JAVA is defined.
author John W. Eaton <jwe@octave.org>
date Mon, 08 Apr 2024 10:07:45 -0400
parents 05da909b8c28
children 4b134186195c
files libinterp/octave-value/ov-java.cc
diffstat 1 files changed, 30 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-java.cc	Sun Apr 07 13:33:33 2024 -0400
+++ b/libinterp/octave-value/ov-java.cc	Mon Apr 08 10:07:45 2024 -0400
@@ -641,6 +641,7 @@
 
   return jvm_lib_path;
 }
+
 #endif
 
 //! Initialize the java virtual machine (jvm) and field #jvm if necessary.
@@ -905,6 +906,12 @@
 
 #endif
 
+OCTAVE_NORETURN static void
+error_unexpected (const char *name)
+{
+  error ("unexpected call to %s when HAVE_JAVA is not defined - please report this bug", name);
+}
+
 bool
 octave_java::is_java_string () const
 {
@@ -925,7 +932,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::is_java_string");
 
 #endif
 }
@@ -957,7 +964,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::is_instance_of");
 
 #endif
 }
@@ -2183,7 +2190,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::dims");
 
 #endif
 }
@@ -2248,7 +2255,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::subsref");
 
 #endif
 }
@@ -2338,7 +2345,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::subsasgn");
 
 #endif
 }
@@ -2360,7 +2367,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::map_keys");
 
 #endif
 }
@@ -2386,7 +2393,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::convert_to_str_internal");
 
 #endif
 }
@@ -2496,7 +2503,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_javaMethod");
 
 #endif
 }
@@ -2517,7 +2524,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_javaMethod");
 
 #endif
 }
@@ -2577,7 +2584,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_javaMethod");
 
 #endif
 }
@@ -2600,7 +2607,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_javaMethod");
 
 #endif
 }
@@ -2656,7 +2663,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_javaObject");
 
 #endif
 }
@@ -2677,7 +2684,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_javaObject");
 
 #endif
 }
@@ -2723,7 +2730,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_get");
 
 #endif
 }
@@ -2742,7 +2749,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_get");
 
 #endif
 }
@@ -2790,7 +2797,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_get");
 
 #endif
 }
@@ -2811,7 +2818,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_get");
 
 #endif
 }
@@ -2858,7 +2865,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_set");
 
 #endif
 }
@@ -2878,7 +2885,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_set");
 
 #endif
 }
@@ -2929,7 +2936,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_set");
 
 #endif
 }
@@ -2952,7 +2959,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::do_java_set");
 
 #endif
 }
@@ -3002,7 +3009,7 @@
   // This shouldn't happen because construction of octave_java
   // objects is supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::init");
 
 #endif
 }
@@ -3031,7 +3038,7 @@
   // This shouldn't happen because construction of octave_java objects is
   // supposed to be impossible if Java is not available.
 
-  panic_impossible ();
+  error_unexpected ("octave_java::release");
 
 #endif
 }