Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SuppressWarnings unused and other code cleanup #880

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/com/sun/jna/CallbackReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ protected List<String> getFieldOrder() {
}

/* Called from native code to initialize a callback thread. */
private static ThreadGroup initializeThread(Callback cb, AttachOptions args) {
@SuppressWarnings("unused")
private static ThreadGroup initializeThread(Callback cb, AttachOptions args) {
CallbackThreadInitializer init = null;
if (cb instanceof DefaultCallbackProxy) {
cb = ((DefaultCallbackProxy)cb).getCallback();
Expand Down
4 changes: 3 additions & 1 deletion src/com/sun/jna/ELFAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class ELFAnalyser {
* e_flags mask if executable file conforms to software floating-point
* procedure-call standard (arm ABI version 5)
*/
private static final int EF_ARM_ABI_FLOAT_SOFT = 0x00000200;
private static final int EI_DATA_BIG_ENDIAN = 2;
private static final int E_MACHINE_ARM = 0x28;
private static final int EI_CLASS_64BIT = 2;
Expand Down Expand Up @@ -116,6 +115,7 @@ private void runDetection() throws IOException {
}
}
if (!ELF) {
raf.close();
return;
}
raf.seek(4);
Expand All @@ -136,5 +136,7 @@ private void runDetection() throws IOException {
armHardFloat = (flags & EF_ARM_ABI_FLOAT_HARD) == EF_ARM_ABI_FLOAT_HARD;
armSoftFloat = !armHardFloat;
}

raf.close();
}
}
2 changes: 1 addition & 1 deletion src/com/sun/jna/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public static Function getFunction(Pointer p, int callFlags, String encoding) {
this.functionName = functionAddress.toString();
this.callFlags = callFlags;
this.peer = functionAddress.peer;
this.options = Collections.EMPTY_MAP;
this.options = Collections.emptyMap();
this.encoding = encoding != null
? encoding : Native.getDefaultStringEncoding();
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/sun/jna/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@ static Class<?> findEnclosingLibraryClass(Class<?> cls) {
* @param type The type class
* @return The options map
*/
public static Map<String, Object> getLibraryOptions(Class<?> type) {
@SuppressWarnings("unchecked")
public static Map<String, Object> getLibraryOptions(Class<?> type) {
Map<String, Object> libraryOptions;
// cached already ?
synchronized(libraries) {
Expand Down Expand Up @@ -2242,7 +2243,6 @@ public static void detach(boolean detach) {
// state every time. Clear the termination flag, since it's not
// needed when the native thread is detached normally.
nativeThreads.remove(thread);
Pointer p = nativeThreadTerminationFlag.get();
setDetachState(true, 0);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/com/sun/jna/NativeString.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @author Todd Fast, [email protected]
* @author [email protected]
*/
class NativeString implements CharSequence, Comparable {
class NativeString implements CharSequence, Comparable<Object> {

static final String WIDE_STRING = "--WIDE-STRING--";

Expand Down
18 changes: 12 additions & 6 deletions src/com/sun/jna/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public interface ByReference { }
private final Map<String, Object> nativeStrings = new HashMap<String, Object>();
private TypeMapper typeMapper;
// This field is accessed by native code
private long typeInfo;
@SuppressWarnings("unused")
private long typeInfo;

private boolean autoRead = true;
private boolean autoWrite = true;
Expand Down Expand Up @@ -1356,7 +1357,8 @@ else if (NativeMapped.class.isAssignableFrom(type)) {
return value;
}

private int addPadding(int calculatedSize) {
@SuppressWarnings("unused")
private int addPadding(int calculatedSize) {
return addPadding(calculatedSize, structAlignment);
}

Expand Down Expand Up @@ -1586,8 +1588,10 @@ public Structure[] toArray(Structure[] array) {
public Structure[] toArray(int size) {
return toArray((Structure[])Array.newInstance(getClass(), size));
}

private Class<?> baseClass() {

//Native usage
@SuppressWarnings("unused")
private Class<?> baseClass() {
if ((this instanceof Structure.ByReference
|| this instanceof Structure.ByValue)
&& Structure.class.isAssignableFrom(getClass().getSuperclass())) {
Expand Down Expand Up @@ -1755,7 +1759,8 @@ static Pointer getTypeInfo(Object obj) {
* #newInstance(Class,Pointer)}, except that it additionally calls
* {@link #conditionalAutoRead()}.
*/
private static Structure newInstance(Class<?> type, long init) {
@SuppressWarnings("unused")
private static Structure newInstance(Class<?> type, long init) {
try {
Structure s = newInstance(type, init == 0 ? PLACEHOLDER_MEMORY : new Pointer(init));
if (init != 0) {
Expand Down Expand Up @@ -1879,11 +1884,12 @@ public static class size_t extends IntegerType {
// Native.initIDs initializes these fields to their appropriate
// pointer values. These are in a separate class from FFIType so that
// they may be initialized prior to loading the FFIType class
@SuppressWarnings("unused")
private static class FFITypes {
private static Pointer ffi_type_void;
private static Pointer ffi_type_float;
private static Pointer ffi_type_double;
private static Pointer ffi_type_longdouble;
private static Pointer ffi_type_longdouble;
private static Pointer ffi_type_uint8;
private static Pointer ffi_type_sint8;
private static Pointer ffi_type_uint16;
Expand Down
2 changes: 1 addition & 1 deletion src/com/sun/jna/WString.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/** Simple wrapper class to identify a wide string argument or return type.
* @author [email protected]
*/
public final class WString implements CharSequence, Comparable {
public final class WString implements CharSequence, Comparable<Object> {
private String string;
public WString(String s){
if (s == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/sun/jna/WeakMemoryHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public synchronized void put(Object o, Memory m) {
}

public synchronized void clean() {
for(Reference ref = referenceQueue.poll(); ref != null; ref = referenceQueue.poll()) {
for(Reference<?> ref = referenceQueue.poll(); ref != null; ref = referenceQueue.poll()) {
backingMap.remove(ref);
}
}
Expand Down