[libvirt] [java] [PATCH 1/2] Fix compilation error for unreported exceptions

Claudio Bley claudio.bley at gmail.com
Thu Sep 10 20:07:11 UTC 2015


In Java 1.6 source mode, javac reported the error:

```
src/main/java/org/libvirt/Library.java:93: unreported exception java.lang.Exception; must be caught or declared to be thrown
```

Since the code inside the try block does not throw any checked
exceptions, we only need to handle unchecked exceptions on the catch
side, ie. RuntimeExceptions.
---
 src/main/java/org/libvirt/Library.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/libvirt/Library.java b/src/main/java/org/libvirt/Library.java
index 7ce986d..8e054c6 100644
--- a/src/main/java/org/libvirt/Library.java
+++ b/src/main/java/org/libvirt/Library.java
@@ -86,7 +86,7 @@ public final class Library {
                 result[i] = cstrarr[i].toString();
             }
             return result;
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
             for (; i < size; ++i) {
                 if (cstrarr[i] != null) cstrarr[i].free();
             }
-- 
2.5.1




More information about the libvir-list mailing list