diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5533d0be1849..bfd3bf79c679 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2114,9 +2114,8 @@ jobs: - name: web.jsfapi run: ant $OPTS -f enterprise/web.jsfapi test -# Fails -# - name: web.jspparser -# run: ant $OPTS -f enterprise/web.jspparser test + - name: web.jspparser + run: ant $OPTS -f enterprise/web.jspparser test # Fails # - name: web.project diff --git a/.gitignore b/.gitignore index 6045e2589e5a..d20d1599df4e 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,8 @@ /nb/ide.launcher/windows/nbproject/Package-*.bash /platform/o.n.bootstrap/launcher/windows/nbproject/Makefile-*.mk /platform/o.n.bootstrap/launcher/windows/nbproject/Package-*.bash +/enterprise/web.jspparser/test/unit/data/emptyWebProject/lib/*.jar +/enterprise/web.jspparser/test/unit/data/project2/lib/*.jar # Database logs derby.log diff --git a/enterprise/j2ee.dd/nbproject/project.xml b/enterprise/j2ee.dd/nbproject/project.xml index fdd319301fea..1a501bc06bbc 100644 --- a/enterprise/j2ee.dd/nbproject/project.xml +++ b/enterprise/j2ee.dd/nbproject/project.xml @@ -248,10 +248,6 @@ org.netbeans.modules.j2ee.dd.spi.ejb org.netbeans.modules.j2ee.dd.spi.web - - ext/javaee-api-5.jar - external/javaee-api-5.jar - diff --git a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/annotation/ResourceImpl.java b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/annotation/ResourceImpl.java index 8b1a7cc4ecc9..195c8be6d431 100644 --- a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/annotation/ResourceImpl.java +++ b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/annotation/ResourceImpl.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; -import javax.annotation.Resource.AuthenticationType; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; diff --git a/enterprise/web.jspparser/build.xml b/enterprise/web.jspparser/build.xml index fb343475a46d..9e1ab51ddd2f 100644 --- a/enterprise/web.jspparser/build.xml +++ b/enterprise/web.jspparser/build.xml @@ -29,9 +29,14 @@ + + + + + - - + + @@ -49,12 +54,26 @@ + includes="org/apache/jasper/**, com/sun/el/**, com/sun/appserv/server/util/PreprocessorUtil.class, org/glassfish/jsp/api/**" + zipfile="./external/generated-glassfish-jspparser-5.1.0.jar" /> + + + + + + + + + + + + + + diff --git a/enterprise/web.jspparser/external/binaries-list b/enterprise/web.jspparser/external/binaries-list index 56df76326266..9e1b7b61a0e3 100644 --- a/enterprise/web.jspparser/external/binaries-list +++ b/enterprise/web.jspparser/external/binaries-list @@ -19,3 +19,9 @@ F48473482C0E3E714F87186D9305BCAE30B7F5CB org.glassfish:jakarta.el:3.0.4 9A3D933B7B079AD73C43878BF09AC47586FAC897 org.glassfish.main.common:glassfish-ee-api:5.1.0 CED8804F81DB0C9099786472C615A12EA592C44B org.glassfish.main.common:common-util:5.1.0 +# Binary dependencies required for the unittest data (test projects). Only +# required at build/test time. Don't change/update unless unittest changes are +# intended. +34A035507F0270F1C6B7722D728BD7B5A9BBAC4C jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:1.2.7 +F5A092DE3B2B087C14CA4B8D6F2C77A1F6802828 org.glassfish.web:jakarta.servlet.jsp.jstl:1.2.6 +8CFF7DC1E492911F3DD7640EBFB60D6206A1DD40 commons-logging:commons-logging:1.3.1 diff --git a/enterprise/web.jspparser/external/commons-logging-1.3.1-license.txt b/enterprise/web.jspparser/external/commons-logging-1.3.1-license.txt new file mode 100644 index 000000000000..9d40ee4d11c9 --- /dev/null +++ b/enterprise/web.jspparser/external/commons-logging-1.3.1-license.txt @@ -0,0 +1,209 @@ +Name: Apache Jakarta Commons Logging +Origin: Apache Software Foundation +Version: 1.3.1 +License: Apache-2.0 +Description: Logging component +URL: https://commons.apache.org/proper/commons-logging/ +Type: compile-time + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/enterprise/web.jspparser/external/commons-logging-1.3.1-notice.txt b/enterprise/web.jspparser/external/commons-logging-1.3.1-notice.txt new file mode 100644 index 000000000000..db3351bca504 --- /dev/null +++ b/enterprise/web.jspparser/external/commons-logging-1.3.1-notice.txt @@ -0,0 +1,5 @@ +Apache Commons Logging +Copyright 2001-2024 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (https://www.apache.org/). \ No newline at end of file diff --git a/enterprise/web.jspparser/external/jakarta.servlet.jsp.jstl-1.2-license.txt b/enterprise/web.jspparser/external/jakarta.servlet.jsp.jstl-1.2-license.txt new file mode 100644 index 000000000000..f8726ad9ddb4 --- /dev/null +++ b/enterprise/web.jspparser/external/jakarta.servlet.jsp.jstl-1.2-license.txt @@ -0,0 +1,94 @@ +Name: Jakarta Standard Tag Library +Version: 1.2 +License: EPL-v20 +Description: Jakarta Standard Tag Library +Origin: Eclipse Foundation (https://projects.eclipse.org/projects/ee4j.jstl) +Files: jakarta.servlet.jsp.jstl-1.2.6.jar, jakarta.servlet.jsp.jstl-api-1.2.7.jar +Type: compile-time + +Eclipse Public License - v 2.0 +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. Definitions +“Contribution” means: + +a) in the case of the initial Contributor, the initial content Distributed under this Agreement, and +b) in the case of each subsequent Contributor: +i) changes to the Program, and +ii) additions to the Program; where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works. +“Contributor” means any person or entity that Distributes the Program. + +“Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +“Program” means the Contributions Distributed in accordance with this Agreement. + +“Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors. + +“Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. + +“Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof. + +“Distribute” means the acts of a) distributing or b) making available in any manner that enables the transfer of a copy. + +“Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files. + +“Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor. + +2. Grant of Rights +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +e) Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3). + +3. Requirements +3.1 If a Contributor Distributes the Program in any form, then: + +a) the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and + +b) the Contributor may Distribute the Program under a license different than this Agreement, provided that such license: + +i) effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; +ii) effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; +iii) does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and +iv) requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3. +3.2 When the Program is Distributed as Source Code: + +a) it must be made available under this Agreement, or if the Program (i) is combined with other material in a separate file or files made available under a Secondary License, and (ii) the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and +b) a copy of this Agreement must be included with each copy of the Program. +3.3 Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (“notices”) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices. + +4. Commercial Distribution +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. No Warranty +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. Disclaimer of Liability +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. General +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice +“This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}.” + +Simply including a copy of this Agreement, including this Exhibit A is not sufficient to license the Source Code under Secondary Licenses. + +If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. diff --git a/enterprise/web.jspparser/extsrc/org/netbeans/modules/web/jspparser_ext/WebAppParseSupport.java b/enterprise/web.jspparser/extsrc/org/netbeans/modules/web/jspparser_ext/WebAppParseSupport.java index b1aea9fb50c3..d4fd828f4b01 100644 --- a/enterprise/web.jspparser/extsrc/org/netbeans/modules/web/jspparser_ext/WebAppParseSupport.java +++ b/enterprise/web.jspparser/extsrc/org/netbeans/modules/web/jspparser_ext/WebAppParseSupport.java @@ -46,6 +46,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.logging.*; import java.util.zip.ZipException; import javax.servlet.ServletContext; @@ -81,6 +82,7 @@ import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; +import org.openide.util.Utilities; import org.openide.util.WeakListeners; /** @@ -122,22 +124,18 @@ public class WebAppParseSupport implements WebAppParseProxy, PropertyChangeListe final FileObject webInf; private final FileSystemListener fileSystemListener; - OptionsImpl editorOptions; - OptionsImpl diskOptions; - ServletContext editorContext; - ServletContext diskContext; + private OptionsImpl editorOptions; + private OptionsImpl diskOptions; + private ServletContext editorContext; + private ServletContext diskContext; private JspRuntimeContext rctxt; - private ParserClassLoader waClassLoader; - private ParserClassLoader waContextClassLoader; - - // This is intended for tests exclusively!!! - private static boolean noReset = false; + private URL[][] classLoaderSources = null; // @GuardedBy(this) /** * The library mappings are cashed here. */ - final Map mappings = new HashMap(); + final Map mappings = new HashMap<>(); /** * Flag whether class path is current. @@ -160,6 +158,7 @@ public class WebAppParseSupport implements WebAppParseProxy, PropertyChangeListe private final RequestProcessor.Task tldChangeTask; // #152482 - this escaped from constructor + @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public static WebAppParseProxy create(JspParserImpl jspParser, WebModule wm) { WebAppParseSupport instance = new WebAppParseSupport(jspParser, wm); @@ -188,7 +187,7 @@ public static WebAppParseProxy create(JspParserImpl jspParser, WebModule wm) { private WebAppParseSupport(JspParserImpl jspParser, WebModule wm) { this.jspParser = jspParser; - this.wm = new WeakReference(wm); + this.wm = new WeakReference<>(wm); wmRoot = wm.getDocumentBase(); webInf = wm.getWebInf(); if (LOG.isLoggable(Level.FINE)) { @@ -210,6 +209,7 @@ private WebAppParseSupport(JspParserImpl jspParser, WebModule wm) { initOptions(true); } + @Override public JspParserAPI.JspOpenInfo getJspOpenInfo(FileObject jspFile, boolean useEditor /*, URLClassLoader waClassLoader*/) { // PENDING - do caching for individual JSPs @@ -219,10 +219,8 @@ public JspParserAPI.JspOpenInfo getJspOpenInfo(FileObject jspFile, boolean useEd ExtractPageData epd = new ExtractPageData(ctxt); try { return new JspParserAPI.JspOpenInfo(epd.isXMLSyntax(), epd.getEncoding()); - } catch (Exception e) { + } catch (IOException | JasperException | RuntimeException e) { LOG.fine(e.getMessage()); - } finally { - resetClassLoaders(); } return DEFAULT_JSP_OPEN_INFO; } @@ -263,17 +261,9 @@ private synchronized void initOptions(boolean firstTime) { } } - // #134455 (see #67017 and #128360 as well) - // commenting for NB 6.5M1, let's see whether some issues caused by this change will happen or whether this code can be removed - private boolean isUnexpectedLibrary(URL url) { - return false; -// Matcher m = RE_PATTERN_COMMONS_LOGGING.matcher(url.getFile()); -// return m.matches(); - } - private void createClassLoaders() { - Map tomcatTable = new HashMap(); - Map loadingTable = new HashMap(); + Map tomcatTable = new HashMap<>(); + Map loadingTable = new HashMap<>(); URL helpurl; FileObject actualWebInf = getWebInf(); @@ -286,7 +276,7 @@ private void createClassLoaders() { if (cp != null) { for (FileObject root : cp.getRoots()) { helpurl = findInternalURL(root); - if (loadingTable.get(helpurl) == null && !isUnexpectedLibrary(helpurl)) { + if (loadingTable.get(helpurl) == null) { loadingTable.put(helpurl, helpurl); tomcatTable.put(helpurl, findExternalURL(root)); } @@ -297,7 +287,7 @@ private void createClassLoaders() { if (cp != null) { for (FileObject root : cp.getRoots()) { helpurl = findInternalURL(root); - if (loadingTable.get(helpurl) == null && !isUnexpectedLibrary(helpurl)) { + if (loadingTable.get(helpurl) == null) { loadingTable.put(helpurl, helpurl); tomcatTable.put(helpurl, findExternalURL(root)); } @@ -315,33 +305,15 @@ private void createClassLoaders() { } } - URL[] loadingURLs = loadingTable.values().toArray(new URL[0]); - URL[] tomcatURLs = tomcatTable.values().toArray(new URL[0]); + @SuppressWarnings("CollectionsToArray") + URL[][] urls = { + loadingTable.values().toArray(new URL[0]), + tomcatTable.values().toArray(new URL[0]) + }; - waClassLoader = new ParserClassLoader(loadingURLs, tomcatURLs, getClass().getClassLoader()); - waContextClassLoader = new ParserClassLoader(loadingURLs, tomcatURLs, getClass().getClassLoader()); + this.classLoaderSources = urls; } - // #128360 - private void resetClassLoaders() { - if (noReset) { - return; - } - URL[] loadingURLs = waClassLoader.getLoadingURLs(); - URL[] tomcatURLs = waClassLoader.getTomcatURLs(); - URL[] loadingContextURLs = waContextClassLoader.getLoadingURLs(); - URL[] tomcatContextURLs = waContextClassLoader.getTomcatURLs(); - - try { - waClassLoader.close(); - waContextClassLoader.close(); - } catch (Exception e) { - LOG.log(Level.WARNING, null, e); - } - waClassLoader = new ParserClassLoader(loadingURLs, tomcatURLs, waClassLoader.getParent()); - waContextClassLoader = new ParserClassLoader(loadingContextURLs, tomcatContextURLs, waContextClassLoader.getParent()); - } - // #127379 - XXX review after listening on a web module is possible private FileObject getWebInf() { if (wmRoot == null) { @@ -372,10 +344,8 @@ private void putWebInfLibraries(FileObject webInf, Map tomcatTable, Ma FileObject elem = libDirKids.nextElement(); if (elem.getExt().equals("jar")) { // NOI18N helpurl = findInternalURL(elem); - if (!isUnexpectedLibrary(helpurl)) { - tomcatTable.put(helpurl, helpurl); - loadingTable.put(helpurl, helpurl); - } + tomcatTable.put(helpurl, helpurl); + loadingTable.put(helpurl, helpurl); } } } @@ -390,7 +360,7 @@ private URL findExternalURL(FileObject fo) { File f = FileUtil.toFile(fo); if ((f != null)/* && (f.isDirectory())*/) { try { - return f.toURI().toURL(); + return Utilities.toURI(f).toURL(); } catch (MalformedURLException e) { LOG.log(Level.INFO, null, e); } @@ -416,21 +386,16 @@ private synchronized JspCompilationContext createCompilationContext(FileObject j } else { clctxt = new JspCompilationContext(jspUri, false, options, context, null, rctxt); } + clctxt.setClassLoader(getWAClassLoader()); } catch (JasperException ex) { LOG.log(Level.INFO, null, ex); } - clctxt.setClassLoader(getWAClassLoader()); return clctxt; } boolean determineIsTagFile(FileObject fo) { - if (fo.getExt().startsWith("tag")) { // NOI18N - all tag, tagx and even tagf are considered tag files - return true; - } - if (JspParserAPI.TAG_MIME_TYPE.equals(fo.getMIMEType())) { - return true; - } - return false; + return fo.getExt().startsWith("tag") // NOI18N - all tag, tagx and even tagf are considered tag files + || JspParserAPI.TAG_MIME_TYPE.equals(fo.getMIMEType()); } private String getJSPUri(FileObject jsp) { @@ -443,16 +408,17 @@ private String getJSPUri(FileObject jsp) { } // from JspCompileUtil + @Override public JspParserAPI.ParseResult analyzePage(FileObject jspFile, /*String compilationURI, */ int errorReportingMode) { // PENDING - do caching for individual JSPs checkReinitCachesTask(); JspCompilationContext ctxt = createCompilationContext(jspFile, true); - try { - return callTomcatParser(jspFile, ctxt, waContextClassLoader, errorReportingMode); - } finally { - resetClassLoaders(); + try (URLClassLoader cl = new ParserClassLoader(this.classLoaderSources[0], this.classLoaderSources[1], getClass().getClassLoader())) { + return callTomcatParser(jspFile, ctxt, cl, errorReportingMode); + } catch (IOException ex) { + throw new RuntimeException(ex); } } @@ -462,27 +428,35 @@ public JspParserAPI.ParseResult analyzePage(FileObject jspFile, /*String compila * returned as a String array: * [0] The location * [1] If the location is a jar file, this is the location of the tld. + * + * @param useEditor + * @return + * @throws java.io.IOException */ + @Override public synchronized Map getTaglibMap(boolean useEditor) throws IOException { // useEditor not needed, both caches are the same // we have to clear all the caches when the class path is not current or the taglibmap is not initialized yet checkReinitCachesTask(); // XXX return deep copy (not needed now, only jsp editor uses it) - return new HashMap(mappings); + return new HashMap<>(mappings); } /** * Returns the classloader to be used by the JSP parser. * This classloader loads the classes belonging to the application * from both expanded directory structures and jar files. + * @return */ + @Override public synchronized URLClassLoader getWAClassLoader() { if (cpCurrent.get() != 0L) { reinitOptions(); } // XXX #128360 - classloader is leaking out - no chance to close it - return waClassLoader; + // Callers must close the classloader as soon as possible! + return new ParserClassLoader(this.classLoaderSources[0], this.classLoaderSources[1], getClass().getClassLoader()); } @Override @@ -499,14 +473,10 @@ public boolean isValid(WebModule wm) { return valid; } - public class RRef { - JspParserAPI.ParseResult result; - } - private JspParserAPI.ParseResult callTomcatParser(final FileObject jspFile, final JspCompilationContext ctxt, final ClassLoader contextClassLoader, final int errorReportingMode) { - final RRef resultRef = new RRef(); + final AtomicReference resultRef = new AtomicReference<>(); // calling the parser in a new thread, as per the spec, we need to set the context classloader // to contain the web application classes. Jasper really relies on this @@ -517,18 +487,18 @@ private void setResult(GetParseData gpd){ Node.Nodes nbNodes = gpd.getNbNodes(); Throwable e = gpd.getParseException(); if (e == null) { - resultRef.result = new JspParserAPI.ParseResult(nbPageInfo, nbNodes); + resultRef.set(new JspParserAPI.ParseResult(nbPageInfo, nbNodes)); } else { // the exceptions we may see here: // JasperException - usual // ArrayIndexOutOfBoundsException - see issue 20919 // Throwable - see issue 21169, related to Tomcat bug 7124 // XXX has to be returned back to track all errors - Exceptions.attachLocalizedMessage(e, NbBundle.getMessage(WebAppParseSupport.class, "MSG_errorDuringJspParsing")); // NOI18N + e = Exceptions.attachLocalizedMessage(e, NbBundle.getMessage(WebAppParseSupport.class, "MSG_errorDuringJspParsing")); // NOI18N LOG.fine(e.getMessage()); LOG.log(Level.FINE, null, e); JspParserAPI.ErrorDescriptor error = constructErrorDescriptor(e, wmRoot, jspFile); - resultRef.result = new JspParserAPI.ParseResult(nbPageInfo, nbNodes, new JspParserAPI.ErrorDescriptor[] {error}); + resultRef.set(new JspParserAPI.ParseResult(nbPageInfo, nbNodes, new JspParserAPI.ErrorDescriptor[] {error})); } } @@ -539,10 +509,6 @@ public void run() { gpd = new GetParseData(ctxt, errorReportingMode); gpd.parse(); setResult(gpd); - - } catch (ThreadDeath td) { - LOG.log(Level.INFO, null, td); - throw td; } catch (Throwable t) { if (gpd != null) { if (gpd.getParseException() == null) { @@ -561,7 +527,7 @@ public void run() { compThread.start(); try { compThread.join(); - return resultRef.result; + return resultRef.get(); } catch (InterruptedException e) { JspParserAPI.ErrorDescriptor error = constructErrorDescriptor(e, wmRoot, jspFile); return new JspParserAPI.ParseResult(new JspParserAPI.ErrorDescriptor[] {error}); @@ -589,6 +555,7 @@ private static JspParserAPI.ErrorDescriptor constructErrorDescriptor(Throwable e /** Returns an ErrorDescriptor for a compilation error if the throwable was thrown by Jakarta, * otherwise returns null. */ + @SuppressWarnings("AssignmentToMethodParameter") private static JspParserAPI.ErrorDescriptor constructJakartaErrorDescriptor(FileObject wmRoot, FileObject jspPage, Throwable ex) throws IOException { @@ -598,7 +565,7 @@ private static JspParserAPI.ErrorDescriptor constructJakartaErrorDescriptor(File last = ex; ex = ((JasperException) ex).getRootCause(); if (ex != null) { - ErrorManager.getDefault().annotate(last, ex); + last = ErrorManager.getDefault().annotate(last, ex); } } @@ -668,7 +635,9 @@ private static JspParserAPI.ErrorDescriptor constructJakartaErrorDescriptor(File /** * Handles the event of property change of class path (source, run). + * @param evt */ + @Override public void propertyChange(PropertyChangeEvent evt) { // classpath has channged => invalidate cache LOG.fine("Class path has changed"); @@ -676,6 +645,7 @@ public void propertyChange(PropertyChangeEvent evt) { reinitCachesTask.schedule(REINIT_OPTIONS_DELAY); } + @SuppressWarnings("unchecked") private void clearTagLibraryInfoCache() { assert Thread.holdsLock(this); // clear the cache of tagLibrary map @@ -690,6 +660,7 @@ private void clearTagLibraryInfoCache() { } } + @SuppressWarnings("unchecked") void reinitTagLibMappings() { assert Thread.holdsLock(this); try { @@ -710,6 +681,7 @@ void reinitTagLibMappings() { mappingsField.setAccessible(true); // Before new parsing, the old mappings in the TldLocationCache has to be cleared. Else there are // stored the old mappings. + @SuppressWarnings("unchecked") Map tmpMappings = (Map) mappingsField.get(lc); // the mapping doesn't have to be initialized yet if (tmpMappings != null) { @@ -717,22 +689,24 @@ void reinitTagLibMappings() { } Thread compThread = new WebAppParseSupport.InitTldLocationCacheThread(lc); - compThread.setContextClassLoader(waContextClassLoader); - long start = 0; - if (LOG.isLoggable(Level.FINE)) { - start = System.currentTimeMillis(); - LOG.fine("InitTldLocationCacheThread start"); //NOI18N - } - compThread.start(); - - try { - compThread.join(); + try (URLClassLoader cl = new ParserClassLoader(this.classLoaderSources[0], this.classLoaderSources[1], getClass().getClassLoader())) { + compThread.setContextClassLoader(cl); + long start = 0; if (LOG.isLoggable(Level.FINE)) { - long end = System.currentTimeMillis(); - LOG.log(Level.FINE, "InitTldLocationCacheThread finished in {0} ms", (end - start)); //NOI18N + start = System.currentTimeMillis(); + LOG.fine("InitTldLocationCacheThread start"); //NOI18N + } + compThread.start(); + + try { + compThread.join(); + if (LOG.isLoggable(Level.FINE)) { + long end = System.currentTimeMillis(); + LOG.log(Level.FINE, "InitTldLocationCacheThread finished in {0} ms", (end - start)); //NOI18N + } + } catch (InterruptedException e) { + LOG.log(Level.INFO, null, e); } - } catch (InterruptedException e) { - LOG.log(Level.INFO, null, e); } // obtain the current mappings after parsing @@ -754,9 +728,7 @@ void reinitTagLibMappings() { } // cache tld files under WEB-INF directory as well mappings.putAll(getImplicitLocation()); - } catch (NoSuchFieldException e) { - LOG.log(Level.INFO, null, e); - } catch (IllegalAccessException e) { + } catch (NoSuchFieldException | IllegalAccessException | IOException e) { LOG.log(Level.INFO, null, e); } } @@ -766,7 +738,7 @@ void reinitTagLibMappings() { */ private Map getImplicitLocation() { assert Thread.holdsLock(this); - Map returnMap = new HashMap(); + Map returnMap = new HashMap<>(); // Obtain all tld files under WEB-INF folder FileObject fo; if (webInf != null && webInf.isFolder() && webInf.isValid()) { @@ -810,7 +782,8 @@ void reinitCaches() { tldChangeTask.run(); } - final class ReinitCaches implements Runnable { + private final class ReinitCaches implements Runnable { + @Override public void run() { synchronized (WebAppParseSupport.this) { LOG.fine("ReinitCaches task started"); // NOI18N @@ -820,7 +793,8 @@ public void run() { } } - final class TldChange implements Runnable { + private final class TldChange implements Runnable { + @Override public void run() { WebModule webModule = wm.get(); if (webModule == null) { @@ -872,12 +846,21 @@ public static class ParserClassLoader extends URLClassLoader { private final ClassLoader parent; - /** This constructor and the getURLs() method is one horrible hack. On the one hand, we want to give - * Tomcat a JarURLConnection when it attempts to load classes from jars, on the other hand - * we don't want this classloader to load classes using JarURLConnection, as that's buggy. - * We want it to load classes using internal nb: protocols. So the getURLs() method - * returns an "external" list of URLs for Tomcat, while internally, the classloader uses - * an "internal" list of URLs. + /** + * This constructor and the getURLs() method is one horrible hack. On + * the one hand, we want to give Tomcat a JarURLConnection when it + * attempts to load classes from jars, + * + * On the other hand we don't want this classloader to load classes using + * JarURLConnection, as that's buggy. + * + * We want it to load classes using internal nb: protocols. So the + * getURLs() method returns an "external" list of URLs for Tomcat, while + * internally, the classloader uses an "internal" list of URLs. + * + * @param classLoadingURLs + * @param tomcatURLs + * @param parent */ public ParserClassLoader(URL[] classLoadingURLs, URL[] tomcatURLs, ClassLoader parent) { super(classLoadingURLs, parent); @@ -885,9 +868,13 @@ public ParserClassLoader(URL[] classLoadingURLs, URL[] tomcatURLs, ClassLoader p this.tomcatURLs = tomcatURLs; } - /** See the constructor for explanation of what thie method does. + /** + * See the constructor for explanation of what thie method does. + * + * @return */ @Override + @SuppressWarnings("ReturnOfCollectionOrArrayField") public URL[] getURLs() { return tomcatURLs; } @@ -896,6 +883,7 @@ public URL[] getLoadingURLs() { return super.getURLs(); } + @SuppressWarnings("ReturnOfCollectionOrArrayField") public URL[] getTomcatURLs() { return tomcatURLs; } @@ -991,27 +979,15 @@ private static class InitTldLocationCacheThread extends Thread { @Override public void run() { try { - // #188702 -// Field mappings = TldScanner.class.getDeclaredField("mappings"); // NOI18N -// mappings.setAccessible(true); -// mappings.set(cache, null); -// cache.getLocation(""); // NOI18N - // see #205387 - adjust TldScanner logger updateTldScannerLogger(); Method mappingsMethod = TldScanner.class.getDeclaredMethod("scanTlds"); //NOI18N mappingsMethod.setAccessible(true); mappingsMethod.invoke(cache); - } catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException | NoSuchMethodException | SecurityException | IllegalAccessException ex) { LOG.log(Level.WARNING, null, ex); } catch (InvocationTargetException ex) { LOG.log(Level.INFO, null, ex); - } catch (NoSuchMethodException ex) { - LOG.log(Level.WARNING, null, ex); - } catch (SecurityException ex) { - LOG.log(Level.WARNING, null, ex); - } catch (IllegalAccessException e) { - LOG.log(Level.WARNING, null, e); } } @@ -1044,7 +1020,7 @@ public boolean isLoggable(LogRecord record) { } - final class FileSystemListener extends FileChangeAdapter { + private final class FileSystemListener extends FileChangeAdapter { @Override public void fileChanged(FileEvent fe) { @@ -1088,6 +1064,7 @@ private void processFileChange(final FileEvent fe) { } } + @Override public WebModule getWebModule() { return wm.get(); } diff --git a/enterprise/web.jspparser/test/unit/data/emptyWebProject/lib/tags/META-INF/taglib.tld b/enterprise/web.jspparser/test/unit/data/emptyWebProject/lib/tags/META-INF/taglib.tld new file mode 100644 index 000000000000..7e3a8b5d363d --- /dev/null +++ b/enterprise/web.jspparser/test/unit/data/emptyWebProject/lib/tags/META-INF/taglib.tld @@ -0,0 +1,31 @@ + + + + Test tag library. + 1.0 + ttl + /TestTagLibrary + + diff --git a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/FastScanTest.java b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/FastScanTest.java index 368abecd9541..2b63d5a60289 100644 --- a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/FastScanTest.java +++ b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/FastScanTest.java @@ -48,14 +48,6 @@ public void testPage1() throws Exception { doFastScanTest("jspparser-data/wmroot", "subdir/Page1.jsp", new JspParserAPI.JspOpenInfo(false, "ISO-8859-1")); } - public void testXMLFromExamples1() throws Exception { - doFastScanTest("project3/web", "xml/xml.jsp", new JspParserAPI.JspOpenInfo(true, "UTF-8")); - } - - public void testXMLFromExamples2() throws Exception { - doFastScanTest("project3/web", "jsp2/jspx/basic.jspx", new JspParserAPI.JspOpenInfo(true, "UTF-8")); - } - public void testEncodingBug198637() throws Exception { doFastScanTest("project2/web", "encoding198637.jsp", new JspParserAPI.JspOpenInfo(false, "utf-8")); } diff --git a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParseTest.java b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParseTest.java index e886b00f7f61..8037a0132f7f 100644 --- a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParseTest.java +++ b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParseTest.java @@ -75,16 +75,6 @@ public void testAnalysisOutsideWM() throws Exception { parserTestInProject("project2", "/outside/outsidewm.jsp"); } - /* Commented out - see bug 194639. - public void testAnalysisFunction() throws Exception { - parserTestInProject("project3", "/web/jsp2/el/functions.jsp"); - } - */ - - public void testAnalysisXMLTextRotate_1_5() throws Exception { - parserTestInProject("project3", "/web/jsp2/jspx/textRotate.jspx"); - } - // TODO: temporarily disabled because of JDK 5 and 6 differences public void disableTestAnalysisTagLibFromTagFiles_1_6() throws Exception { parserTestInProject("project2", "/web/testTagLibs.jsp"); @@ -105,11 +95,6 @@ public void testIncludePreludeCoda() throws Exception { log("Coda: " + result.getPageInfo().getIncludeCoda()); } - public void testTagFileAttribute() throws Exception { - parserTestInProject("project3", "/web/WEB-INF/tags/displayProducts.tag"); - parserTestInProject("project3", "/web/WEB-INF/tags/displayProducts.tag"); - } - public JspParserAPI.ParseResult parserTestInProject(String projectFolderName, String pagePath) throws Exception { FileObject jspFo = TestUtil.getProjectFile(this, projectFolderName, pagePath); WebModule webModule = TestUtil.getWebModule(jspFo); diff --git a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParserClassLoaderTest.java b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParserClassLoaderTest.java deleted file mode 100644 index acb7e08462df..000000000000 --- a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/ParserClassLoaderTest.java +++ /dev/null @@ -1,148 +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.web.jspparser; - -import java.lang.reflect.Field; -import org.netbeans.junit.NbTestCase; -import org.netbeans.modules.web.api.webmodule.WebModule; -import org.netbeans.modules.web.jsps.parserapi.JspParserAPI; -import org.netbeans.modules.web.jsps.parserapi.JspParserFactory; -import org.openide.filesystems.FileObject; - -/** - * - * @author Petr Hejl - */ -public class ParserClassLoaderTest extends NbTestCase { - - private static final String ISSUE_WA_VENDOR = "Sun Microsystems"; - private static final String ISSUE_WA_VENDOR_ALT = "Oracle Corporation"; - private static final int ISSUE_WA_MAJOR_VERSION = 1; - private static final int ISSUE_WA_MINOR_VERSION = 6; - - public ParserClassLoaderTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - TestUtil.setup(this); - } - - public void testReusable() throws Exception { - String vendor = System.getProperty("java.vendor"); - if (!vendor.contains(ISSUE_WA_VENDOR) && !vendor.contains(ISSUE_WA_VENDOR_ALT)) { - return; - } - String version = System.getProperty("java.version"); - System.out.println(version); - - String[] parts = version.split("\\."); - if (parts.length < 2 || Integer.parseInt(parts[0]) < ISSUE_WA_MAJOR_VERSION - || (Integer.parseInt(parts[0]) == ISSUE_WA_MAJOR_VERSION && Integer.parseInt(parts[1]) < ISSUE_WA_MINOR_VERSION)) { - return; - } - - FileObject jspFo = TestUtil.getProjectFile(this, "project3", "/web/source.jsp"); - WebModule webModule = TestUtil.getWebModule(jspFo); - JspParserAPI jspParser = JspParserFactory.getJspParser(); - JspParserAPI.ParseResult result = jspParser.analyzePage(jspFo, webModule, JspParserAPI.ERROR_IGNORE); - - if (!(jspParser instanceof JspParserImpl)) { - return; - } - - JspParserImpl jspParserImpl = (JspParserImpl) jspParser; - WebAppParseProxy proxy = jspParserImpl.parseSupports.get(webModule); - - if (!"org.netbeans.modules.web.jspparser_ext.WebAppParseSupport".equals(proxy.getClass().getName())) { - return; - } - - Field waClassLoaderField = proxy.getClass().getDeclaredField("waClassLoader"); - waClassLoaderField.setAccessible(true); - ClassLoader waClassLoader = (ClassLoader) waClassLoaderField.get(proxy); - Field waContextClassLoaderField = proxy.getClass().getDeclaredField("waContextClassLoader"); - waContextClassLoaderField.setAccessible(true); - ClassLoader waContextClassLoader = (ClassLoader) waContextClassLoaderField.get(proxy); - - waClassLoader.loadClass("examples.LogTag"); - waClassLoader.loadClass("javax.servlet.jsp.jstl.sql.Result"); - waContextClassLoader.loadClass("examples.LogTag"); - waContextClassLoader.loadClass("javax.servlet.jsp.jstl.sql.Result"); - } - - public void testPerformanceDifference() throws Exception { - String vendor = System.getProperty("java.vendor"); - if (!vendor.contains(ISSUE_WA_VENDOR) && !vendor.contains(ISSUE_WA_VENDOR_ALT)) { - return; - } - String version = System.getProperty("java.version"); - System.out.println(version); - - String[] parts = version.split("\\."); - if (parts.length < 2 || Integer.parseInt(parts[0]) < ISSUE_WA_MAJOR_VERSION - || (Integer.parseInt(parts[0]) == ISSUE_WA_MAJOR_VERSION && Integer.parseInt(parts[1]) < ISSUE_WA_MINOR_VERSION)) { - return; - } - - FileObject jspFo = TestUtil.getProjectFile(this, "project3", "/web/source.jsp"); - WebModule webModule = TestUtil.getWebModule(jspFo); - JspParserAPI jspParser = JspParserFactory.getJspParser(); - - long startWithReset = System.nanoTime(); - for (int i = 0; i < 500; i++) { - JspParserAPI.ParseResult result = jspParser.analyzePage(jspFo, webModule, JspParserAPI.ERROR_IGNORE); - } - long elapsedWithReset = System.nanoTime() - startWithReset; - - disableReset(jspParser, webModule); - - long startWithoutReset = System.nanoTime(); - for (int i = 0; i < 500; i++) { - JspParserAPI.ParseResult result = jspParser.analyzePage(jspFo, webModule, JspParserAPI.ERROR_IGNORE); - } - long elapsedWithoutReset = System.nanoTime() - startWithoutReset; - - System.out.println("Absolute difference " + ((elapsedWithReset - elapsedWithoutReset) / 1000000) + " ms"); - double perCent = ((double) elapsedWithReset/elapsedWithoutReset) * 100; - System.out.println("Per cent difference " + perCent); - - assertTrue(perCent < 200); - } - - private void disableReset(JspParserAPI jspParser, WebModule webModule) throws NoSuchFieldException, IllegalAccessException { - if (!(jspParser instanceof JspParserImpl)) { - return; - } - - JspParserImpl jspParserImpl = (JspParserImpl) jspParser; - WebAppParseProxy proxy = jspParserImpl.parseSupports.get(webModule); - - if (!"org.netbeans.modules.web.jspparser_ext.WebAppParseSupport".equals(proxy.getClass().getName())) { - return; - } - - Field noResetField = proxy.getClass().getDeclaredField("noReset"); - noResetField.setAccessible(true); - noResetField.set(proxy, Boolean.TRUE); - } -} diff --git a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/TestUtil.java b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/TestUtil.java index 0eb569d49d8e..109328c4b485 100644 --- a/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/TestUtil.java +++ b/enterprise/web.jspparser/test/unit/src/org/netbeans/modules/web/jspparser/TestUtil.java @@ -104,8 +104,6 @@ public static void setLookup(Object... instances) { static void setup(NbTestCase test) throws Exception { test.clearWorkDir(); Logger.getLogger("org.netbeans.modules.web.jspparser_ext").setLevel(Level.FINE); - // unzip test project - TestUtil.getProject(test, "project3"); TestUtil.initParserJARs(); } diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps index ae6e7b9e92d6..1029080e804b 100644 --- a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps +++ b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps @@ -122,3 +122,7 @@ ide/libs.graalsdk/external/nativeimage-24.0.0.jar ide/libs.graalsdk.system/exter ide/libs.graalsdk/external/polyglot-24.0.0.jar ide/libs.graalsdk.system/external/polyglot-24.0.0.jar ide/libs.graalsdk/external/word-24.0.0.jar ide/libs.graalsdk.system/external/word-24.0.0.jar +# Intentionally duplicated (in web.jspparser only as unittest dependency and copied to make license handling easier) +enterprise/web.jspparser/external/jakarta.servlet.jsp.jstl-api-1.2.7.jar enterprise/libs.jstl/external/jakarta.servlet.jsp.jstl-api-1.2.7.jar +enterprise/web.jspparser/external/jakarta.servlet.jsp.jstl-1.2.6.jar enterprise/libs.jstl/external/jakarta.servlet.jsp.jstl-1.2.6.jar +enterprise/web.jspparser/external/commons-logging-1.3.1.jar platform/o.apache.commons.logging/external/commons-logging-1.3.1.jar \ No newline at end of file