ObjectUpcastedUsageInfo[] (UsageInfo[] usages) { ArrayList<ObjectUpcastedUsageInfo> result = new ArrayList<>(); for (UsageInfo usage : usages) { if (usage instanceof ObjectUpcastedUsageInfo) { result.add(((ObjectUpcastedUsageInfo)usage)); } } return result.toArray(new ObjectUpcastedUsageInfo[0]); }