-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FELIX-5800: calculate system package exports at runtime on jpms, opti…
…onally with uses constraints, and cleanup the existing default definitions. git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1829104 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
7 changed files
with
3,542 additions
and
1,080 deletions.
There are no files selected for viewing
545 changes: 345 additions & 200 deletions
545
osgi-r7/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
osgi-r7/framework/src/main/java/org/apache/felix/framework/util/ClassFileVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.felix.framework.util; | ||
|
||
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
import java.util.SortedMap; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
@IgnoreJRERequirement | ||
public class ClassFileVisitor extends java.nio.file.SimpleFileVisitor<java.nio.file.Path> | ||
{ | ||
private final Set<String> m_imports; | ||
private final Set<String> m_exports; | ||
private final ClassParser m_classParser; | ||
private final SortedMap<String, SortedSet<String>> m_result; | ||
|
||
public ClassFileVisitor(Set<String> imports, Set<String> exports, ClassParser classParser, SortedMap<String, SortedSet<String>> result) | ||
{ | ||
m_imports = imports; | ||
m_exports = exports; | ||
m_classParser = classParser; | ||
m_result = result; | ||
} | ||
|
||
@Override | ||
public java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs) throws IOException | ||
{ | ||
if (file.getNameCount() > 3) | ||
{ | ||
String name = file.subpath(2, file.getNameCount() - 1).toString().replace("/", "."); | ||
if (m_exports.contains(name) && file.toString().endsWith(".class")) | ||
{ | ||
SortedSet<String> strings = m_result.get(name); | ||
|
||
if (!name.startsWith("java.")) | ||
{ | ||
try | ||
{ | ||
Set<String> refs = m_classParser.parseClassFileUses(file.toString(), java.nio.file.Files.newInputStream(file)); | ||
refs.retainAll(m_imports); | ||
refs.remove(name); | ||
if (strings == null) | ||
{ | ||
strings = new TreeSet<String>(refs); | ||
m_result.put(name, strings); | ||
} | ||
else | ||
{ | ||
strings.addAll(refs); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
ex.printStackTrace(); | ||
} | ||
} | ||
else if (strings == null) | ||
{ | ||
m_result.put(name, new TreeSet<String>()); | ||
} | ||
} | ||
} | ||
return java.nio.file.FileVisitResult.CONTINUE; | ||
} | ||
} |
Oops, something went wrong.