Package[] () { // Get all our packages. Package[] packages; synchronized(definedPackages) { packages = new Package[definedPackages.size()]; definedPackages.values().toArray(packages); } // If we have a parent get all packages defined by our parents. Package[] parentPackages; if (parent == null) parentPackages = VMClassLoader.getPackages(); else parentPackages = parent.getPackages(); Package[] allPackages = new Package[parentPackages.length + packages.length]; System.arraycopy(parentPackages, 0, allPackages, 0, parentPackages.length); System.arraycopy(packages, 0, allPackages, parentPackages.length, packages.length); return allPackages; }