From 10d9af57ca4bbce72cca4d21b8a609a4611da024 Mon Sep 17 00:00:00 2001 From: "Brian P. Hinz" Date: Sat, 26 Dec 2015 21:49:49 -0500 Subject: [PATCH] Suppress/eliminate JDK warnings --- java/CMakeLists.txt | 2 +- java/com/jcraft/jsch/HostKey.java | 2 +- java/com/jcraft/jsch/KeyPair.java | 12 ++++++------ java/com/jcraft/jsch/KeyPairDSA.java | 6 +++--- java/com/jcraft/jsch/KeyPairECDSA.java | 6 +++--- java/com/jcraft/jsch/KeyPairPKCS8.java | 4 ++-- java/com/jcraft/jsch/KeyPairRSA.java | 6 +++--- java/com/jcraft/jsch/KnownHosts.java | 2 +- java/com/jcraft/jsch/Session.java | 4 ++-- java/com/tigervnc/rdr/Exception.java | 6 ------ java/com/tigervnc/rdr/TimedOut.java | 26 ++++++++++++++++++++++++++ 11 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 java/com/tigervnc/rdr/TimedOut.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index a076d958..8f698ac5 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -7,7 +7,7 @@ endif() find_package(Java) -set(DEFAULT_JAVACFLAGS "-source 1.5 -target 1.5 -Xlint:all,-serial,-cast,-unchecked,-fallthrough,-dep-ann,-deprecation,-rawtypes") +set(DEFAULT_JAVACFLAGS "-source 1.6 -target 1.6 -Xlint:all,-serial,-cast,-unchecked,-fallthrough,-dep-ann,-deprecation,-rawtypes") set(JAVACFLAGS ${DEFAULT_JAVACFLAGS} CACHE STRING "Java compiler flags (Default: ${DEFAULT_JAVACFLAGS})") message(STATUS "Java compiler flags = ${JAVACFLAGS}") diff --git a/java/com/jcraft/jsch/HostKey.java b/java/com/jcraft/jsch/HostKey.java index 6269469a..bf7ab28c 100644 --- a/java/com/jcraft/jsch/HostKey.java +++ b/java/com/jcraft/jsch/HostKey.java @@ -103,7 +103,7 @@ public class HostKey{ public String getKey(){ return Util.byte2str(Util.toBase64(key, 0, key.length)); } - public String getFingerPrint(JSch jsch){ + @SuppressWarnings({"static"}) public String getFingerPrint(JSch jsch){ HASH hash=null; try{ Class c=Class.forName(jsch.getConfig("md5")); diff --git a/java/com/jcraft/jsch/KeyPair.java b/java/com/jcraft/jsch/KeyPair.java index 7c31f15b..3eb3c2dc 100644 --- a/java/com/jcraft/jsch/KeyPair.java +++ b/java/com/jcraft/jsch/KeyPair.java @@ -383,7 +383,7 @@ public abstract class KeyPair{ return j; } - private Random genRandom(){ + @SuppressWarnings({"static"}) private Random genRandom(){ if(random==null){ try{ Class c=Class.forName(jsch.getConfig("random")); @@ -394,7 +394,7 @@ public abstract class KeyPair{ return random; } - private HASH genHash(){ + @SuppressWarnings({"static"}) private HASH genHash(){ try{ Class c=Class.forName(jsch.getConfig("md5")); hash=(HASH)(c.newInstance()); @@ -404,7 +404,7 @@ public abstract class KeyPair{ } return hash; } - private Cipher genCipher(){ + @SuppressWarnings({"static"}) private Cipher genCipher(){ try{ Class c; c=Class.forName(jsch.getConfig("3des-cbc")); @@ -421,7 +421,7 @@ public abstract class KeyPair{ h(n) <- hash(h(n-1), passphrase, iv); key <- (h(0),...,h(n))[0,..,key.length]; */ - synchronized byte[] genKey(byte[] passphrase, byte[] iv){ + @SuppressWarnings({"static"}) synchronized byte[] genKey(byte[] passphrase, byte[] iv){ if(cipher==null) cipher=genCipher(); if(hash==null) hash=genHash(); @@ -565,7 +565,7 @@ public abstract class KeyPair{ } } - public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchException{ + @SuppressWarnings({"static"}) public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchException{ byte[] iv=new byte[8]; // 8 boolean encrypted=true; @@ -985,7 +985,7 @@ public abstract class KeyPair{ "Private-MAC: " }; - static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException { + @SuppressWarnings({"static"}) static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException { byte[] pubkey = null; byte[] prvkey = null; int lines = 0; diff --git a/java/com/jcraft/jsch/KeyPairDSA.java b/java/com/jcraft/jsch/KeyPairDSA.java index ca5b708c..15922269 100644 --- a/java/com/jcraft/jsch/KeyPairDSA.java +++ b/java/com/jcraft/jsch/KeyPairDSA.java @@ -59,7 +59,7 @@ public class KeyPairDSA extends KeyPair{ key_size = (new java.math.BigInteger(P_array)).bitLength(); } - void generate(int key_size) throws JSchException{ + @SuppressWarnings({"static"}) void generate(int key_size) throws JSchException{ this.key_size=key_size; try{ Class c=Class.forName(jsch.getConfig("keypairgen.dsa")); @@ -247,7 +247,7 @@ public class KeyPairDSA extends KeyPair{ return key_size; } - public byte[] getSignature(byte[] data){ + @SuppressWarnings({"static"}) public byte[] getSignature(byte[] data){ try{ Class c=Class.forName((String)jsch.getConfig("signature.dss")); SignatureDSA dsa=(SignatureDSA)(c.newInstance()); @@ -267,7 +267,7 @@ public class KeyPairDSA extends KeyPair{ return null; } - public Signature getVerifier(){ + @SuppressWarnings({"static"}) public Signature getVerifier(){ try{ Class c=Class.forName((String)jsch.getConfig("signature.dss")); SignatureDSA dsa=(SignatureDSA)(c.newInstance()); diff --git a/java/com/jcraft/jsch/KeyPairECDSA.java b/java/com/jcraft/jsch/KeyPairECDSA.java index aa25a6eb..55a52ca4 100644 --- a/java/com/jcraft/jsch/KeyPairECDSA.java +++ b/java/com/jcraft/jsch/KeyPairECDSA.java @@ -71,7 +71,7 @@ public class KeyPairECDSA extends KeyPair{ (prv_array.length>=48 ? 384 : 256); } - void generate(int key_size) throws JSchException{ + @SuppressWarnings({"static"}) void generate(int key_size) throws JSchException{ this.key_size=key_size; try{ Class c=Class.forName(jsch.getConfig("keypairgen.ecdsa")); @@ -282,7 +282,7 @@ public class KeyPairECDSA extends KeyPair{ return key_size; } - public byte[] getSignature(byte[] data){ + @SuppressWarnings({"static"}) public byte[] getSignature(byte[] data){ try{ Class c=Class.forName((String)jsch.getConfig("signature.ecdsa")); SignatureECDSA ecdsa=(SignatureECDSA)(c.newInstance()); @@ -303,7 +303,7 @@ public class KeyPairECDSA extends KeyPair{ return null; } - public Signature getVerifier(){ + @SuppressWarnings({"static"}) public Signature getVerifier(){ try{ Class c=Class.forName((String)jsch.getConfig("signature.ecdsa")); final SignatureECDSA ecdsa=(SignatureECDSA)(c.newInstance()); diff --git a/java/com/jcraft/jsch/KeyPairPKCS8.java b/java/com/jcraft/jsch/KeyPairPKCS8.java index 47c2a933..0aafa717 100644 --- a/java/com/jcraft/jsch/KeyPairPKCS8.java +++ b/java/com/jcraft/jsch/KeyPairPKCS8.java @@ -218,7 +218,7 @@ public class KeyPairPKCS8 extends KeyPair { return kpair.forSSHAgent(); } - public boolean decrypt(byte[] _passphrase){ + @SuppressWarnings({"static"}) public boolean decrypt(byte[] _passphrase){ if(!isEncrypted()){ return true; } @@ -330,7 +330,7 @@ or return false; } - Cipher getCipher(byte[] id){ + @SuppressWarnings({"static"}) Cipher getCipher(byte[] id){ Cipher cipher=null; String name = null; try{ diff --git a/java/com/jcraft/jsch/KeyPairRSA.java b/java/com/jcraft/jsch/KeyPairRSA.java index 4221b75e..97b41203 100644 --- a/java/com/jcraft/jsch/KeyPairRSA.java +++ b/java/com/jcraft/jsch/KeyPairRSA.java @@ -61,7 +61,7 @@ public class KeyPairRSA extends KeyPair{ } } - void generate(int key_size) throws JSchException{ + @SuppressWarnings({"static"}) void generate(int key_size) throws JSchException{ this.key_size=key_size; try{ Class c=Class.forName(jsch.getConfig("keypairgen.rsa")); @@ -316,7 +316,7 @@ public class KeyPairRSA extends KeyPair{ return key_size; } - public byte[] getSignature(byte[] data){ + @SuppressWarnings({"static"}) public byte[] getSignature(byte[] data){ try{ Class c=Class.forName((String)jsch.getConfig("signature.rsa")); SignatureRSA rsa=(SignatureRSA)(c.newInstance()); @@ -335,7 +335,7 @@ public class KeyPairRSA extends KeyPair{ return null; } - public Signature getVerifier(){ + @SuppressWarnings({"static"}) public Signature getVerifier(){ try{ Class c=Class.forName((String)jsch.getConfig("signature.rsa")); SignatureRSA rsa=(SignatureRSA)(c.newInstance()); diff --git a/java/com/jcraft/jsch/KnownHosts.java b/java/com/jcraft/jsch/KnownHosts.java index b86fa25c..c4e06518 100644 --- a/java/com/jcraft/jsch/KnownHosts.java +++ b/java/com/jcraft/jsch/KnownHosts.java @@ -482,7 +482,7 @@ loop: return hosts; } - private synchronized MAC getHMACSHA1(){ + @SuppressWarnings({"static"}) private synchronized MAC getHMACSHA1(){ if(hmacsha1==null){ try{ Class c=Class.forName(jsch.getConfig("hmac-sha1")); diff --git a/java/com/jcraft/jsch/Session.java b/java/com/jcraft/jsch/Session.java index 39e9029a..4da30cb3 100644 --- a/java/com/jcraft/jsch/Session.java +++ b/java/com/jcraft/jsch/Session.java @@ -2308,7 +2308,7 @@ break; } } - public String getConfig(String key){ + @SuppressWarnings({"static"}) public String getConfig(String key){ Object foo=null; if(config!=null){ foo=config.get(key); @@ -2534,7 +2534,7 @@ break; catch(Exception e){ return false; } } - private String[] checkSignatures(String sigs){ + @SuppressWarnings({"static"}) private String[] checkSignatures(String sigs){ if(sigs==null || sigs.length()==0) return null; diff --git a/java/com/tigervnc/rdr/Exception.java b/java/com/tigervnc/rdr/Exception.java index 7fd75f81..31d75ecd 100644 --- a/java/com/tigervnc/rdr/Exception.java +++ b/java/com/tigervnc/rdr/Exception.java @@ -25,12 +25,6 @@ public class Exception extends RuntimeException { } } -class TimedOut extends Exception { - public TimedOut() { - super("Timed out"); - } -} - class FrameException extends Exception { public FrameException() { super("Frame Exception"); diff --git a/java/com/tigervnc/rdr/TimedOut.java b/java/com/tigervnc/rdr/TimedOut.java new file mode 100644 index 00000000..a0230c71 --- /dev/null +++ b/java/com/tigervnc/rdr/TimedOut.java @@ -0,0 +1,26 @@ +/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. + * Copyright (C) 2012 Brian P. Hinz + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +package com.tigervnc.rdr; + +class TimedOut extends Exception { + public TimedOut() { + super("Timed out"); + } +} -- 2.39.5