summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-11-09 11:07:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-11-09 14:27:47 +0100
commiteee1ff965143910eb52895af471b260564938db6 (patch)
tree4fb4a55b5b9a8e853cd3ed321a8d953e4b0df3a9
parentb4cbd33588c194c21926bf6ab70aa76088a9bb09 (diff)
enable unchecked lint for our java code
and annotate where necessary, mostly just suppressing the warnings Change-Id: I8e39d797cde6c7c3f4e3e1bd93a128965ecec81d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159205 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java2
-rw-r--r--dbaccess/qa/complex/dbaccess/DatabaseDocument.java1
-rw-r--r--dbaccess/qa/complex/dbaccess/RowSet.java8
-rw-r--r--dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java2
-rw-r--r--dbaccess/qa/complex/dbaccess/TestCase.java2
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java1
-rw-r--r--qadevOOo/runner/util/ValueChanger.java1
-rw-r--r--qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java3
-rw-r--r--qadevOOo/tests/java/ifc/beans/_XMultiPropertySet.java1
-rw-r--r--qadevOOo/tests/java/ifc/io/_XDataInputStream.java4
-rw-r--r--qadevOOo/tests/java/ifc/io/_XDataOutputStream.java1
-rw-r--r--qadevOOo/tests/java/ifc/sdbc/_XParameters.java1
-rw-r--r--qadevOOo/tests/java/ifc/sdbc/_XRow.java1
-rw-r--r--qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java1
-rw-r--r--qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java1
-rw-r--r--qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java1
-rw-r--r--ridljar/com/sun/star/lib/util/WeakMap.java4
-rw-r--r--sfx2/qa/complex/sfx2/UndoManager.java1
-rw-r--r--solenv/gbuild/JavaClassSet.mk3
-rw-r--r--wizards/com/sun/star/wizards/ui/ButtonList.java1
20 files changed, 29 insertions, 11 deletions
diff --git a/bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java b/bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java
index 12817e57eeda..200f664f32c3 100644
--- a/bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java
+++ b/bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java
@@ -139,7 +139,7 @@ public final class JNI_proxy implements java.lang.reflect.InvocationHandler
public static java.lang.reflect.Constructor get_proxy_ctor( Class clazz )
throws Throwable
{
- Class proxy_class = java.lang.reflect.Proxy.getProxyClass(
+ Class<?> proxy_class = java.lang.reflect.Proxy.getProxyClass(
s_classloader,
new Class [] { clazz, IQueryInterface.class,
com.sun.star.lib.uno.Proxy.class } );
diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
index 5bd28053b77c..3087ad6374c2 100644
--- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
+++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
@@ -174,6 +174,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
};
}
+ @SuppressWarnings("unchecked")
public void dispose()
{
final EventObject event = new EventObject(this);
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java
index 4c5fcc6da793..ed42a271b46f 100644
--- a/dbaccess/qa/complex/dbaccess/RowSet.java
+++ b/dbaccess/qa/complex/dbaccess/RowSet.java
@@ -365,7 +365,7 @@ public class RowSet extends TestCase
m_rowSet.addRowSetListener(pRow);
// do some movements to check if we got all notifications
- final Class cResSet = Class.forName("com.sun.star.sdbc.XResultSet");
+ final Class<?> cResSet = Class.forName("com.sun.star.sdbc.XResultSet");
final boolean moves[] = new boolean[9];
for (int i = 0; i < moves.length; ++i)
{
@@ -399,7 +399,7 @@ public class RowSet extends TestCase
testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_MODIFIED] = false;
- final Class cupd = Class.forName("com.sun.star.sdbc.XResultSetUpdate");
+ final Class<?> cupd = Class.forName("com.sun.star.sdbc.XResultSetUpdate");
final XResultSetUpdate upd = UnoRuntime.queryInterface( XResultSetUpdate.class, m_resultSet );
testCursorMove(upd, cupd.getMethod("moveToInsertRow", (Class[]) null), pRow, moves, null);
@@ -445,7 +445,7 @@ public class RowSet extends TestCase
moves[RowSetEventListener.COLUMN_VALUE] = true;
moves[RowSetEventListener.CURSOR_MOVED] = true;
- final Class cloc = Class.forName("com.sun.star.sdbcx.XRowLocate");
+ final Class<?> cloc = Class.forName("com.sun.star.sdbcx.XRowLocate");
m_resultSet.first();
final Object bookmark = m_rowLocate.getBookmark();
m_resultSet.next();
@@ -470,7 +470,7 @@ public class RowSet extends TestCase
moves[RowSetEventListener.APPROVE_ROW_CHANGE] = true;
moves[RowSetEventListener.ROW_CHANGED] = true;
moves[RowSetEventListener.ROW_COUNT] = true;
- final Class cdelRows = Class.forName("com.sun.star.sdbcx.XDeleteRows");
+ final Class<?> cdelRows = Class.forName("com.sun.star.sdbcx.XDeleteRows");
ctemp[0] = Object[].class;
final XDeleteRows delRows = UnoRuntime.queryInterface( XDeleteRows.class, m_resultSet );
final Object bookmarks[] = new Object[5];
diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
index 2d05030b7e83..656b44d00c04 100644
--- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
+++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
@@ -81,7 +81,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
String realValue = null;
try
{
- final Class composerClass = m_composer.getClass();
+ final Class<?> composerClass = m_composer.getClass();
final Method attributeGetter = composerClass.getMethod("get" + _attributeName, new Class[]
{
});
diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java
index a9768e7b47a2..8c284ae51f40 100644
--- a/dbaccess/qa/complex/dbaccess/TestCase.java
+++ b/dbaccess/qa/complex/dbaccess/TestCase.java
@@ -119,7 +119,7 @@ public abstract class TestCase
private void assureException( final String _message, final Object _object, final String _methodName,
final Class[] _argClasses, final Object[] _methodArgs, final Class _expectedExceptionClass )
{
- Class objectClass = _object.getClass();
+ Class<?> objectClass = _object.getClass();
boolean noExceptionAllowed = ( _expectedExceptionClass == null );
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java
index a406b84d457e..e3e9266afd4d 100644
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java
+++ b/javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test.java
@@ -626,6 +626,7 @@ public class InterfaceContainer_Test
it.previous();
}
+ @SuppressWarnings("unchecked")
@Test public void ListIterator_add() throws Exception
{
logger.log(Level.INFO, "Testing ListIterator.add()");
diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java
index 998bd9fce131..f6a58dd2b8c0 100644
--- a/qadevOOo/runner/util/ValueChanger.java
+++ b/qadevOOo/runner/util/ValueChanger.java
@@ -1077,6 +1077,7 @@ public class ValueChanger {
return result;
}
+ @SuppressWarnings("unchecked")
private static <T> T copyStruct(T value) {
Class<T> clazz = (Class<T>) value.getClass();
T newValue;
diff --git a/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java b/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java
index a7821ba2b88d..12f4a1bdc282 100644
--- a/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java
+++ b/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java
@@ -73,7 +73,8 @@ public class _XFastPropertySet extends MultiMethodTest {
/**
* Retrieves relation.
*/
- @Override
+ @SuppressWarnings("unchecked")
+ @Override
protected void before() {
exclude = (Set<String>) tEnv.getObjRelation("XFastPropertySet.ExcludeProps") ;
if (exclude == null) {
diff --git a/qadevOOo/tests/java/ifc/beans/_XMultiPropertySet.java b/qadevOOo/tests/java/ifc/beans/_XMultiPropertySet.java
index e23e3845d867..052e58843679 100644
--- a/qadevOOo/tests/java/ifc/beans/_XMultiPropertySet.java
+++ b/qadevOOo/tests/java/ifc/beans/_XMultiPropertySet.java
@@ -78,6 +78,7 @@ public class _XMultiPropertySet extends MultiMethodTest {
/**
* Initializes some fields.
*/
+ @SuppressWarnings("unchecked")
@Override
public void before() {
exclProps = (Set<String>) tEnv.getObjRelation("XMultiPropertySet.ExcludeProps");
diff --git a/qadevOOo/tests/java/ifc/io/_XDataInputStream.java b/qadevOOo/tests/java/ifc/io/_XDataInputStream.java
index 5ab320fa526e..e451b8e7eb05 100644
--- a/qadevOOo/tests/java/ifc/io/_XDataInputStream.java
+++ b/qadevOOo/tests/java/ifc/io/_XDataInputStream.java
@@ -76,12 +76,12 @@ public class _XDataInputStream extends MultiMethodTest {
* data of different types and fills the appropriate variables.
* @throws StatusException If one of relations not found.
*/
+ @SuppressWarnings("unchecked")
@Override
public void before(){
XInterface x = (XInterface)tEnv.getObjRelation("StreamWriter") ;
- oStream = UnoRuntime.queryInterface(
- XDataOutputStream.class, x);
+ oStream = UnoRuntime.queryInterface(XDataOutputStream.class, x);
List<Object> data = (List<Object>) tEnv.getObjRelation("StreamData") ;
if (data == null || oStream == null) {
throw new StatusException(Status.failed("Object relation not found."));
diff --git a/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java b/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java
index 3ea11193d58b..3395ba9d61c5 100644
--- a/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java
+++ b/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java
@@ -56,6 +56,7 @@ public class _XDataOutputStream extends MultiMethodTest {
* If relation or data of some type in stream not found then
* tests of corresponding methods are skipped.
*/
+ @SuppressWarnings("unchecked")
@Override
public void before() throws RuntimeException {
diff --git a/qadevOOo/tests/java/ifc/sdbc/_XParameters.java b/qadevOOo/tests/java/ifc/sdbc/_XParameters.java
index 4284931fefee..31a5e6d4b0ad 100644
--- a/qadevOOo/tests/java/ifc/sdbc/_XParameters.java
+++ b/qadevOOo/tests/java/ifc/sdbc/_XParameters.java
@@ -99,6 +99,7 @@ public class _XParameters extends MultiMethodTest {
/**
* Gets object relation
*/
+ @SuppressWarnings("unchecked")
@Override
public void before() {
data = (List<Object>) tEnv.getObjRelation("XParameters.ParamValues") ;
diff --git a/qadevOOo/tests/java/ifc/sdbc/_XRow.java b/qadevOOo/tests/java/ifc/sdbc/_XRow.java
index 70a60b0cf34c..e1babb0760b6 100644
--- a/qadevOOo/tests/java/ifc/sdbc/_XRow.java
+++ b/qadevOOo/tests/java/ifc/sdbc/_XRow.java
@@ -100,6 +100,7 @@ public class _XRow extends MultiMethodTest {
/**
* Retrieves object relation first.
*/
+ @SuppressWarnings("unchecked")
@Override
public void before() {
data = (List<Object>) tEnv.getObjRelation("CurrentRowData") ;
diff --git a/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java b/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java
index e57b2f062d6e..88122513cc88 100644
--- a/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java
+++ b/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java
@@ -99,6 +99,7 @@ public class _XRowUpdate extends MultiMethodTest {
/**
* Gets relations.
*/
+ @SuppressWarnings("unchecked")
@Override
public void before() {
rowData = (List<Object>) tEnv.getObjRelation("CurrentRowData") ;
diff --git a/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java b/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java
index c7009a88ab18..310e37e94ed3 100644
--- a/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java
+++ b/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java
@@ -54,6 +54,7 @@ public class _XMultiSelectionSupplier extends MultiMethodTest {
Object[] selections = null;
Comparator<Object> ObjCompare = null;
+ @SuppressWarnings("unchecked")
@Override
protected void before() {
selections = (Object[])tEnv.getObjRelation("Selections");
diff --git a/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java b/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java
index 0fa919d944b1..cc6bc4120a7c 100644
--- a/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java
+++ b/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java
@@ -53,6 +53,7 @@ public class _XSelectionSupplier extends MultiMethodTest {
Object[] selections = null;
Comparator<Object> ObjCompare = null;
+ @SuppressWarnings("unchecked")
@Override
protected void before() {
selections = (Object[])tEnv.getObjRelation("Selections");
diff --git a/ridljar/com/sun/star/lib/util/WeakMap.java b/ridljar/com/sun/star/lib/util/WeakMap.java
index f3b3b55a356b..4d63d27286a3 100644
--- a/ridljar/com/sun/star/lib/util/WeakMap.java
+++ b/ridljar/com/sun/star/lib/util/WeakMap.java
@@ -165,6 +165,7 @@ public final class WeakMap<K,V> implements Map {
* @return previous value associated with the specified key, or
* <code>null</code> if there was no mapping for the key
*/
+ @SuppressWarnings("unchecked")
public Object /*WeakReference<V>*/ put(/*K*/ Object key, /*V*/ Object value) {
cleanUp();
return map.put((K) key, new Entry<K,V>((K) key, (V) value, queue));
@@ -193,6 +194,7 @@ public final class WeakMap<K,V> implements Map {
* must be plain objects, which are then wrapped in instances of
* <code>WeakReference</code>.
*/
+ @SuppressWarnings("unchecked")
public void putAll(Map/*<K,V>*/ m) {
cleanUp();
for (Iterator<Map.Entry<K,V>> i = m.entrySet().iterator(); i.hasNext();) {
@@ -267,6 +269,7 @@ public final class WeakMap<K,V> implements Map {
* @return the referent of the specified <code>WeakReference</code>, or
* <code>null</code> if <code>ref</code> is <code>null</code>
*/
+ @SuppressWarnings("unchecked")
public static <T> T getValue(Object /*WeakReference<T>*/ ref) {
return ref == null ? null : ((WeakReference<T>) ref).get();
}
@@ -277,6 +280,7 @@ public final class WeakMap<K,V> implements Map {
* (Specifically, iterating over the collections returned by those
* methods), as non-modifying methods might modify the underlying map.
**/
+ @SuppressWarnings("unchecked")
private void cleanUp() {
for (;;) {
Entry<K,V> e = (Entry<K,V>) queue.poll();
diff --git a/sfx2/qa/complex/sfx2/UndoManager.java b/sfx2/qa/complex/sfx2/UndoManager.java
index 12f13ada10a1..ea1a3496519f 100644
--- a/sfx2/qa/complex/sfx2/UndoManager.java
+++ b/sfx2/qa/complex/sfx2/UndoManager.java
@@ -1384,6 +1384,7 @@ public class UndoManager
return new String[] { getCallbackComponentServiceName() };
}
+ @SuppressWarnings("unchecked")
public void dispose()
{
final EventObject event = new EventObject( this );
diff --git a/solenv/gbuild/JavaClassSet.mk b/solenv/gbuild/JavaClassSet.mk
index 087c79750d00..84fbcc13c32d 100644
--- a/solenv/gbuild/JavaClassSet.mk
+++ b/solenv/gbuild/JavaClassSet.mk
@@ -20,7 +20,8 @@
gb_JavaClassSet_JAVACCOMMAND = $(ICECREAM_RUN) $(JAVACOMPILER) $(JAVACFLAGS) \
-encoding utf8 \
--release $(1) \
- -Xlint:-options
+ -Xlint:-options \
+ -Xlint:unchecked
gb_JavaClassSet_JAVACDEBUG :=
diff --git a/wizards/com/sun/star/wizards/ui/ButtonList.java b/wizards/com/sun/star/wizards/ui/ButtonList.java
index 522768bf8c07..a129fe97c8fc 100644
--- a/wizards/com/sun/star/wizards/ui/ButtonList.java
+++ b/wizards/com/sun/star/wizards/ui/ButtonList.java
@@ -375,6 +375,7 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
/** Notifies all registered listeners about the event.
*
*/
+ @SuppressWarnings("unchecked")
private void fireItemSelected()
{
java.util.ArrayList<XItemListener> list;