The easy and most simply way to handle this is osing Object like in ArrayList.
The problem with then always casting from Object to T is thousands of unchecked warnings in PriorityQueue. I would propose the following:
In general the final T heap variable should be private to the PQ and used only there. For performance yonik wanted the heap protected and that caused the issue. As long as the heap array is private it can never be accessed incorrectly.
So my proposal is to internally use the T as a private field and simply use another Object thats protected (pointing to the same array). This would fix the problem. The most correct idea would be to add a setHeapSlot(int, T o) and T getHeapSlot(int) method and hiding the T heap completely, but I know, Yonik will disagree
There is some other problem: the heap array should be final, but it cannot, because of the stupid initialize() method. I would like to remove this method and simply move the code to PQ's ctor. I don't understand why the initialize() method is there, which is a problem: Every guide on Java programming tells you to never call protected overrideable methods from ctors, as this can break easily. If the heap is final, the problem of having two references to the same object is not a problem anymore.