Eclipse gives me a weird error when compiling...
Posted
by Legend
on Stack Overflow
See other posts from Stack Overflow
or by Legend
Published on 2010-03-31T01:12:53Z
Indexed on
2010/03/31
1:33 UTC
Read the original article
Hit count: 266
I have this function which returns a datatype InetAddress[]
public InetAddress []
lookupAllHostAddr(String host) throws UnknownHostException {
Name name = null;
try {
name = new Name(host);
}
catch (TextParseException e) {
throw new UnknownHostException(host);
}
Record [] records = null;
if (preferV6)
records = new Lookup(name, Type.AAAA).run();
if (records == null)
records = new Lookup(name, Type.A).run();
if (records == null && !preferV6)
records = new Lookup(name, Type.AAAA).run();
if (records == null)
throw new UnknownHostException(host);
InetAddress[] array = new InetAddress[records.length];
for (int i = 0; i < records.length; i++) {
Record record = records[i];
if (records[i] instanceof ARecord) {
ARecord a = (ARecord) records[i];
array[i] = a.getAddress();
} else {
AAAARecord aaaa = (AAAARecord) records[i];
array[i] = aaaa.getAddress();
}
}
return array;
}
Eclipse complains that the return type should be byte[][] but when I change the return type to byte[][], it complains that the function is returning the wrong data type. I'm stuck in a loop. Does anyone know what is happening here?
© Stack Overflow or respective owner