So I'm trying to run a particular file called CountdownTree.java that inherits functions from a bunch of other files in the package comp2402a4.
These were all starting files given by my instructor that I'm supposed to add to, and there shouldn't be any errors running these files. I compiled it using 'javac comp2402a4/CountdownTree.java' and it compiled fine with no problems. But when I try to run it using 'java comp2402a4/CountdownTree.java', I get the error:
Exception in thread "main" java.lang.IllegalAccessError: failed to access class
comp2402a4.DefaultComparator from class comp2402a4.CountdownTree (comp2402a4.DefaultComparator is in
unnamed module of loader 'app'; comp2402a4.CountdownTree is in unnamed module of loader
com.sun.tools.javac.launcher.Main$MemoryClassLoader @21507a04)
at comp2402a4.CountdownTree.<init>(CountdownTree.java:26)
at comp2402a4.CountdownTree.main(CountdownTree.java:53)
I have absolutely no idea what's causing this and I'm really frusterated because I need this file to run so I can start my project. I tried googling but couldn't figure out what's wrong. I would really appreciate any help as to what might be the problem.
CountdownTree.java:
package comp2402a4;
import java.util.Random;
import java.util.SortedSet;
import java.util.TreeSet;
/**
* An unfinished implementation of an Countdown tree (for exercises)
* @author morin
*
* @param <T>
*/
public class CountdownTree<T> extends
BinarySearchTree<CountdownTree.Node<T>, T> implements SSet<T> {
// countdown delay factor
double d;
public static class Node<T> extends BSTNode<Node<T>,T> {
int timer; // the height of the node
}
public CountdownTree(double d) {
this.d = d;
sampleNode = new Node<T>();
c = new DefaultComparator<T>();
}
public boolean add(T x) {
Node<T> u = new Node<T>();
u.timer = (int)Math.ceil(d);
u.x = x;
if (super.add(u)) {
// add some code here
return true;
}
return false;
}
public void splice(Node<T> u) {
Node<T> w = u.parent;
super.splice(u);
// add some code here (we just removed u from the tree)
}
protected void explode(Node<T> u) {
// Write this code to explode u
// Make sure to update u.parent and/or r (the tree root) as appropriate
}
// Here is some test code you can use
public static void main(String[] args) {
Testum.sortedSetSanityTests(new SortedSSet<Integer>(new CountdownTree<Integer>(1)), 1000);
Testum.sortedSetSanityTests(new SortedSSet<Integer>(new CountdownTree<Integer>(2.5)), 1000);
Testum.sortedSetSanityTests(new SortedSSet<Integer>(new CountdownTree<Integer>(0.5)), 1000);
java.util.List<SortedSet<Integer>> ell = new java.util.ArrayList<SortedSet<Integer>>();
ell.add(new java.util.TreeSet<Integer>());
ell.add(new SortedSSet<Integer>(new CountdownTree<Integer>(1)));
ell.add(new SortedSSet<Integer>(new CountdownTree<Integer>(2.5)));
ell.add(new SortedSSet<Integer>(new CountdownTree<Integer>(0.5)));
Testum.sortedSetSpeedTests(ell, 1000000);
}
}
Here's a folder with all the files in the package if you'd like to try running it:
https://drive.google.com/drive/folders/1Cu0qNud7-1ACqLvyLahKiVVk0aHcLMEr?usp=sharing