static void collectPackagesFromJar(Path jarPath, Set<String> packages) {
		try {
			try (JarFile jarFile = new JarFile(jarPath.toFile())) {
				Manifest manifest = jarFile.getManifest();

				// if this jar is an OSGi bundle, use its declared exports
				String exportPackageString = manifest != null
						? manifest.getMainAttributes().getValue(Constants.EXPORT_PACKAGE)
						: null;
				if (exportPackageString != null) {
					String saved = null;
					/*
					 *	split on commas not contained in quotes.
					 * 
					 *	e.g.
					 *		org.foo,org.bar;uses="org.baz,org.qux"
					 *		       ^- should split here  ^- not here
					 *
					 *	We first split on all commas. The first entry, 
					 *		org.foo    
					 *	has an even number of quotes, so it's added as is to packages.
					 *	The second entry,
					 *		        org.bar;uses="org.baz
					 *	has an odd number of quotes, so we save
					 *		        org.bar;uses="org.baz,
					 *	Then the third entry,
					 *		                              org.qux"
					 *	is appended, and the result has an even number of quotes, so is added.
					 */

					for (String packageName : exportPackageString.split(",")) {
						boolean evenQuoteCount = hasEvenQuoteCount(packageName);
						if (saved != null) {
							packageName = saved + packageName;
							evenQuoteCount = !evenQuoteCount;
							saved = null;
						}
						if (evenQuoteCount) {
							packages.add(packageName);
						}
						else {
							saved = packageName + ',';
						}
					}
				}
				else {
					jarFile.stream()
							.filter(entry -> entry.getName().endsWith(".class"))
							.forEach(jarEntry -> {
								String entryName = jarEntry.getName();
								int lastSlash = entryName.lastIndexOf('/');
								if (lastSlash > 0) {
									packages.add(
										entryName.substring(0, lastSlash).replace('/', '.'));
								}
							});
				}
			}
		}
		catch (IOException e) {
			Msg.error(OSGiUtils.class, "Error while collecting packages from jar", e);
		}
	}
parse Export-Package string from a bundle manifest

@param exportPackageString Import-Package value
@return deduced capabilities or null if there was an error
@throws BundleException on parse failure
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/OSGiUtils.java