Skip to content

Commit

Permalink
Java: Eliminate warnings with Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Feb 8, 2024
1 parent d2c5c17 commit 466515c
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 48 deletions.
3 changes: 2 additions & 1 deletion java/com/jcraft/jsch/ChannelSftp.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2024 D. R. Commander. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -33,7 +34,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import java.util.Vector;

public class ChannelSftp extends ChannelSession{
public final class ChannelSftp extends ChannelSession{

static private final int LOCAL_MAXIMUM_PACKET_SIZE=32*1024;
static private final int LOCAL_WINDOW_SIZE_MAX=(64*LOCAL_MAXIMUM_PACKET_SIZE);
Expand Down
4 changes: 2 additions & 2 deletions java/com/jcraft/jsch/JSch.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2018, 2023 D. R. Commander. All rights reserved.
Copyright (c) 2018, 2023-2024 D. R. Commander. All rights reserved.
Copyright (c) 2020-2021 Jeremy Norris. All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -34,7 +34,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import java.io.InputStream;
import java.util.Vector;

public class JSch{
public final class JSch{
/**
* The version number.
*/
Expand Down
4 changes: 2 additions & 2 deletions java/com/jcraft/jsch/Session.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2018, 2023 D. R. Commander. All rights reserved.
Copyright (c) 2018, 2023-2024 D. R. Commander. All rights reserved.
Copyright (c) 2020-2021 Jeremy Norris. All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -1314,7 +1314,7 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key,
}
command=packet.buffer.getCommand();
recipient=c.getRecipient();
length-=len;
length-=(int)len;
c.rwsize-=len;
sendit=true;
}
Expand Down
7 changes: 4 additions & 3 deletions java/com/jcraft/jsch/jce/SignatureDSA.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2024 D. R. Commander. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -131,12 +132,12 @@ public boolean verify(byte[] sig) throws Exception{
int length=_frst.length+_scnd.length+6+frst+scnd;
tmp=new byte[length];
tmp[0]=(byte)0x30; tmp[1]=(byte)(_frst.length+_scnd.length+4);
tmp[1]+=frst; tmp[1]+=scnd;
tmp[1]+=(byte)frst; tmp[1]+=(byte)scnd;
tmp[2]=(byte)0x02; tmp[3]=(byte)_frst.length;
tmp[3]+=frst;
tmp[3]+=(byte)frst;
System.arraycopy(_frst, 0, tmp, 4+frst, _frst.length);
tmp[4+tmp[3]]=(byte)0x02; tmp[5+tmp[3]]=(byte)_scnd.length;
tmp[5+tmp[3]]+=scnd;
tmp[5+tmp[3]]+=(byte)scnd;
System.arraycopy(_scnd, 0, tmp, 6+tmp[3]+scnd, _scnd.length);
sig=tmp;

Expand Down
2 changes: 2 additions & 0 deletions java/com/jcraft/jsch/jcraft/HMACMD5.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2024 D. R. Commander. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -35,6 +36,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
public class HMACMD5 extends HMAC implements MAC{
private static final String name="hmac-md5";

@SuppressWarnings("this-escape")
public HMACMD5(){
super();
MessageDigest md=null;
Expand Down
2 changes: 2 additions & 0 deletions java/com/jcraft/jsch/jcraft/HMACSHA1.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2024 D. R. Commander. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -35,6 +36,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
public class HMACSHA1 extends HMAC implements MAC{
private static final String name="hmac-sha1";

@SuppressWarnings("this-escape")
public HMACSHA1(){
super();
MessageDigest md=null;
Expand Down
9 changes: 5 additions & 4 deletions java/com/jcraft/jzlib/Deflate.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*-mode:java; c-basic-offset:2; -*- */
/*
Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2024 D. R. Commander. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -436,7 +437,7 @@ void scan_tree (short[] tree,// the tree to be scanned
continue;
}
else if(count < min_count) {
bl_tree[curlen*2] += count;
bl_tree[curlen*2] += (short)count;
}
else if(curlen != 0) {
if(curlen != prevlen) bl_tree[curlen*2]++;
Expand Down Expand Up @@ -584,13 +585,13 @@ void send_bits(int value, int length){
if (bi_valid > Buf_size - len) {
int val = value;
// bi_buf |= (val << bi_valid);
bi_buf |= ((val << bi_valid)&0xffff);
bi_buf |= (short)((val << bi_valid)&0xffff);
put_short(bi_buf);
bi_buf = (short)(val >>> (Buf_size - bi_valid));
bi_valid += len - Buf_size;
} else {
// bi_buf |= (value) << bi_valid;
bi_buf |= (((value) << bi_valid)&0xffff);
bi_buf |= (short)(((value) << bi_valid)&0xffff);
bi_valid += len;
}
}
Expand Down Expand Up @@ -653,7 +654,7 @@ boolean _tr_tally (int dist, // distance of matched string
int dcode;
for (dcode = 0; dcode < D_CODES; dcode++) {
out_length += (int)dyn_dtree[dcode*2] *
(5L+Tree.extra_dbits[dcode]);
(int)(5L+Tree.extra_dbits[dcode]);
}
out_length >>>= 3;
if ((matches < (last_lit/2)) && out_length < in_length/2) return true;
Expand Down
3 changes: 2 additions & 1 deletion java/com/jcraft/jzlib/Tree.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*-mode:java; c-basic-offset:2; -*- */
/*
Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
Copyright (c) 2024 D. R. Commander. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -218,7 +219,7 @@ void gen_bitlen(Deflate s){
m = s.heap[--h];
if (m > max_code) continue;
if (tree[m*2+1] != bits) {
s.opt_len += ((long)bits - (long)tree[m*2+1])*(long)tree[m*2];
s.opt_len += (int)(((long)bits - (long)tree[m*2+1])*(long)tree[m*2]);
tree[m*2+1] = (short)bits;
}
n--;
Expand Down
12 changes: 7 additions & 5 deletions java/com/turbovnc/rdr/InStream.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (C) 2012, 2015, 2018, 2020 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2012, 2015, 2018, 2020, 2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C) 2011 Brian P. Hinz
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
Expand Down Expand Up @@ -177,12 +178,12 @@ public final void readPixels(Object buf, int length, int bytesPerPixel,
if (bigEndian) {
while (length-- > 0) {
((short[])buf)[dstPtr] = (short)((pixels[srcPtr++] & 0xff) << 8);
((short[])buf)[dstPtr++] |= (pixels[srcPtr++] & 0xff);
((short[])buf)[dstPtr++] |= (short)(pixels[srcPtr++] & 0xff);
}
} else {
while (length-- > 0) {
((short[])buf)[dstPtr] = (short)(pixels[srcPtr++] & 0xff);
((short[])buf)[dstPtr++] |= (pixels[srcPtr++] & 0xff) << 8;
((short[])buf)[dstPtr++] |= (short)((pixels[srcPtr++] & 0xff) << 8);
}
}
} else if (bytesPerPixel == 3 && buf instanceof int[]) {
Expand Down Expand Up @@ -281,7 +282,7 @@ public final void readPixels(Object buf, int stride, Rect r,
int endOfRow = dstPtr + w;
while (dstPtr < endOfRow) {
((short[])buf)[dstPtr] = (short)((pixels[srcPtr++] & 0xff) << 8);
((short[])buf)[dstPtr++] |= (pixels[srcPtr++] & 0xff);
((short[])buf)[dstPtr++] |= (short)(pixels[srcPtr++] & 0xff);
}
dstPtr += pad;
h--;
Expand All @@ -291,7 +292,8 @@ public final void readPixels(Object buf, int stride, Rect r,
int endOfRow = dstPtr + w;
while (dstPtr < endOfRow) {
((short[])buf)[dstPtr] = (short)(pixels[srcPtr++] & 0xff);
((short[])buf)[dstPtr++] |= (pixels[srcPtr++] & 0xff) << 8;
((short[])buf)[dstPtr++] |=
(short)((pixels[srcPtr++] & 0xff) << 8);
}
dstPtr += pad;
h--;
Expand Down
6 changes: 3 additions & 3 deletions java/com/turbovnc/rfb/ConnParams.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) 2011-2012, 2015, 2018, 2022 D. R. Commander.
* All Rights Reserved.
/* Copyright (C) 2011-2012, 2015, 2018, 2022, 2024 D. R. Commander.
* All Rights Reserved.
* Copyright 2019 Pierre Ossman for Cendio AB
* Copyright (C) 2012 Brian P. Hinz
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Expand All @@ -24,7 +24,7 @@

import com.turbovnc.rdr.*;

public class ConnParams {
public final class ConnParams {

static LogWriter vlog = new LogWriter("ConnParams");

Expand Down
3 changes: 2 additions & 1 deletion java/com/turbovnc/rfb/DesCipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
// The rest is:
//
// Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
// Copyright (C) 2024 by D. R. Commander. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -71,7 +72,7 @@

package com.turbovnc.rfb;

public class DesCipher {
public final class DesCipher {

// Constructor, byte-array key.
public DesCipher(byte[] key) {
Expand Down
3 changes: 2 additions & 1 deletion java/com/turbovnc/rfb/PixelBuffer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2012, 2015, 2018 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2012, 2015, 2018, 2024 D. R. Commander. All Rights Reserved.
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -31,6 +31,7 @@

public class PixelBuffer {

@SuppressWarnings("this-escape")
public PixelBuffer() {
setPF(new PixelFormat());
}
Expand Down
10 changes: 5 additions & 5 deletions java/com/turbovnc/vncviewer/CConn.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2011-2023 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2011-2024 D. R. Commander. All Rights Reserved.
* Copyright (C) 2021 Steffen Kieß
* Copyright 2009-2011, 2016-2019 Pierre Ossman <ossman@cendio.se>
* for Cendio AB
Expand Down Expand Up @@ -50,10 +50,10 @@
import com.turbovnc.network.Socket;
import com.turbovnc.network.TcpSocket;

public class CConn extends CConnection implements UserPasswdGetter,
public final class CConn extends CConnection implements UserPasswdGetter,
OptionsDialogCallback, FdInStreamBlockCallback {

public final PixelFormat getPreferredPF() { return fullColourPF; }
public PixelFormat getPreferredPF() { return fullColourPF; }
static final PixelFormat VERY_LOW_COLOR_PF =
new PixelFormat(8, 3, false, true, 1, 1, 1, 2, 1, 0);
static final PixelFormat LOW_COLOR_PF =
Expand Down Expand Up @@ -257,7 +257,7 @@ public void blockCallback() {
// RFB thread: getUserPasswd() is called by the CSecurity object when it
// needs us to read a password from the user.
@Override
public final boolean getUserPasswd(StringBuffer user, StringBuffer passwd) {
public boolean getUserPasswd(StringBuffer user, StringBuffer passwd) {
String title = ((user == null ? "Standard VNC Authentication" :
"Unix Login Authentication") +
" [" + csecurity.getDescription() + "]");
Expand Down Expand Up @@ -601,7 +601,7 @@ else if (params.desktopSize.getMode() == DesktopSize.AUTO) {
}
}

public final ScreenSet computeScreenLayout(int width, int height) {
public ScreenSet computeScreenLayout(int width, int height) {
java.awt.Point vpPos = viewport.getContentPane().getLocationOnScreen();
Rectangle vpRect = viewport.getContentPane().getBounds();
ScreenSet layout;
Expand Down
6 changes: 3 additions & 3 deletions java/com/turbovnc/vncviewer/F8Menu.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) 2012-2015, 2017-2018, 2020-2022 D. R. Commander.
* All Rights Reserved.
/* Copyright (C) 2012-2015, 2017-2018, 2020-2022, 2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C) 2011, 2013 Brian P. Hinz
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
Expand Down Expand Up @@ -28,7 +28,7 @@

import com.turbovnc.rfb.*;

public class F8Menu extends JPopupMenu implements ActionListener {
public final class F8Menu extends JPopupMenu implements ActionListener {
public F8Menu(CConn cc_) {
super("VNC Menu");
setLightWeightPopupEnabled(false);
Expand Down
7 changes: 4 additions & 3 deletions java/com/turbovnc/vncviewer/ImageDrawTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (C) 2012, 2015, 2018, 2020 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2012, 2015, 2018, 2020, 2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C) 2011-2012 Brian P. Hinz
*
* This is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -28,7 +29,7 @@

import com.turbovnc.rfb.*;

public class ImageDrawTest extends JFrame {
public final class ImageDrawTest extends JFrame {

static final PixelFormat VERY_LOW_COLOR_PF =
new PixelFormat(8, 3, false, true, 1, 1, 1, 2, 1, 0);
Expand All @@ -44,7 +45,7 @@ public class ImageDrawTest extends JFrame {
public static final int DEFAULT_WIDTH = 1240;
public static final int DEFAULT_HEIGHT = 900;

public class MyPanel extends JPanel {
public final class MyPanel extends JPanel {

public MyPanel(int w, int h, int colors) {
swingDB = Utils.getBooleanProperty("turbovnc.swingdb", false);
Expand Down
4 changes: 2 additions & 2 deletions java/com/turbovnc/vncviewer/MacMenuBar.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2012-2015, 2018, 2020-2023 D. R. Commander.
/* Copyright (C) 2012-2015, 2018, 2020-2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C) 2011 Brian P. Hinz
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Expand Down Expand Up @@ -31,7 +31,7 @@

import com.turbovnc.rfb.*;

public class MacMenuBar extends JMenuBar implements ActionListener {
public final class MacMenuBar extends JMenuBar implements ActionListener {

// The following code allows us to pop up our own dialogs whenever "About"
// and "Preferences" are selected from the application menu.
Expand Down
3 changes: 2 additions & 1 deletion java/com/turbovnc/vncviewer/PlatformPixelBuffer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2012, 2015 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2012, 2015, 2024 D. R. Commander. All Rights Reserved.
* Copyright (C) 2011-2012 Brian P. Hinz
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
Expand Down Expand Up @@ -28,6 +28,7 @@

public abstract class PlatformPixelBuffer extends PixelBuffer {

@SuppressWarnings("this-escape")
public PlatformPixelBuffer(int w, int h, CConn cc_, DesktopWindow desktop_) {
cc = cc_;
desktop = desktop_;
Expand Down
6 changes: 3 additions & 3 deletions java/com/turbovnc/vncviewer/Toolbar.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) 2012-2013, 2015, 2018, 2020, 2022 D. R. Commander.
* All Rights Reserved.
/* Copyright (C) 2012-2013, 2015, 2018, 2020, 2022, 2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C) 2011-2012 Brian P. Hinz
*
* This is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -29,7 +29,7 @@
import com.turbovnc.rdr.*;
import com.turbovnc.rfb.*;

public class Toolbar extends JToolBar implements ActionListener {
public final class Toolbar extends JToolBar implements ActionListener {

static final String[] BUTTONS = {
"Connection options...", "Connection info...", "Full screen",
Expand Down
5 changes: 3 additions & 2 deletions java/com/turbovnc/vncviewer/TrayMenu.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (C) 2014, 2018, 2020, 2022 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2014, 2018, 2020, 2022, 2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C) 2011 Brian P. Hinz
* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
Expand Down Expand Up @@ -27,7 +28,7 @@
import com.turbovnc.rdr.*;
import com.turbovnc.rfb.*;

public class TrayMenu extends PopupMenu implements ActionListener {
public final class TrayMenu extends PopupMenu implements ActionListener {

public TrayMenu(VncViewer viewer_) {
super("TurboVNC Viewer");
Expand Down
Loading

0 comments on commit 466515c

Please sign in to comment.