javagenericsjgrasp

How to uncheck -Xlint when using JGrasp?


In my textbook it has us creating abstract data type classes, in this case a Stack. It is based off an array, thus bounded. Here is the part of the code generating the message:

package ch03.stacks;

    public class ArrayStack<T> implements BoundedStackInterface<T> 
    {
  protected final int DEFCAP = 100; // default capacity
  protected T[] stack;              // holds stack elements
  protected int topIndex = -1;      // index of top element in stack

  public ArrayStack() 
  {
    stack = (T[]) new Object[DEFCAP];
  }

  public ArrayStack(int maxSize) 
  {
    stack = (T[]) new Object[maxSize];
  }

I believe the protected T[] stack; part is the issue since it does not have a type set, but that is how it is supposed to be, left generic for the user of the class to specify. Here is the message generated in JGrasp:

Note: ch03\stacks\ArrayStack.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

I checked JGrasp help documents but they were of no help.


Solution

  • You need to go to settings->compiler settings->workspace->flags/args, then find the box that says "compile". click in the box. You should be able to type in the text area to the right of the box now. Type "-Xlint:unchecked" in the text area, apply, then save. There is a screenshot on this blog: http://comp2210.blogspot.com/ if you get lost somehow. You'll still get errors when you compile; you can just ignore them and run your program. cheers.