8000 Fix or disable unchecked warnings · codesplode/dnsjava@c49ec7d · GitHub
[go: up one dir, main page]

Skip to content

Commit c49ec7d

Browse files
committed
Fix or disable unchecked warnings
1 parent 0ae8fea commit c49ec7d

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

src/main/java/org/xbill/DNS/Cache.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static class NegativeElement implements Element {
132132
}
133133
}
134134

135-
private static class CacheMap extends LinkedHashMap {
135+
private static class CacheMap extends LinkedHashMap<Name, Object> {
136136
private int maxsize;
137137

138138
CacheMap(int maxsize) {
@@ -214,9 +214,10 @@ protected boolean removeEldestEntry(Map.Entry eldest) {
214214
private synchronized Element []
215215
allElements(Object types) {
216216
if (types instanceof List) {
217-
List typelist = (List) types;
217+
@SuppressWarnings("unchecked")
218+
List<Element> typelist = (List<Element>) types;
218219
int size = typelist.size();
219-
return (Element []) typelist.toArray(new Element[size]);
220+
return typelist.toArray(new Element[size]);
220221
} else {
221222
Element set = (Element) types;
222223
return new Element[] {set};
@@ -271,6 +272,7 @@ protected boolean removeEldestEntry(Map.Entry eldest) {
271272
}
272273
int type = element.getType();
273274
if (types instanceof List) {
275+
@SuppressWarnings("unchecked")
274276
List<Element> list = (List<Element>) types;
275277
for (int i = 0; i < list.size(); i++) {
276278
Element elt = (Element) list.get(i);

src/main/java/org/xbill/DNS/Message.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class Message implements Cloneable {
5353
private stat 8000 ic Record [] emptyRecordArray = new Record[0];
5454
private static RRset [] emptyRRsetArray = new RRset[0];
5555

56+
@SuppressWarnings("unchecked")
5657
private
5758
Message(Header header) {
5859
sections = new List[4];
@@ -343,8 +344,8 @@ public class Message implements Cloneable {
343344
getSectionArray(int section) {
344345
if (sections[section] == null)
345346
return emptyRecordArray;
346-
List l = sections[section];
347-
return (Record []) l.toArray(new Record[0]);
347+
List<Record> l = sections[section];
348+
return l.toArray(new Record[0]);
348349
}
349350

350351
private static boolean

src/main/java/org/xbill/DNS/Record.java

Lines changed: 2 additions & 4 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @author Brian Wellington
1515
*/
16-
public abstract class Record implements Cloneable, Comparable, Serializable {
16+
public abstract class Record implements Cloneable, Comparable<Record>, Serializable {
1717

1818
private static final long serialVersionUID = 2694906050116005466L;
1919

@@ -642,9 +642,7 @@ public abstract class Record implements Cloneable, Comparable, Serializable {
642642
*/
643643
@Override
644644
public int
645-
compareTo(Object o) {
646-
Record arg = (Record) o;
647-
645+
compareTo(Record arg) {
648646
if (this == arg)
649647
return (0);
650648

src/main/java/org/xbill/DNS/ResolverConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public class ResolverConfig {
157157
* Uses the undocumented Sun DNS implementation to determine the configuration.
158158
* This doesn't work or even compile with all JVMs (gcj, for example).
159159
*/
160+
@SuppressWarnings("unchecked")
160161
private boolean
161162
findSunJVM() {
162163
List<String> lserver = new ArrayList<>(0);

src/main/java/org/xbill/DNS/Zone.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Zone implements Serializable {
2121
/** A secondary zone */
2222
public static final int SECONDARY = 2;
2323

24-
private Map data;
24+
private Map<Name, Object> data;
2525
private Name origin;
2626
private Object originNode;
2727
private int dclass = DClass.IN;
@@ -134,7 +134,7 @@ else if (type == Type.NS)
134134
*/
135135
public
136136
Zone(Name zone, String file) throws IOException {
137-
data = new TreeMap();
137+
data = new TreeMap<>();
138138

139139
if (zone == null)
140140
throw new IllegalArgumentException("no zone name specified");
@@ -155,7 +155,7 @@ else if (type == Type.NS)
155155
*/
156156
public
157157
Zone(Name zone, Record [] records) throws IOException {
158-
data = new TreeMap();
158+
data = new TreeMap<>();
159159

160160
if (zone == null)
161161
throw new IllegalArgumentException("no zone name specified");
@@ -167,7 +167,7 @@ else if (type == Type.NS)
167167

168168
private void
169169
fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException {
170-
data = new TreeMap();
170+
data = new TreeMap<>();
171171

172172
origin = xfrin.getName();
173173
List records = xfrin.run();
@@ -236,8 +236,9 @@ else if (type == Type.NS)
236236
private synchronized RRset []
237237
allRRsets(Object types) {
238238
if (types instanceof List) {
239-
List typelist = (List) types;
240-
return (RRset []) typelist.toArray(new RRset[0]);
239+
@SuppressWarnings("unchecked")
240+
List<RRset> typelist = (List<RRset>) types;
241+
return typelist.toArray(new RRset[0]);
241242
} else {
242243
RRset set = (RRset) types;
243244
return new RRset [] {set};
@@ -282,6 +283,7 @@ else if (type == Type.NS)
282283
}
283284
int rtype = rrset.getType();
284285
if (types instanceof List) {
286+
@SuppressWarnings("unchecked")
285287
List<RRset> list = (List<RRset>) types;
286288
for (int i = 0; i < list.size(); i++) {
287289
RRset set = (RRset) list.get(i);

0 commit comments

Comments
 (0)
0