Skip to content

Commit

Permalink
Cleanup floating-point constructor use (apache#3648)
Browse files Browse the repository at this point in the history
Cleaned up the deprecated use of old constructors. The compiler/VM will now autobox this into a proper
class. So this change removes warnings like this:

[repeat] /home/bwalker/src/netbeans/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofInstanceValue.java:93: warning: [deprecation] Byte(byte) in Byte has been deprecated
[repeat]                 return new Byte(bt);
[repeat]                        ^

Also, added a couple of override annotations since I was here..
  • Loading branch information
BradWalker authored Feb 20, 2022
1 parent de854f8 commit 4ae01ea
Showing 1 changed file with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ class HprofInstanceValue extends HprofObject implements FieldValue {

//~ Methods ------------------------------------------------------------------------------------------------------------------

@Override
public Instance getDefiningInstance() {
return field.classDump.getHprof().getInstanceByOffset(new long[] {instanceOffset});
}

@Override
public Field getField() {
return field;
}

@Override
public String getValue() {
return getTypeValue().toString();
}
Expand All @@ -62,50 +65,41 @@ Object getTypeValue() {
static Object getTypeValue(final HprofByteBuffer dumpBuffer, final long position, final byte type) {
switch (type) {
case HprofHeap.OBJECT:

long obj = dumpBuffer.getID(position);

return new Long(obj);
return obj;

case HprofHeap.BOOLEAN:

byte b = dumpBuffer.get(position);

return Boolean.valueOf(b != 0);
return b != 0;

case HprofHeap.CHAR:

char ch = dumpBuffer.getChar(position);

return Character.valueOf(ch);
return ch;

case HprofHeap.FLOAT:

float f = dumpBuffer.getFloat(position);

return new Float(f);
return f;

case HprofHeap.DOUBLE:

double d = dumpBuffer.getDouble(position);

return new Double(d);
return d;

case HprofHeap.BYTE:

byte bt = dumpBuffer.get(position);

return new Byte(bt);
return bt;

case HprofHeap.SHORT:

short sh = dumpBuffer.getShort(position);

return new Short(sh);
return sh;

case HprofHeap.INT:

int i = dumpBuffer.getInt(position);

return Integer.valueOf(i);
return i;

case HprofHeap.LONG:

long lg = dumpBuffer.getLong(position);

return new Long(lg);
return lg;

default:
return "Invalid type " + type; // NOI18N
}
Expand Down

0 comments on commit 4ae01ea

Please sign in to comment.