public final static Reference[] getXReferences(CodeUnit cu, int maxNumber) {
		Program prog = cu.getProgram();
		if (prog == null) {
			return EMPTY_REF_ARRAY;
		}
		List<Reference> xrefList = new ArrayList<>();
		//lookup the direct xrefs to the current code unit
		//
		ReferenceIterator iter = prog.getReferenceManager().getReferencesTo(cu.getMinAddress());
		while (iter.hasNext()) {
			Reference ref = iter.next();
			xrefList.add(ref);
			if (maxNumber > 0 && xrefList.size() == maxNumber) {
				break;
			}
		}
		// Check for thunk reference
		Function func = prog.getFunctionManager().getFunctionAt(cu.getMinAddress());
		if (func != null) {
			Address[] thunkAddrs = func.getFunctionThunkAddresses();
			if (thunkAddrs != null) {
				for (Address thunkAddr : thunkAddrs) {
					xrefList.add(new ThunkReference(thunkAddr, func.getEntryPoint()));
				}
			}
		}
		Reference[] arr = new Reference[xrefList.size()];
		xrefList.toArray(arr);
		return arr;
	}
Returns an array containing the first <b><code>maxNumber</code></b>
direct xref references to the specified code unit.

@param cu the code unit to generate the xrefs
@param maxNumber max number of xrefs to get,
                 or -1 to get all references

@return array first <b><code>maxNumber</code></b> xrefs to the code unit
Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtil.java