-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
15
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
windows 10 version 20H2,
A DESCRIPTION OF THE PROBLEM :
there is no error in program but it throws null pointer exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
to run smoothly.
---------- BEGIN SOURCE ----------
//TO DO: Complete this class, add JavaDocs
//Do not add any more imports!
import java.util.Iterator;
import java.util.Set;
public class MemMan implements Iterable<MemBlock> {
//******************************************************
//**** IMPORTANT: DO NOT CHANGE/ALTER/REMOVE ****
//**** ANYTHING PROVIDED LIKE THESE INTS HERE... ****
//******************************************************
public static final int FIRST_FIT = 0;
public static final int BEST_FIT = 1;
public static final int WORST_FIT = 2;
public static final int NEXT_FIT = 3;
public static BareNode head;
//******************************************************
//**** IMPORTANT: DO NOT CHANGE/ALTER/REMOVE ****
//**** ANYTHING PROVIDED LIKE THE INSTANCE ****
//**** VARIABLES IN THIS NESTED CLASS. ALSO ****
//**** DON'T REMOVE THE CLASS ITSELF OR ANYTHING ****
//**** STRANGE LIKE THAT. ****
//******************************************************
public static class BareNode {
public MemBlock block;
public BareNode next;
public BareNode prev;
public boolean marked;
public BareNode(MemBlock block) {
this.block = block;
}
}
public BareNode getHead(){
return head;
}
public BareNode malloc(int size){
BareNode node = new BareNode(new MemBlock(0,size,false));
node.next=head;
node.prev=null;
if(head!= null){
head.prev=node;
}
head=node;
return node;
}
public BareNode realloc(BareNode oldBn, int size){
BareNode bNode = oldBn;
bNode.block.size=size;
return bNode;
}
public int garbageCollect(Set<Integer> addrs){
return 2;
}
public boolean free(BareNode node){
return true;
}
public static MemMan factory(int fit, BareNode head){
this.head= head;
}
public MemMan iterator() {
return new LinkedListIterator();
}
private class LinkedListIterator implements Iterator<MemBlock> {
private BareNode current = head;
public MemBlock next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
MemBlock item = current.block;
current = current.next;
return item;
}
public boolean hasNext() {
return current != null;
}
public void remove() {
throw new UnsupportedOperationException();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
i have not found anyone.
FREQUENCY : always
windows 10 version 20H2,
A DESCRIPTION OF THE PROBLEM :
there is no error in program but it throws null pointer exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
to run smoothly.
---------- BEGIN SOURCE ----------
//TO DO: Complete this class, add JavaDocs
//Do not add any more imports!
import java.util.Iterator;
import java.util.Set;
public class MemMan implements Iterable<MemBlock> {
//******************************************************
//**** IMPORTANT: DO NOT CHANGE/ALTER/REMOVE ****
//**** ANYTHING PROVIDED LIKE THESE INTS HERE... ****
//******************************************************
public static final int FIRST_FIT = 0;
public static final int BEST_FIT = 1;
public static final int WORST_FIT = 2;
public static final int NEXT_FIT = 3;
public static BareNode head;
//******************************************************
//**** IMPORTANT: DO NOT CHANGE/ALTER/REMOVE ****
//**** ANYTHING PROVIDED LIKE THE INSTANCE ****
//**** VARIABLES IN THIS NESTED CLASS. ALSO ****
//**** DON'T REMOVE THE CLASS ITSELF OR ANYTHING ****
//**** STRANGE LIKE THAT. ****
//******************************************************
public static class BareNode {
public MemBlock block;
public BareNode next;
public BareNode prev;
public boolean marked;
public BareNode(MemBlock block) {
this.block = block;
}
}
public BareNode getHead(){
return head;
}
public BareNode malloc(int size){
BareNode node = new BareNode(new MemBlock(0,size,false));
node.next=head;
node.prev=null;
if(head!= null){
head.prev=node;
}
head=node;
return node;
}
public BareNode realloc(BareNode oldBn, int size){
BareNode bNode = oldBn;
bNode.block.size=size;
return bNode;
}
public int garbageCollect(Set<Integer> addrs){
return 2;
}
public boolean free(BareNode node){
return true;
}
public static MemMan factory(int fit, BareNode head){
this.head= head;
}
public MemMan iterator() {
return new LinkedListIterator();
}
private class LinkedListIterator implements Iterator<MemBlock> {
private BareNode current = head;
public MemBlock next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
MemBlock item = current.block;
current = current.next;
return item;
}
public boolean hasNext() {
return current != null;
}
public void remove() {
throw new UnsupportedOperationException();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
i have not found anyone.
FREQUENCY : always