You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/08/28 11:14:58 UTC
[GitHub] geertjanw closed pull request #790: Enable JDK matrix in Travis
geertjanw closed pull request #790: Enable JDK matrix in Travis
URL: https://github.com/apache/incubator-netbeans/pull/790
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/.gitignore b/.gitignore
index 86c1e0ac0a..d1e641dac1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@
/*/*/external/*.dll
/*/*/external/*.exe
/*/*/external/*.js
+/*/*/external/*.nbm
/*/*/external/*/**
/nbbuild/netbeans/
/nbbuild/nbms/
diff --git a/.travis.yml b/.travis.yml
index be2a895333..1be4db58bc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,16 +15,23 @@
# specific language governing permissions and limitations
# under the License.
language: java
-jdk:
- - oraclejdk8
script:
- if [ "x$RAT" == "xtrue" ]; then (ant -quiet build-source-config && mkdir scratch && cd scratch && unzip -qq ../nbbuild/build/basic-src* && ant -quiet rat -Drat-report.haltonfailure=true && cd .. && rm -rf scratch); fi
- - ant -quiet build -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false
+ - if [ "x$OPTS" == "x" ]; then OPTS="-quiet build -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false"; fi
+ - ant $OPTS
- if [ "x$COMPILETEST" == "xtrue" ]; then ant -quiet test -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false -Dtest.includes=NoTestsJustBuild; fi
- if [ "x$LICENSE" == "xtrue" ]; then ant -quiet verify-libs-and-licenses -Dverify-libs-and-licenses.haltonfailure=true; fi
- if [ "x$EOL" == "xtrue" ]; then ./travis-check-line-endings.sh; fi
- if [ "x$SIGTEST" == "xtrue" ]; then ant check-sigtests; fi
- if [ "x$CV" == "xtrue" ]; then ant -quiet -f ergonomics/ide.ergonomics/ test -Dtest.config=commit; fi
-env:
- - SIGTEST=false COMPILETEST=true RAT=true EOL=false LICENSE=true CV=false
- - SIGTEST=true COMPILETEST=false RAT=false EOL=true LICENSE=false CV=true
+
+matrix:
+ include:
+ - env: SIGTEST=false COMPILETEST=true RAT=true EOL=false LICENSE=true CV=false
+ jdk: oraclejdk8
+
+ - env: SIGTEST=true COMPILETEST=false RAT=false EOL=true LICENSE=false CV=true
+ jdk: oraclejdk8
+
+ - env: OPTS="build-platform -Dpermit.jdk9.builds=true -Dvanilla.javac.exists=true"
+ jdk: oraclejdk11
diff --git a/nbbuild/templates/common.xml b/nbbuild/templates/common.xml
index a0cbef13a7..e1fbc795b0 100644
--- a/nbbuild/templates/common.xml
+++ b/nbbuild/templates/common.xml
@@ -65,7 +65,7 @@
<condition property="javahelp.class.path.extension" value="docs/${javahelp.jar.basename}">
<isset property="has.javahelp"/>
</condition>
- <property name="javac.source" value="1.4"/>
+ <property name="javac.source" value="1.7"/>
<property name="javac.target" value="${javac.source}"/>
<property name="javac.compilerargs" value=""/>
<property name="module.auto.deps.xml" location="module-auto-deps.xml"/>
diff --git a/nbi/engine/build.xml b/nbi/engine/build.xml
index c027ccf361..2fb096ed9e 100644
--- a/nbi/engine/build.xml
+++ b/nbi/engine/build.xml
@@ -140,8 +140,13 @@
</target>
- <target name="probe">
- <javac srcdir="probesrc" destdir="${build.classes.dir}/org/netbeans/installer/utils/applications/" source="1.3" debug="true" deprecation="true" target="1.1"/>
+ <target name="probe" depends="init">
+ <available property="probe.javac.source" value="1.6" classname="java.lang.Module"/>
+ <available property="probe.javac.target" value="1.6" classname="java.lang.Module"/>
+ <property name="probe.javac.source" value="1.3"/>
+ <property name="probe.javac.target" value="1.1"/>
+ <mkdir dir="${build.classes.dir}/org/netbeans/installer/utils/applications/"/>
+ <javac srcdir="probesrc" destdir="${build.classes.dir}/org/netbeans/installer/utils/applications/" source="${probe.javac.source}" debug="true" deprecation="true" target="${probe.javac.target}"/>
</target>
</project>
diff --git a/platform/applemenu/build.xml b/platform/applemenu/build.xml
index 800d217919..bbed7244f3 100644
--- a/platform/applemenu/build.xml
+++ b/platform/applemenu/build.xml
@@ -23,7 +23,8 @@
<project name="platform/applemenu" basedir="." default="build">
<import file="../../nbbuild/templates/projectized.xml"/>
- <target name="build-init" depends="projectized.build-init">
+ <available property="desktop.classes.available" classname="java.awt.desktop.AppEvent"/>
+ <target name="build-init" depends="projectized.build-init" unless="desktop.classes.available">
<mkdir dir="${build.dir}/desktop-classes-src" />
<unzip src="external/applemenu-external-desktop-classes-8.2.zip" dest="${build.dir}/desktop-classes-src"/>
<mkdir dir="${build.dir}/desktop-classes-classes" />
diff --git a/platform/core.execution/src/org/netbeans/core/execution/SecMan.java b/platform/core.execution/src/org/netbeans/core/execution/SecMan.java
index bcde561481..a0dc10c9b2 100644
--- a/platform/core.execution/src/org/netbeans/core/execution/SecMan.java
+++ b/platform/core.execution/src/org/netbeans/core/execution/SecMan.java
@@ -85,8 +85,20 @@ private void stopTaskThreadGroup(TaskThreadGroup old) {
//throw new ExitSecurityException();
}
}
-
+
+ @Override
+ public void checkPermission(Permission perm) {
+ checkPermission(perm, null);
+ }
+
@Override
+ public void checkPermission(Permission perm, Object context) {
+ if ("showWindowWithoutWarningBanner".equals(perm.getName())) { // NOI18N
+ checkTopLevelWindow(context);
+ }
+ super.checkPermission(perm, context);
+ }
+
public boolean checkTopLevelWindow(Object window) {
IOPermissionCollection iopc = AccController.getIOPermissionCollection();
if (iopc != null && iopc.grp != null && (window instanceof java.awt.Window)) {
diff --git a/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiIsNotFriendTest.java b/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiIsNotFriendTest.java
index 9902da7124..f5b0dd58bb 100644
--- a/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiIsNotFriendTest.java
+++ b/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiIsNotFriendTest.java
@@ -20,9 +20,11 @@
package org.netbeans.core.netigso;
import java.io.File;
-import java.util.Arrays;
-import java.util.HashSet;
-import org.netbeans.*;
+import org.netbeans.InvalidException;
+import org.netbeans.MockEvents;
+import org.netbeans.MockModuleInstaller;
+import org.netbeans.Module;
+import org.netbeans.ModuleManager;
public class NetigsoOSGiIsNotFriendTest extends NetigsoHid {
public NetigsoOSGiIsNotFriendTest(String name) {
diff --git a/platform/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListStartLevelTest.java b/platform/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListStartLevelTest.java
index 56a1c2400f..85bb108299 100644
--- a/platform/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListStartLevelTest.java
+++ b/platform/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListStartLevelTest.java
@@ -24,11 +24,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.netbeans.*;
+import org.netbeans.MockEvents;
+import org.netbeans.MockModuleInstaller;
+import org.netbeans.Module;
+import org.netbeans.ModuleManager;
+import org.netbeans.Stamps;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.LocalFileSystem;
diff --git a/platform/libs.javafx/build.xml b/platform/libs.javafx/build.xml
index 65ca9efde7..219de43b92 100644
--- a/platform/libs.javafx/build.xml
+++ b/platform/libs.javafx/build.xml
@@ -28,24 +28,13 @@
</condition>
</target>
<target name="-build-openjfx" depends="-check-openjfx" unless="openjfx.zip.exists">
- <mkdir dir="${build.dir}/openjfx-src" />
- <unzip src="external/openjfx-master-rt-8.zip" dest="${build.dir}/openjfx-src" />
- <mkdir dir="${build.dir}/openjfx-classes" />
- <javac destdir="${build.dir}/openjfx-classes" srcdir="${build.dir}/openjfx-src/rt-f89b7dc932af"
- source="1.8" target="1.8" includeantruntime="no" >
- <include name="buildSrc/src/main/java/com/sun/javafx/**" />
- <include name="modules/base/src/main/java/**" />
- <include name="modules/base/src/main/version-info/VersionInfo.java" />
- <include name="modules/controls/src/main/java/**" />
- <include name="modules/fxml/src/main/java/**" />
- <include name="modules/graphics/src/main/java/**" />
- <exclude name="modules/graphics/src/main/java/com/sun/glass/ui/swt/**" />
- <include name="modules/media/src/main/java/**" />
- <include name="modules/swing/src/main/java/**" />
- <include name="modules/web/src/main/java/**" />
- <compilerarg value="-XDignore.symbol.file"/>
- </javac>
- <zip destfile="${build.dir}/openjfx.zip" basedir="${build.dir}/openjfx-classes" />
+ <unzip src="external/lib-javafx-13.03-beta.nbm" dest="${build.dir}">
+ <mapper type="flatten"/>
+ <patternset>
+ <include name="**/javafx-2.2.4.jar"/>
+ </patternset>
+ </unzip>
+ <move file="${build.dir}/javafx-2.2.4.jar" tofile="${build.dir}/openjfx.zip"/>
</target>
<target name="build-init" depends="projectized.build-init,-build-openjfx">
</target>
diff --git a/platform/libs.javafx/external/binaries-list b/platform/libs.javafx/external/binaries-list
index 50d2222bf9..721e0231b2 100644
--- a/platform/libs.javafx/external/binaries-list
+++ b/platform/libs.javafx/external/binaries-list
@@ -14,4 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-BE6B07C1FC3D974AA55E28393F120380DD4D4ACB openjfx-master-rt-8.zip
+7AFF40A979416E4AF0CB62D493FD67E9C93E3830 eu.agrosense.client:lib-javafx:13.03-beta@nbm
diff --git a/platform/libs.javafx/external/openjfx-master-rt-8-license.txt b/platform/libs.javafx/external/lib-javafx-13.03-beta-license.txt
similarity index 98%
rename from platform/libs.javafx/external/openjfx-master-rt-8-license.txt
rename to platform/libs.javafx/external/lib-javafx-13.03-beta-license.txt
index 524255b3fd..5e0ca706a5 100644
--- a/platform/libs.javafx/external/openjfx-master-rt-8-license.txt
+++ b/platform/libs.javafx/external/lib-javafx-13.03-beta-license.txt
@@ -1,12 +1,12 @@
Name: Open JavaFX
-Description: Sources of the master/rt repository of openjfx
-Version: 8
+Description: APIs of JavaFX
+Version: 13.03
License: GPL-2-CP
-Source: file://openjfx-master-rt-8.zip
+Files: lib-javafx-13.03-beta.nbm
Origin: OpenJDK
URL: http://hg.openjdk.java.net/openjfx/8/master/rt/
Type: compile-time
-Comment: Allows to build code leveraging OpenJavaFX on JDKs that don't contain OpenJavaFX.
+Comment: Allows to build code leveraging JavaFX on JDKs that don't contain JavaFX.
The GNU General Public License (GPL)
Version 2, June 1991
diff --git a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoOSGiIsNotFriendTest.java b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoOSGiIsNotFriendTest.java
index 3cf55ba128..cb6eab9e02 100644
--- a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoOSGiIsNotFriendTest.java
+++ b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoOSGiIsNotFriendTest.java
@@ -22,7 +22,11 @@
import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
-import org.netbeans.*;
+import org.netbeans.InvalidException;
+import org.netbeans.MockEvents;
+import org.netbeans.MockModuleInstaller;
+import org.netbeans.Module;
+import org.netbeans.ModuleManager;
public class NetigsoOSGiIsNotFriendTest extends NetigsoHid {
public NetigsoOSGiIsNotFriendTest(String name) {
diff --git a/platform/o.n.bootstrap/build.xml b/platform/o.n.bootstrap/build.xml
index b47aca90fa..df070d2d1c 100644
--- a/platform/o.n.bootstrap/build.xml
+++ b/platform/o.n.bootstrap/build.xml
@@ -32,7 +32,7 @@
<target name="rebuild-main" unless="main.up.to.date">
<mkdir dir="${build.classes.dir}"/>
<delete file="${build.classes.dir}/org/netbeans/Main.class"/>
- <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="${build.compiler.debug}" debuglevel="${build.compiler.debuglevel}" deprecation="${build.compiler.deprecation}" optimize="${build.compiler.optimize}" source="1.4" target="1.4" includeantruntime="false">
+ <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="${build.compiler.debug}" debuglevel="${build.compiler.debuglevel}" deprecation="${build.compiler.deprecation}" optimize="${build.compiler.optimize}" source="1.6" target="1.6" includeantruntime="false">
<classpath refid="cp"/>
<include name="org/netbeans/Main.java"/>
<compilerarg line="${javac.compilerargs}"/>
diff --git a/platform/o.n.bootstrap/src/java/lang/Module.java b/platform/o.n.bootstrap/src/java/lang/Module.java
new file mode 100644
index 0000000000..4b36b26142
--- /dev/null
+++ b/platform/o.n.bootstrap/src/java/lang/Module.java
@@ -0,0 +1,23 @@
+/*
+ * 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 java.lang;
+
+/** Dummy */
+public class Module {
+}
diff --git a/platform/o.n.bootstrap/src/org/netbeans/NbInstrumentation.java b/platform/o.n.bootstrap/src/org/netbeans/NbInstrumentation.java
index f8424d3158..971f5bd4db 100644
--- a/platform/o.n.bootstrap/src/org/netbeans/NbInstrumentation.java
+++ b/platform/o.n.bootstrap/src/org/netbeans/NbInstrumentation.java
@@ -28,8 +28,9 @@
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.jar.JarFile;
import java.util.logging.Level;
@@ -183,5 +184,12 @@ public boolean isNativeMethodPrefixSupported() {
public void setNativeMethodPrefix(ClassFileTransformer transformer, String prefix) {
throw new UnsupportedOperationException();
}
-
+
+ public void redefineModule(java.lang.Module module, Set<java.lang.Module> extraReads, Map<String, Set<java.lang.Module>> extraExports, Map<String, Set<java.lang.Module>> extraOpens, Set<Class<?>> extraUses, Map<Class<?>, List<Class<?>>> extraProvides) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isModifiableModule(java.lang.Module module) {
+ return false;
+ }
}
diff --git a/platform/o.n.bootstrap/src/org/netbeans/TopSecurityManager.java b/platform/o.n.bootstrap/src/org/netbeans/TopSecurityManager.java
index f7536e7548..8163611787 100644
--- a/platform/o.n.bootstrap/src/org/netbeans/TopSecurityManager.java
+++ b/platform/o.n.bootstrap/src/org/netbeans/TopSecurityManager.java
@@ -197,14 +197,17 @@ final void checkExitImpl(int status, AccessControlContext acc) throws SecurityEx
super.checkExit(status);
}
- public @Override boolean checkTopLevelWindow(Object window) {
+ public boolean checkTopLevelWindow(Object window) {
+ return checkTopLevelWindow(new AWTPermission("showWindowWithoutWarningBanner"), window); // NOI18N
+ }
+
+ private boolean checkTopLevelWindow(Permission windowPermission, Object window) {
synchronized (delegates) {
for (SecurityManager sm : delegates) {
- sm.checkTopLevelWindow(window);
+ sm.checkPermission(windowPermission, window);
}
}
-
- return super.checkTopLevelWindow(window);
+ return true;
}
/* XXX probably unnecessary:
@@ -384,7 +387,6 @@ final void checkConnectImpl(String host, int port) {
private final Set<Class> warnedSunMisc = new WeakSet<Class>();
private final Set<String> callerWhiteList = createCallerWhiteList();
- @Override
public void checkMemberAccess(Class<?> clazz, int which) {
final String n = clazz.getName();
if (n.startsWith("sun.misc")) { // NOI18N
@@ -422,7 +424,6 @@ public void checkMemberAccess(Class<?> clazz, int which) {
Exception ex = new Exception(msg.toString()); // NOI18N
LOG.log(l, null, ex);
}
- super.checkMemberAccess(clazz, which);
}
/**
@@ -477,6 +478,9 @@ private static boolean isDangerous(String caller, String accessTo) {
checkWhetherAccessedFromSwingTransfer ();
}
}
+ if ("showWindowWithoutWarningBanner".equals(perm.getName())) { // NOI18N
+ checkTopLevelWindow(perm, null);
+ }
}
return;
}
diff --git a/platform/openide.util.enumerations/build.xml b/platform/openide.util.enumerations/build.xml
index 4f97d05bb4..7fa277b49a 100644
--- a/platform/openide.util.enumerations/build.xml
+++ b/platform/openide.util.enumerations/build.xml
@@ -21,7 +21,20 @@
-->
<project name="platform/openide.util.enumerations" default="build" basedir=".">
-
+ <available property="is.jdk9" classname="java.lang.Module"/>
<import file="../../nbbuild/templates/projectized.xml"/>
+ <target name="compile" depends="-copy" unless="is.jdk9">
+ <antcall target="projectized-common.compile"/>
+ </target>
+
+ <target name="-copy" depends="init,up-to-date">
+ <copy todir="${build.classes.dir}">
+ <fileset dir="${src.dir}" excludes="${jar-excludes}"/>
+ </copy>
+ </target>
+
+ <target name="do-unit-test-build" unless="is.jdk9">
+ <antcall target="projectized-common.do-unit-test-build"/>
+ </target>
</project>
diff --git a/platform/openide.util.enumerations/nbproject/project.properties b/platform/openide.util.enumerations/nbproject/project.properties
index 9a7fcfa25b..bac7a70564 100644
--- a/platform/openide.util.enumerations/nbproject/project.properties
+++ b/platform/openide.util.enumerations/nbproject/project.properties
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
+javac.source=1.4
is.autoload=true
#javadoc.main.page=org/openide/util/doc-files/api.html
#javadoc.arch=${basedir}/../arch/arch-openide-util.xml
diff --git a/platform/openide.util.ui/src/org/netbeans/modules/openide/util/NbBundleProcessor.java b/platform/openide.util.ui/src/org/netbeans/modules/openide/util/NbBundleProcessor.java
deleted file mode 100644
index c0710f54a2..0000000000
--- a/platform/openide.util.ui/src/org/netbeans/modules/openide/util/NbBundleProcessor.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * 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.netbeans.modules.openide.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Processor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.StandardLocation;
-import org.openide.util.EditableProperties;
-import org.openide.util.NbBundle;
-import org.openide.util.NbCollections;
-import org.openide.util.Utilities;
-import org.openide.util.lookup.ServiceProvider;
-
-@ServiceProvider(service = Processor.class)
-@SupportedSourceVersion(SourceVersion.RELEASE_7)
-public class NbBundleProcessor extends AbstractProcessor {
-
- public @Override Set<String> getSupportedAnnotationTypes() {
- return Collections.singleton(NbBundle.Messages.class.getCanonicalName());
- }
-
- public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (roundEnv.processingOver()) {
- return false;
- }
- Map</*package*/String,Set<Element>> annotatedElementsByPackage = new HashMap<String,Set<Element>>();
- for (Element e : roundEnv.getElementsAnnotatedWith(NbBundle.Messages.class)) {
- NbBundle.Messages messages = e.getAnnotation(NbBundle.Messages.class);
- if (messages == null) { // bug in java.source, apparently; similar to #195983
- continue;
- }
- String pkg = findPackage(e);
- Set<Element> annotatedElements = annotatedElementsByPackage.get(pkg);
- if (annotatedElements == null) {
- annotatedElements = new HashSet<Element>();
- annotatedElementsByPackage.put(pkg, annotatedElements);
- }
- annotatedElements.add(e);
- }
- PACKAGE: for (Map.Entry<String,Set<Element>> packageEntry : annotatedElementsByPackage.entrySet()) {
- String pkg = packageEntry.getKey();
- Set<Element> annotatedElements = packageEntry.getValue();
- PackageElement pkgE = processingEnv.getElementUtils().getPackageElement(pkg);
- if (pkgE != null) {
- Set<Element> unscannedTopElements = new HashSet<Element>();
- unscannedTopElements.add(pkgE);
- try {
- unscannedTopElements.addAll(pkgE.getEnclosedElements());
- } catch (/*NullPointerException,BadClassFile*/RuntimeException x) { // #196556
- processingEnv.getMessager().printMessage(Kind.WARNING, "#196556: reading " + pkg + " failed with " + x + " in " + x.getStackTrace()[0] + "; do a clean build!");
- }
- unscannedTopElements.removeAll(roundEnv.getRootElements());
- addToAnnotatedElements(unscannedTopElements, annotatedElements);
- } else {
- processingEnv.getMessager().printMessage(Kind.WARNING, "Could not check for other source files in " + pkg);
- }
- Map</*key*/String,/*value*/String> pairs = new HashMap<String,String>();
- Map</*identifier*/String,Element> identifiers = new HashMap<String,Element>();
- Map</*key*/String,/*simplename*/String> compilationUnits = new HashMap<String,String>();
- Map</*key*/String,/*line*/String[]> comments = new HashMap<String,String[]>();
- for (Element e : annotatedElements) {
- String simplename = findCompilationUnitName(e);
- List<String> runningComments = new ArrayList<String>();
- for (String keyValue : e.getAnnotation(NbBundle.Messages.class).value()) {
- if (keyValue.startsWith("#")) {
- runningComments.add(keyValue);
- if (keyValue.matches("# +(PART)?(NO)?I18N *")) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "#NOI18N and related keywords must not include spaces", e);
- }
- continue;
- }
- int i = keyValue.indexOf('=');
- if (i == -1) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Bad key=value: " + keyValue, e);
- continue;
- }
- String key = keyValue.substring(0, i);
- if (key.isEmpty() || !key.equals(key.trim())) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Whitespace not permitted in key: " + keyValue, e);
- continue;
- }
- Element original = identifiers.put(toIdentifier(key), e);
- if (original != null) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Duplicate key: " + key, e);
- processingEnv.getMessager().printMessage(Kind.ERROR, "Duplicate key: " + key, original);
- continue PACKAGE; // do not generate anything
- }
- String value = keyValue.substring(i + 1);
- pairs.put(key, value);
- compilationUnits.put(key, simplename);
- if (!runningComments.isEmpty()) {
- comments.put(key, runningComments.toArray(new String[runningComments.size()]));
- runningComments.clear();
- }
- }
- if (!runningComments.isEmpty()) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Comments must precede keys", e);
- }
- }
- Element[] elements = new HashSet<Element>(identifiers.values()).toArray(new Element[0]);
- try {
- EditableProperties p = new EditableProperties(true);
- // Load any preexisting bundle so we can just add our keys.
- try {
- InputStream is = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, pkg, "Bundle.properties").openInputStream();
- try {
- p.load(is);
- } finally {
- is.close();
- }
- } catch (IOException x) {
- // OK, not there
- }
- for (String key : p.keySet()) {
- if (pairs.containsKey(key)) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Key " + key + " is a duplicate of one from Bundle.properties", identifiers.get(toIdentifier(key)));
- }
- }
- // Also check class output for (1) incremental builds, (2) preexisting bundles from Maven projects.
- try {
- InputStream is = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, pkg, "Bundle.properties").openInputStream();
- try {
- // do not use p.load(is) as the impl in EditableProperties does not currently handle duplicates properly
- EditableProperties p2 = new EditableProperties(true);
- p2.load(is);
- p.putAll(p2);
- } finally {
- is.close();
- }
- } catch (IOException x) {
- // OK, not there
- }
- p.putAll(pairs);
- for (Map.Entry<String,String[]> entry2 : comments.entrySet()) {
- p.setComment(entry2.getKey(), entry2.getValue(), false);
- }
- OutputStream os = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, pkg, "Bundle.properties", elements).openOutputStream();
- try {
- p.store(os);
- } finally {
- os.close();
- }
- Map</*identifier*/String,/*method body*/String> methods = new TreeMap<String,String>();
- for (Map.Entry<String, String> entry2 : pairs.entrySet()) {
- String key = entry2.getKey();
- String value = entry2.getValue();
- StringBuilder method = new StringBuilder();
- method.append(" /**\n");
- List<String> params = new ArrayList<String>();
- int i = 0;
- while (value.contains("{" + i)) {
- params.add("arg" + i++);
- }
- String[] commentLines = comments.get(key);
- if (commentLines != null) {
- for (String comment : commentLines) {
- Matcher m = Pattern.compile("# [{](\\d+)[}] - (.+)").matcher(comment);
- if (m.matches()) {
- i = Integer.parseInt(m.group(1));
- while (i >= params.size()) {
- params.add("arg" + params.size());
- }
- String desc = m.group(2);
- params.set(i, toIdentifier(desc));
- method.append(" * @param ").append(params.get(i)).append(" ").append(toJavadoc(desc)).append("\n");
- }
- }
- }
- StringBuffer annotatedValue = new StringBuffer("<i>");
- Matcher m = Pattern.compile("[{](\\d+)[}]").matcher(toJavadoc(value));
- while (m.find()) {
- i = Integer.parseInt(m.group(1));
- m.appendReplacement(annotatedValue, i < params.size() ? "</i>{@code " + params.get(i) + "}<i>" : m.group());
- }
- m.appendTail(annotatedValue);
- annotatedValue.append("</i>");
- method.append(" * @return ").append(annotatedValue.toString().replace("<i></i>", "")).append('\n');
- method.append(" * @see ").append(compilationUnits.get(key)).append('\n');
- method.append(" */\n");
- String name = toIdentifier(key);
- method.append(" static String ").append(name).append("(");
- boolean first = true;
- i = 0;
- for (String param : params) {
- if (param.equals("arg" + i)) {
- warnUndocumented(i, identifiers.get(name), key);
- }
- i++;
- if (first) {
- first = false;
- } else {
- method.append(", ");
- }
- method.append("Object ").append(param);
- }
- method.append(") {\n");
- method.append(" return org.openide.util.NbBundle.getMessage(Bundle.class, \"").append(key).append("\"");
- for (String param : params) {
- method.append(", ").append(param);
- }
- method.append(");\n");
- method.append(" }\n");
- methods.put(name, method.toString());
- }
- try {
- Set<String> restored = new TreeSet<String>();
- Matcher m = Pattern.compile(" /[*][*]\r?\n(?: [*].+\r?\n)+ [*] @see (?:[\\w-]+)\r?\n [*]/\r?\n static String (\\w+).+\r?\n .+\r?\n [}]\r?\n").matcher(processingEnv.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, pkg, "Bundle.java").getCharContent(false));
- while (m.find()) {
- String identifier = m.group(1);
- if (!methods.containsKey(identifier)) {
- methods.put(identifier, m.group());
- restored.add(identifier);
- }
- }
- /*
- if (!restored.isEmpty()) {
- processingEnv.getMessager().printMessage(Kind.NOTE, "loaded " + pkg + ".Bundle identifiers " + restored + " from earlier run");
- }
- */
- } catch (IOException x) {
- // OK, not there
- }
- String fqn = pkg + ".Bundle";
- Writer w = processingEnv.getFiler().createSourceFile(fqn, elements).openWriter();
- try {
- PrintWriter pw = new PrintWriter(w);
- pw.println("package " + pkg + ";");
- pw.println("/** Localizable strings for {@link " + pkg + "}. */");
- pw.println("@javax.annotation.Generated(value=\"" + NbBundleProcessor.class.getName() + "\")");
- pw.println("class Bundle {");
- for (String method : methods.values()) {
- pw.print(method);
- }
- pw.println(" private Bundle() {}");
- pw.println("}");
- pw.flush();
- pw.close();
- } finally {
- w.close();
- }
- } catch (IOException x) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Could not generate files: " + x, elements[0]);
- }
- }
- return true;
- }
-
- private String findPackage(Element e) {
- switch (e.getKind()) {
- case PACKAGE:
- return ((PackageElement) e).getQualifiedName().toString();
- default:
- return findPackage(e.getEnclosingElement());
- }
- }
-
- private String findCompilationUnitName(Element e) {
- switch (e.getKind()) {
- case PACKAGE:
- return "package-info";
- case CLASS:
- case INTERFACE:
- case ENUM:
- case ANNOTATION_TYPE:
- switch (e.getEnclosingElement().getKind()) {
- case PACKAGE:
- return e.getSimpleName().toString();
- }
- }
- return findCompilationUnitName(e.getEnclosingElement());
- }
-
- private String toIdentifier(String key) {
- if (Utilities.isJavaIdentifier(key)) {
- return key;
- } else {
- String i = key.replaceAll("[^\\p{javaJavaIdentifierPart}]+", "_");
- if (Utilities.isJavaIdentifier(i)) {
- return i;
- } else {
- return "_" + i;
- }
- }
- }
-
- private String toJavadoc(String text) {
- return text.replace("&", "&").replace("<", "<").replace("*/", "*/").replace("\n", "<br>").replace("@", "@");
- }
-
- private void addToAnnotatedElements(Collection<? extends Element> unscannedElements, Set<Element> annotatedElements) {
- for (Element e : unscannedElements) {
- if (e.getAnnotation(NbBundle.Messages.class) != null) {
- annotatedElements.add(e);
- }
- if (e.getKind() != ElementKind.PACKAGE) {
- addToAnnotatedElements(e.getEnclosedElements(), annotatedElements);
- }
- }
- }
-
- private void warnUndocumented(int i, Element e, String key) {
- AnnotationMirror mirror = null;
- AnnotationValue value = null;
- if (e != null) {
- for (AnnotationMirror _mirror : e.getAnnotationMirrors()) {
- if (_mirror.getAnnotationType().toString().equals(NbBundle.Messages.class.getCanonicalName())) {
- mirror = _mirror;
- for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
- if (entry.getKey().getSimpleName().contentEquals("value")) {
- // SimpleAnnotationValueVisitor6 unusable here since we need to determine the AnnotationValue in scope when visitString is called:
- Object v = entry.getValue().getValue();
- if (v instanceof String) {
- if (((String) v).startsWith(key + "=")) {
- value = entry.getValue();
- }
- } else {
- for (AnnotationValue subentry : NbCollections.checkedListByCopy((List<?>) v, AnnotationValue.class, true)) {
- v = subentry.getValue();
- if (v instanceof String) {
- if (((String) v).startsWith(key + "=")) {
- value = subentry;
- break;
- }
- }
- }
- }
- break;
- }
- }
- break;
- }
- }
- }
- processingEnv.getMessager().printMessage(Kind.WARNING, "Undocumented format parameter {" + i + "}", e, mirror, value);
- }
-
-}
diff --git a/platform/openide.util/src/org/netbeans/modules/openide/util/NbBundleProcessor.java b/platform/openide.util/src/org/netbeans/modules/openide/util/NbBundleProcessor.java
index d64ebfb418..c6056e05e7 100644
--- a/platform/openide.util/src/org/netbeans/modules/openide/util/NbBundleProcessor.java
+++ b/platform/openide.util/src/org/netbeans/modules/openide/util/NbBundleProcessor.java
@@ -271,7 +271,6 @@
PrintWriter pw = new PrintWriter(w);
pw.println("package " + pkg + ";");
pw.println("/** Localizable strings for {@link " + pkg + "}. */");
- pw.println("@javax.annotation.Generated(value=\"" + NbBundleProcessor.class.getName() + "\")");
pw.println("class Bundle {");
for (String method : methods.values()) {
pw.print(method);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists