├── .gitignore ├── istack-commons ├── tools │ ├── src │ │ ├── test │ │ │ ├── resources │ │ │ │ ├── com │ │ │ │ │ └── sun │ │ │ │ │ │ └── istack │ │ │ │ │ │ └── tools │ │ │ │ │ │ ├── .auth │ │ │ │ │ │ └── auth_test.resource │ │ │ │ └── META-INF │ │ │ │ │ └── services │ │ │ │ │ └── javax.xml.stream.XMLInputFactory │ │ │ └── java │ │ │ │ ├── javax │ │ │ │ └── xml │ │ │ │ │ └── ws │ │ │ │ │ ├── Service.java │ │ │ │ │ └── XMLFactory.java │ │ │ │ └── com │ │ │ │ └── sun │ │ │ │ └── istack │ │ │ │ └── tools │ │ │ │ ├── ParallelWorldClassLoaderTest.java │ │ │ │ └── DefaultAuthenticatorTest.java │ │ └── main │ │ │ └── java │ │ │ ├── com │ │ │ └── sun │ │ │ │ └── istack │ │ │ │ └── tools │ │ │ │ ├── package-info.java │ │ │ │ ├── Utils.java │ │ │ │ ├── MaskingClassLoader.java │ │ │ │ ├── ProtectedTask.java │ │ │ │ ├── ParallelWorldClassLoader.java │ │ │ │ └── DefaultAuthenticator.java │ │ │ └── module-info.java │ └── pom.xml ├── maven-plugin │ ├── src │ │ ├── test │ │ │ ├── it │ │ │ │ └── sample │ │ │ │ │ ├── src │ │ │ │ │ └── main │ │ │ │ │ │ ├── resources │ │ │ │ │ │ └── org │ │ │ │ │ │ │ └── aaa │ │ │ │ │ │ │ ├── aprop.properties │ │ │ │ │ │ │ └── aprop_de.properties │ │ │ │ │ │ └── java │ │ │ │ │ │ └── com │ │ │ │ │ │ └── sun │ │ │ │ │ │ └── xml │ │ │ │ │ │ └── ws │ │ │ │ │ │ └── App.java │ │ │ │ │ └── pom.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── sun │ │ │ │ │ └── istack │ │ │ │ │ └── maven │ │ │ │ │ ├── QuickGenMojoITCase.java │ │ │ │ │ └── ResourceGenMojoITCase.java │ │ │ ├── script │ │ │ │ └── setproxy.groovy │ │ │ └── resources │ │ │ │ └── it-settings.xml │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── sun │ │ │ └── istack │ │ │ └── maven │ │ │ ├── ArtifactItem.java │ │ │ ├── LicenseCodeWriter.java │ │ │ ├── RSFileSet.java │ │ │ └── MetainfServicesCompilerMojo.java │ └── pom.xml ├── src │ └── main │ │ ├── resources │ │ ├── copyright-exclude │ │ └── spotbugs-exclude.xml │ │ └── assembly │ │ └── resources.xml ├── runtime │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ ├── com │ │ │ │ └── sun │ │ │ │ │ └── istack │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── Builder.java │ │ │ │ │ ├── Nullable.java │ │ │ │ │ ├── NotNull.java │ │ │ │ │ ├── FinalArrayList.java │ │ │ │ │ ├── SAXException2.java │ │ │ │ │ ├── FragmentContentHandler.java │ │ │ │ │ ├── localization │ │ │ │ │ ├── NullLocalizable.java │ │ │ │ │ ├── Localizable.java │ │ │ │ │ ├── LocalizableMessageFactory.java │ │ │ │ │ ├── LocalizableMessage.java │ │ │ │ │ └── Localizer.java │ │ │ │ │ ├── logging │ │ │ │ │ └── StackHelper.java │ │ │ │ │ ├── Interned.java │ │ │ │ │ ├── XMLStreamException2.java │ │ │ │ │ ├── SAXParseException2.java │ │ │ │ │ ├── ByteArrayDataSource.java │ │ │ │ │ └── Pool.java │ │ │ │ └── module-info.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── sun │ │ │ └── istack │ │ │ └── logging │ │ │ └── LoggerTest.java │ └── pom.xml ├── test │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── com │ │ │ └── sun │ │ │ │ └── istack │ │ │ │ └── test │ │ │ │ ├── package-info.java │ │ │ │ ├── Which.java │ │ │ │ ├── ForkOutputStream.java │ │ │ │ ├── VersionProcessor.java │ │ │ │ ├── VersionNumber.java │ │ │ │ └── AntXmlFormatter.java │ │ │ └── module-info.java │ └── pom.xml ├── import-properties-plugin │ ├── exclude.xml │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── oracle │ │ │ │ └── istack │ │ │ │ └── maven │ │ │ │ ├── CommonLogger.java │ │ │ │ ├── DependencyResolver.java │ │ │ │ ├── ImportPropertiesMojo.java │ │ │ │ └── PropertyResolver.java │ │ └── test │ │ │ ├── it │ │ │ └── sample │ │ │ │ ├── bom │ │ │ │ └── pom.xml │ │ │ │ └── pom.xml │ │ │ ├── script │ │ │ └── setproxy.groovy │ │ │ └── resources │ │ │ └── it-settings.xml │ └── pom.xml ├── soimp │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── sun │ │ │ └── istack │ │ │ └── soimp │ │ │ ├── Listener.java │ │ │ ├── Mode.java │ │ │ ├── ProcessingException.java │ │ │ └── Proc.java │ └── pom.xml └── buildtools │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── sun │ └── istack │ └── build │ └── NameConverter.java ├── .github └── workflows │ └── maven.yml ├── LICENSE.md ├── README.md ├── CONTRIBUTING.md └── NOTICE.md /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea 3 | *.iml 4 | .classpath 5 | .project 6 | .settings/ -------------------------------------------------------------------------------- /istack-commons/tools/src/test/resources/com/sun/istack/tools/.auth: -------------------------------------------------------------------------------- 1 | http://duke:test@foo.com/myservice?wsdl -------------------------------------------------------------------------------- /istack-commons/tools/src/test/resources/META-INF/services/javax.xml.stream.XMLInputFactory: -------------------------------------------------------------------------------- 1 | javax.xml.ws.XMLFactory -------------------------------------------------------------------------------- /istack-commons/tools/src/test/resources/com/sun/istack/tools/auth_test.resource: -------------------------------------------------------------------------------- 1 | #plain password: 2 | http://user:)/_@B8M)gDw@server1.myserver.com/MyService/Service.svc* 3 | 4 | #encoded password: 5 | http://user2:%29%2F_%40B8M%29gDw@server1.myserver.com/encoded/MyService/Service.svc?WSDL 6 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/it/sample/src/main/resources/org/aaa/aprop.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Distribution License v. 1.0, which is available at 6 | # http://www.eclipse.org/org/documents/edl-v10.php. 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | # 10 | 11 | aaa=fdsa 12 | bb.d=rewq 13 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/it/sample/src/main/resources/org/aaa/aprop_de.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Distribution License v. 1.0, which is available at 6 | # http://www.eclipse.org/org/documents/edl-v10.php. 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | # 10 | 11 | aaa=fdsa-de 12 | bb.d=rewq-de 13 | -------------------------------------------------------------------------------- /istack-commons/src/main/resources/copyright-exclude: -------------------------------------------------------------------------------- 1 | /MANIFEST.MF 2 | /META-INF/services/ 3 | /README 4 | .gif 5 | .jpg 6 | .jpeg 7 | .jpeg1 8 | .jpeg2 9 | .png 10 | .svg 11 | .tif 12 | .exe 13 | .ico 14 | .jar 15 | .zip 16 | .war 17 | .sql 18 | .jks 19 | .json 20 | .class 21 | .bin 22 | .iml 23 | .ipr 24 | .envelope 25 | .txt 26 | .bat 27 | .sh 28 | /copyright-exclude 29 | /LICENSE 30 | /copyright.txt 31 | .commented 32 | /.auth 33 | .svnignore 34 | .svn 35 | www 36 | site 37 | .resource 38 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * istack-commons runtime utilities. 13 | */ 14 | package com.sun.istack; 15 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/com/sun/istack/test/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2019 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Common test-related utility code for the istack components. 13 | */ 14 | package com.sun.istack.test; 15 | -------------------------------------------------------------------------------- /istack-commons/tools/src/test/java/javax/xml/ws/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package javax.xml.ws; 12 | 13 | /** 14 | * 15 | * @author lukas 16 | */ 17 | public final class Service { 18 | 19 | public void test() {} 20 | } 21 | -------------------------------------------------------------------------------- /istack-commons/tools/src/main/java/com/sun/istack/tools/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * istack-commons tool time utilities. 13 | * 14 | *

15 | * This includes code that relies on APT, javac, etc. 16 | */ 17 | package com.sun.istack.tools; 18 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/Builder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | /** 14 | * 15 | * @author Martin Grebac 16 | * @param type of the Builder 17 | */ 18 | public interface Builder { 19 | T build(); 20 | } 21 | -------------------------------------------------------------------------------- /istack-commons/tools/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * istack-commons tool time utilities. 13 | */ 14 | module com.sun.istack.tools { 15 | requires java.logging; 16 | requires transitive java.xml; 17 | 18 | exports com.sun.istack.tools; 19 | } 20 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Common test-related utility code for the istack components. 13 | */ 14 | module com.sun.istack.test { 15 | requires java.logging; 16 | requires transitive java.xml; 17 | 18 | exports com.sun.istack.test; 19 | } 20 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/exclude.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/it/sample/src/main/java/com/sun/xml/ws/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.xml.ws; 12 | 13 | /** 14 | * Hello world! 15 | * 16 | */ 17 | public class App 18 | { 19 | public static void main( String[] args ) 20 | { 21 | System.out.println( "Hello World!" ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /istack-commons/tools/src/main/java/com/sun/istack/tools/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.tools; 12 | 13 | import java.net.Authenticator; 14 | 15 | final class Utils { 16 | 17 | 18 | private Utils() {} 19 | 20 | static Authenticator getCurrentAuthenticator() { 21 | return Authenticator.getDefault(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * istack-commons runtime utilities. 13 | */ 14 | module com.sun.istack.runtime { 15 | requires transitive java.logging; 16 | requires transitive java.xml; 17 | requires static transitive jakarta.activation; 18 | 19 | exports com.sun.istack; 20 | exports com.sun.istack.localization; 21 | exports com.sun.istack.logging; 22 | } 23 | -------------------------------------------------------------------------------- /istack-commons/soimp/src/main/java/com/sun/istack/soimp/Listener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.soimp; 12 | 13 | /** 14 | * @author Kohsuke Kawaguchi 15 | */ 16 | public interface Listener { 17 | void info(String line); 18 | 19 | Listener CONSOLE = new Listener() { 20 | @Override 21 | public void info(String line) { 22 | System.out.println(line); 23 | } 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /istack-commons/soimp/src/main/java/com/sun/istack/soimp/Mode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.soimp; 12 | 13 | /** 14 | * @author Kohsuke Kawaguchi 15 | */ 16 | enum Mode { 17 | NEW, DELETED, UPDATED; 18 | 19 | static Mode parse(char ch) { 20 | switch(ch) { 21 | case 'M': 22 | return UPDATED; 23 | case '!': 24 | return DELETED; 25 | case '?': 26 | return NEW; 27 | } 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /istack-commons/soimp/src/main/java/com/sun/istack/soimp/ProcessingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.soimp; 12 | 13 | /** 14 | * @author Kohsuke Kawaguchi 15 | */ 16 | public class ProcessingException extends Exception { 17 | 18 | private static final long serialVersionUID = -6214429602282488762L; 19 | 20 | public ProcessingException(String message) { 21 | super(message); 22 | } 23 | 24 | public ProcessingException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/main/java/com/oracle/istack/maven/CommonLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.oracle.istack.maven; 12 | 13 | import org.apache.maven.plugin.logging.Log; 14 | 15 | /** 16 | * 17 | * @author Martin Grebac 18 | */ 19 | public class CommonLogger { 20 | 21 | private final Log log; 22 | 23 | public CommonLogger(Log log) { 24 | this.log = log; 25 | } 26 | 27 | public void warn(String s) { 28 | if (log != null) { 29 | log.warn(s); 30 | } 31 | } 32 | 33 | public void info(String s) { 34 | if (log != null) { 35 | log.info(s); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/Nullable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import java.lang.annotation.Documented; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | import java.lang.annotation.ElementType; 18 | 19 | /** 20 | * Designates that a field, return value, argument, or a variable may be null. 21 | * 22 | * @author Kohsuke Kawaguchi 23 | */ 24 | @Documented 25 | @Retention(RetentionPolicy.CLASS) 26 | @Target({ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.LOCAL_VARIABLE}) 27 | public @interface Nullable { 28 | } 29 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/NotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import java.lang.annotation.Documented; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | import java.lang.annotation.ElementType; 18 | 19 | /** 20 | * Designates that a field, return value, argument, or a variable is guaranteed to be non-null. 21 | * 22 | * @author Kohsuke Kawaguchi 23 | */ 24 | @Documented 25 | @Retention(RetentionPolicy.CLASS) 26 | @Target({ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.LOCAL_VARIABLE}) 27 | public @interface NotNull { 28 | } 29 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/test/it/sample/bom/pom.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 15 | 4.0.0 16 | 17 | com.sun.xml.ws 18 | imported-bom 19 | 1.0-SNAPSHOT 20 | pom 21 | 22 | sample bom 23 | 24 | 25 | IMPORTED 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/FinalArrayList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Collection; 15 | 16 | /** 17 | * {@link ArrayList} with the final keyword. 18 | * 19 | *

20 | * This gives HotSpot a better hint that all methods can be inlined. 21 | * 22 | * @author Kohsuke Kawaguchi 23 | * @param element type 24 | */ 25 | public final class FinalArrayList extends ArrayList { 26 | 27 | private static final long serialVersionUID = -540534530037816397L; 28 | 29 | public FinalArrayList(int initialCapacity) { 30 | super(initialCapacity); 31 | } 32 | 33 | public FinalArrayList() { 34 | } 35 | 36 | public FinalArrayList(Collection ts) { 37 | super(ts); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/SAXException2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import org.xml.sax.SAXException; 14 | 15 | /** 16 | * {@link SAXException} that handles exception chaining correctly. 17 | * 18 | * @author Kohsuke Kawaguchi 19 | * @since 2.0 FCS 20 | */ 21 | public class SAXException2 extends SAXException { 22 | 23 | private static final long serialVersionUID = -707119042406163844L; 24 | 25 | public SAXException2(String message) { 26 | super(message); 27 | } 28 | 29 | public SAXException2(Exception e) { 30 | super(e); 31 | } 32 | 33 | public SAXException2(String message, Exception e) { 34 | super(message, e); 35 | } 36 | 37 | @Override 38 | public Throwable getCause() { 39 | return getException(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/java/com/sun/istack/maven/QuickGenMojoITCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.maven; 12 | 13 | import org.junit.Assert; 14 | import org.junit.Test; 15 | 16 | import java.io.File; 17 | 18 | public class QuickGenMojoITCase { 19 | 20 | private static final File PROJECTS_DIR = new File(System.getProperty("it.projects.dir")); 21 | 22 | public QuickGenMojoITCase() { 23 | } 24 | 25 | @Test 26 | public void testGeneration() { 27 | File project = new File(PROJECTS_DIR, "sample"); 28 | File f = new File(project, "target/generated-sources/quick-sources/org/app/annotation/XmlEnumQuick.java"); 29 | Assert.assertTrue("Not found " + f.getAbsolutePath(), f.exists()); 30 | f = new File(project, "target/classes/org/app/annotation/Init.class"); 31 | Assert.assertFalse("Found " + f.getAbsolutePath(), f.exists()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/java/com/sun/istack/maven/ResourceGenMojoITCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.maven; 12 | 13 | import java.io.File; 14 | 15 | import org.junit.Assert; 16 | import org.junit.Test; 17 | 18 | /** 19 | * 20 | * @author Lukas Jungmann 21 | */ 22 | public class ResourceGenMojoITCase { 23 | 24 | private static final File PROJECTS_DIR = new File(System.getProperty("it.projects.dir")); 25 | 26 | public ResourceGenMojoITCase() { 27 | } 28 | 29 | @Test 30 | public void testGeneration() { 31 | File project = new File(PROJECTS_DIR, "sample"); 32 | File f = new File(project, "target/generated-sources/resources/org/aaa/ApropMessages.java"); 33 | Assert.assertTrue("Not found " + f.getAbsolutePath(), f.exists()); 34 | f = new File(project, "target/classes/org/aaa/ApropMessages.class"); 35 | Assert.assertTrue("Not found " + f.getAbsolutePath(), f.exists()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /istack-commons/soimp/pom.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 4.0.0 15 | 16 | com.sun.istack 17 | istack-commons 18 | 4.2.1-SNAPSHOT 19 | ../pom.xml 20 | 21 | istack-commons-soimp 22 | 23 | istack common utility code soimp 24 | 25 | 26 | 27 | org.apache.ant 28 | ant 29 | 30 | 31 | args4j 32 | args4j 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/FragmentContentHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import org.xml.sax.helpers.XMLFilterImpl; 14 | import org.xml.sax.SAXException; 15 | import org.xml.sax.XMLReader; 16 | import org.xml.sax.ContentHandler; 17 | 18 | /** 19 | * {@link XMLFilterImpl} that masks start/end document SAX events. 20 | * @author Kohsuke Kawaguchi 21 | */ 22 | public class FragmentContentHandler extends XMLFilterImpl { 23 | public FragmentContentHandler() { 24 | } 25 | 26 | public FragmentContentHandler(XMLReader parent) { 27 | super(parent); 28 | } 29 | 30 | @SuppressWarnings({"this-escape"}) 31 | public FragmentContentHandler(ContentHandler handler) { 32 | super(); 33 | setContentHandler(handler); 34 | } 35 | 36 | @Override 37 | public void startDocument() throws SAXException { 38 | // noop 39 | } 40 | 41 | @Override 42 | public void endDocument() throws SAXException { 43 | // noop 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/localization/NullLocalizable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.localization; 12 | 13 | import java.util.Locale; 14 | import java.util.ResourceBundle; 15 | 16 | /** 17 | * {@link Localizable} that wraps a non-localizable string. 18 | * 19 | * @author WS Development Team 20 | */ 21 | public final class NullLocalizable implements Localizable { 22 | private final String msg; 23 | 24 | public NullLocalizable(String msg) { 25 | if(msg==null) 26 | throw new IllegalArgumentException(); 27 | this.msg = msg; 28 | } 29 | 30 | @Override 31 | public String getKey() { 32 | return Localizable.NOT_LOCALIZABLE; 33 | } 34 | @Override 35 | public Object[] getArguments() { 36 | return new Object[]{msg}; 37 | } 38 | @Override 39 | public String getResourceBundleName() { 40 | return ""; 41 | } 42 | @Override 43 | public ResourceBundle getResourceBundle(Locale locale) { 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/main/java/com/sun/istack/maven/ArtifactItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.maven; 12 | 13 | /** 14 | * 15 | * @author japod 16 | */ 17 | public class ArtifactItem { 18 | 19 | private String artifactId; 20 | private String groupId; 21 | private String version; 22 | 23 | public String getVersion() { 24 | return version; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return String.format("{groupId=%s, artifactId=%s, version=%s}", groupId, artifactId, version); 30 | } 31 | 32 | public void setVersion(String version) { 33 | this.version = version; 34 | } 35 | 36 | public String getArtifactId() { 37 | return artifactId; 38 | } 39 | 40 | public void setArtifactId(String artifactId) { 41 | this.artifactId = artifactId; 42 | } 43 | 44 | public String getGroupId() { 45 | return groupId; 46 | } 47 | 48 | public void setGroupId(String groupId) { 49 | this.groupId = groupId; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /istack-commons/buildtools/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 4.0.0 16 | 17 | 18 | com.sun.istack 19 | istack-commons 20 | 4.2.1-SNAPSHOT 21 | ../pom.xml 22 | 23 | 24 | istack-commons-buildtools 25 | istack common utility buildtools 26 | 27 | 28 | 29 | org.apache.ant 30 | ant 31 | 32 | 33 | org.glassfish.jaxb 34 | codemodel 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/logging/StackHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.logging; 12 | 13 | /** 14 | * Utils for stack trace analysis 15 | * 16 | * @author Daniel Kec 17 | */ 18 | class StackHelper { 19 | 20 | /** 21 | * Function returns the name of the caller method for the method executing this 22 | * function. 23 | * 24 | * @return caller method name from the call stack of the current {@link Thread}. 25 | */ 26 | static String getCallerMethodName() { 27 | return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE) 28 | .walk(frames -> frames 29 | //Its a method of first declaring class after istack Logger class 30 | .dropWhile(f -> !Logger.class.equals(f.getDeclaringClass())) 31 | .dropWhile(f -> Logger.class.equals(f.getDeclaringClass())) 32 | .findFirst() 33 | .map(StackWalker.StackFrame::getMethodName) 34 | .orElse("UNKNOWN METHOD")); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /istack-commons/src/main/resources/spotbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/Interned.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import java.lang.annotation.Documented; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | import java.lang.annotation.ElementType; 18 | 19 | /** 20 | * Designates that a field, return value, argument, or a variable is supposed 21 | * to be an {@link String#intern() interned} string. 22 | * 23 | *

24 | * In many places in the istack, we assume Strings to be interned for 25 | * the performance reason. Similarly, In many other places, we don't 26 | * make such an assumption for the performance reason (because intern 27 | * isn't free.) 28 | * 29 | *

30 | * Therefore, distinguishing which part is supposed to be interned and 31 | * which part is supposed to be not is important. This annotation 32 | * allows us to capture that in the code. 33 | * 34 | * @author Kohsuke Kawaguchi 35 | */ 36 | @Documented 37 | @Retention(RetentionPolicy.CLASS) 38 | @Target({ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.LOCAL_VARIABLE}) 39 | public @interface Interned { 40 | } 41 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/XMLStreamException2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import javax.xml.stream.XMLStreamException; 14 | import javax.xml.stream.Location; 15 | 16 | /** 17 | * {@link XMLStreamException} that properly handles exception chaining. 18 | * 19 | * @author Kohsuke Kawaguchi 20 | */ 21 | public class XMLStreamException2 extends XMLStreamException { 22 | 23 | private static final long serialVersionUID = 1409033131880742500L; 24 | 25 | public XMLStreamException2(String msg) { 26 | super(msg); 27 | } 28 | 29 | public XMLStreamException2(Throwable th) { 30 | super(th); 31 | } 32 | 33 | public XMLStreamException2(String msg, Throwable th) { 34 | super(msg, th); 35 | } 36 | 37 | public XMLStreamException2(String msg, Location location) { 38 | super(msg, location); 39 | } 40 | 41 | public XMLStreamException2(String msg, Location location, Throwable th) { 42 | super(msg, location, th); 43 | } 44 | 45 | /** 46 | * {@link XMLStreamException} doesn't return the correct cause. 47 | */ 48 | @Override 49 | public Throwable getCause() { 50 | return getNestedException(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/localization/Localizable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.localization; 12 | 13 | import java.util.Locale; 14 | import java.util.ResourceBundle; 15 | 16 | /** 17 | * Localizable message. 18 | * 19 | * @author WS Development Team 20 | */ 21 | public interface Localizable { 22 | /** 23 | * Gets the key in the resource bundle. 24 | * 25 | * @return 26 | * if this method returns {@link #NOT_LOCALIZABLE}, 27 | * that means the message is not localizable, and 28 | * the first item of {@link #getArguments()} array 29 | * holds a String. 30 | */ 31 | String getKey(); 32 | 33 | /** 34 | * Returns the arguments for message formatting. 35 | * 36 | * @return 37 | * can be an array of length 0 but never be null. 38 | */ 39 | Object[] getArguments(); 40 | String getResourceBundleName(); 41 | 42 | ResourceBundle getResourceBundle(Locale locale); 43 | 44 | /** 45 | * Special constant that represents a message that 46 | * is not localizable. 47 | * 48 | *

49 | * Use of "new" is to create an unique instance. 50 | */ 51 | String NOT_LOCALIZABLE = "\u0000"; 52 | } 53 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/localization/LocalizableMessageFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.localization; 12 | 13 | import java.util.Locale; 14 | import java.util.ResourceBundle; 15 | 16 | /** 17 | * @author WS Development Team 18 | */ 19 | public class LocalizableMessageFactory { 20 | 21 | private final String _bundlename; 22 | private final ResourceBundleSupplier _rbSupplier; 23 | 24 | @Deprecated 25 | public LocalizableMessageFactory(String bundlename) { 26 | _bundlename = bundlename; 27 | _rbSupplier = null; 28 | } 29 | 30 | public LocalizableMessageFactory(String bundlename, ResourceBundleSupplier rbSupplier) { 31 | _bundlename = bundlename; 32 | _rbSupplier = rbSupplier; 33 | } 34 | 35 | public Localizable getMessage(String key, Object... args) { 36 | return new LocalizableMessage(_bundlename, _rbSupplier, key, args); 37 | } 38 | 39 | public interface ResourceBundleSupplier { 40 | /** 41 | * Gets the ResourceBundle. 42 | * @param locale the requested bundle's locale 43 | * @return ResourceBundle 44 | */ 45 | ResourceBundle getResourceBundle(Locale locale); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/com/sun/istack/test/Which.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.test; 12 | 13 | import java.net.URL; 14 | 15 | /** 16 | * Finds out where a class file is loaded from. 17 | * 18 | * @author 19 | * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 20 | */ 21 | public class Which { 22 | 23 | public static String which( Class clazz ) { 24 | return which( clazz.getName(), clazz.getClassLoader()); 25 | } 26 | 27 | /** 28 | * Search the specified classloader for the given classname. 29 | * 30 | * @param classname the fully qualified name of the class to search for 31 | * @param loader the classloader to search 32 | * @return the source location of the resource, or null if it wasn't found 33 | */ 34 | public static String which(String classname, ClassLoader loader) { 35 | 36 | String classnameAsResource = classname.replace('.', '/') + ".class"; 37 | 38 | if(loader == null) { 39 | loader = ClassLoader.getSystemClassLoader(); 40 | } 41 | 42 | URL it = loader.getResource(classnameAsResource); 43 | if (it != null) { 44 | return it.toString(); 45 | } else { 46 | return null; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/com/sun/istack/test/ForkOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.test; 12 | 13 | import java.io.OutputStream; 14 | import java.io.IOException; 15 | 16 | /** 17 | * {@link OutputStream} splitter. 18 | * 19 | * @author Kohsuke Kawaguchi 20 | */ 21 | public final class ForkOutputStream extends OutputStream { 22 | final OutputStream out1,out2; 23 | 24 | public ForkOutputStream(OutputStream out1,OutputStream out2) { 25 | this.out1 = out1; 26 | this.out2 = out2; 27 | } 28 | 29 | @Override 30 | public void write(int b) throws IOException { 31 | out1.write(b); 32 | out2.write(b); 33 | } 34 | 35 | @Override 36 | public void close() throws IOException { 37 | out1.close(); 38 | out2.close(); 39 | } 40 | 41 | @Override 42 | public void flush() throws IOException { 43 | out1.flush(); 44 | out2.flush(); 45 | } 46 | 47 | @Override 48 | public void write(byte[] b) throws IOException { 49 | out1.write(b); 50 | out2.write(b); 51 | } 52 | 53 | @Override 54 | public void write(byte[] b, int off, int len) throws IOException { 55 | out1.write(b,off,len); 56 | out2.write(b,off,len); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/SAXParseException2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import org.xml.sax.SAXParseException; 14 | import org.xml.sax.Locator; 15 | 16 | /** 17 | * {@link SAXParseException} that handles exception chaining correctly. 18 | * 19 | * @author Kohsuke Kawaguchi 20 | * @since 2.0 FCS 21 | */ 22 | public class SAXParseException2 extends SAXParseException { 23 | 24 | private static final long serialVersionUID = 1304853690034671001L; 25 | 26 | public SAXParseException2(String message, Locator locator) { 27 | super(message, locator); 28 | } 29 | 30 | public SAXParseException2(String message, Locator locator, Exception e) { 31 | super(message, locator, e); 32 | } 33 | 34 | public SAXParseException2(String message, String publicId, String systemId, int lineNumber, int columnNumber) { 35 | super(message, publicId, systemId, lineNumber, columnNumber); 36 | } 37 | 38 | public SAXParseException2(String message, String publicId, String systemId, int lineNumber, int columnNumber, Exception e) { 39 | super(message, publicId, systemId, lineNumber, columnNumber, e); 40 | } 41 | 42 | @Override 43 | public Throwable getCause() { 44 | return getException(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License v. 2.0 which is available at 6 | # http://www.eclipse.org/legal/epl-2.0, 7 | # or the Eclipse Distribution License v. 1.0 which is available at 8 | # http://www.eclipse.org/org/documents/edl-v10.php. 9 | # 10 | # SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause 11 | # 12 | 13 | name: Jakarta IStack Commons 14 | 15 | on: 16 | pull_request: 17 | push: 18 | # Allows you to run this workflow manually from the Actions tab 19 | workflow_dispatch: 20 | 21 | concurrency: 22 | group: ${{ github.ref }} 23 | cancel-in-progress: true 24 | 25 | jobs: 26 | build: 27 | name: Test on JDK ${{ matrix.java_version }} 28 | runs-on: ubuntu-latest 29 | 30 | strategy: 31 | matrix: 32 | java_version: [ 11, 17 , 21-ea] 33 | 34 | steps: 35 | - name: Checkout for build 36 | uses: actions/checkout@v3 37 | with: 38 | fetch-depth: 0 39 | - name: Set up JDK 40 | uses: actions/setup-java@v3 41 | with: 42 | distribution: 'zulu' 43 | java-version: ${{ matrix.java_version }} 44 | cache: maven 45 | - name: Verify 46 | run: | 47 | cd istack-commons 48 | mvn -B -V -U -C -Pstaging,oss-release,license-check clean verify org.glassfish.copyright:glassfish-copyright-maven-plugin:check -Dgpg.skip=true -Dittest=true -Dcopyright.ignoreyear=true 49 | - name: Upload license-check info 50 | uses: actions/upload-artifact@v3 51 | with: 52 | name: license-summary.txt 53 | path: istack-commons/target/dash/summary 54 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Eclipse Foundation, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /istack-commons/tools/src/main/java/com/sun/istack/tools/MaskingClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.tools; 12 | 13 | import java.util.Collection; 14 | 15 | /** 16 | * {@link ClassLoader} that masks a specified set of classes 17 | * from its parent class loader. 18 | * 19 | *

20 | * This code is used to create an isolated environment. 21 | * 22 | * @author Kohsuke Kawaguchi 23 | */ 24 | public class MaskingClassLoader extends ClassLoader { 25 | 26 | private final String[] masks; 27 | 28 | public MaskingClassLoader(String... masks) { 29 | this.masks = masks; 30 | } 31 | 32 | public MaskingClassLoader(Collection masks) { 33 | this(masks.toArray(new String[0])); 34 | } 35 | 36 | public MaskingClassLoader(ClassLoader parent, String... masks) { 37 | super(parent); 38 | this.masks = masks; 39 | } 40 | 41 | public MaskingClassLoader(ClassLoader parent, Collection masks) { 42 | this(parent, masks.toArray(new String[0])); 43 | } 44 | 45 | @Override 46 | protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 47 | for (String mask : masks) { 48 | if(name.startsWith(mask)) 49 | throw new ClassNotFoundException(); 50 | } 51 | 52 | return super.loadClass(name, resolve); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /istack-commons/runtime/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 4.0.0 16 | 17 | com.sun.istack 18 | istack-commons 19 | 4.2.1-SNAPSHOT 20 | ../pom.xml 21 | 22 | istack-commons-runtime 23 | 24 | istack common utility code runtime 25 | 26 | 27 | 28 | jakarta.activation 29 | jakarta.activation-api 30 | provided 31 | true 32 | 33 | 34 | 35 | 36 | 37 | 38 | maven-jar-plugin 39 | 40 | 41 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # iStack Common Utility Code 10 | 11 | [![Build Status](https://github.com/eclipse-ee4j/jaxb-istack-commons/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/eclipse-ee4j/jaxb-istack-commons/actions/workflows/maven.yml?branch=master) 12 | [![Jakarta Staging (Snapshots)](https://img.shields.io/nexus/s/https/jakarta.oss.sonatype.org/com.sun.istack/istack-commons.svg)](https://jakarta.oss.sonatype.org/content/repositories/staging/com/sun/istack/istack-commons/) 13 | 14 | This project is part of [Eclipse Implementation of JAXB](https://projects.eclipse.org/projects/ee4j.jaxb-impl). 15 | 16 | ## License 17 | 18 | iStack Common Utility Code is licensed under a license - [EDL 1.0](LICENSE.md). 19 | 20 | ## Contributing 21 | 22 | We use [contribution policy](CONTRIBUTING.md), which means we can only accept contributions under 23 | the terms of [Eclipse Contributor Agreement](http://www.eclipse.org/legal/ECA.php). 24 | 25 | ## Links 26 | 27 | * [Runtime Utilities](https://javadoc.io/doc/com.sun.istack/istack-commons-runtime/latest/com.sun.istack.runtime/module-summary.html) 28 | * [Tooltime Utilities](https://javadoc.io/doc/com.sun.istack/istack-commons-tools/latest/com.sun.istack.tools/module-summary.html) 29 | * [Test Utilities](https://javadoc.io/doc/com.sun.istack/istack-commons-test/latest/com.sun.istack.test/module-summary.html) 30 | * [Mailing list](https://accounts.eclipse.org/mailing-list/jaxb-impl-dev) 31 | -------------------------------------------------------------------------------- /istack-commons/src/main/assembly/resources.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 23 | resources 24 | 25 | zip 26 | 27 | false 28 | 29 | 30 | ${project.basedir}/.. 31 | legal 32 | 33 | LICENSE.md 34 | NOTICE.md 35 | 36 | 37 | 38 | ${project.basedir}/src/main/resources 39 | config 40 | 41 | * 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # Contributing to Eclipse Implementation of JAXB 10 | 11 | Thanks for your interest in this project. 12 | 13 | ## Project description 14 | 15 | The Java™ Architecture for XML Binding (JAXB) provides an API and tools that 16 | automate the mapping between XML documents and Java objects. This project 17 | contains implementation of JAXB API. 18 | 19 | * https://projects.eclipse.org/projects/ee4j.jaxb-impl 20 | 21 | ## Developer resources 22 | 23 | Information regarding source code management, builds, coding standards, and 24 | more. 25 | 26 | * https://projects.eclipse.org/projects/ee4j.jaxb-impl/developer 27 | 28 | The project maintains the following source code repositories 29 | 30 | 31 | ## Eclipse Contributor Agreement 32 | 33 | Before your contribution can be accepted by the project team contributors must 34 | electronically sign the Eclipse Contributor Agreement (ECA). 35 | 36 | * http://www.eclipse.org/legal/ECA.php 37 | 38 | Commits that are provided by non-committers must have a Signed-off-by field in 39 | the footer indicating that the author is aware of the terms by which the 40 | contribution has been provided to the project. The non-committer must 41 | additionally have an Eclipse Foundation account and must have a signed Eclipse 42 | Contributor Agreement (ECA) on file. 43 | 44 | For more information, please see the Eclipse Committer Handbook: 45 | https://www.eclipse.org/projects/handbook/#resources-commit 46 | 47 | ## Contact 48 | 49 | Contact the project developers via the project's "dev" list. 50 | 51 | * https://accounts.eclipse.org/mailing-list/jaxb-impl-dev 52 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/localization/LocalizableMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.localization; 12 | 13 | import com.sun.istack.localization.LocalizableMessageFactory.ResourceBundleSupplier; 14 | 15 | import java.util.Arrays; 16 | import java.util.Locale; 17 | import java.util.ResourceBundle; 18 | 19 | 20 | /** 21 | * @author WS Development Team 22 | */ 23 | public final class LocalizableMessage implements Localizable { 24 | 25 | private final String _bundlename; 26 | private final ResourceBundleSupplier _rbSupplier; 27 | 28 | private final String _key; 29 | private final Object[] _args; 30 | 31 | @Deprecated 32 | public LocalizableMessage(String bundlename, String key, Object... args) { 33 | this(bundlename, null, key, args); 34 | } 35 | 36 | public LocalizableMessage(String bundlename, ResourceBundleSupplier rbSupplier, 37 | String key, Object... args) { 38 | _bundlename = bundlename; 39 | _rbSupplier = rbSupplier; 40 | _key = key; 41 | if(args==null) 42 | args = new Object[0]; 43 | _args = args; 44 | } 45 | 46 | @Override 47 | public String getKey() { 48 | return _key; 49 | } 50 | 51 | @Override 52 | public Object[] getArguments() { 53 | return Arrays.copyOf(_args, _args.length); 54 | } 55 | 56 | @Override 57 | public String getResourceBundleName() { 58 | return _bundlename; 59 | } 60 | 61 | @Override 62 | public ResourceBundle getResourceBundle(Locale locale) { 63 | if (_rbSupplier == null) 64 | return null; 65 | 66 | return _rbSupplier.getResourceBundle(locale); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/ByteArrayDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import jakarta.activation.DataSource; 14 | import java.io.InputStream; 15 | import java.io.ByteArrayInputStream; 16 | import java.io.OutputStream; 17 | 18 | /** 19 | * {@link DataSource} backed by a byte buffer. 20 | * 21 | * @author Kohsuke Kawaguchi 22 | */ 23 | public final class ByteArrayDataSource implements DataSource { 24 | 25 | private final String contentType; 26 | private final byte[] buf; 27 | private final int len; 28 | 29 | /** 30 | * @param buf input buffer - the byte array isn't being copied; used directly 31 | * @param contentType content type 32 | */ 33 | public ByteArrayDataSource(byte[] buf, String contentType) { 34 | this(buf,buf.length,contentType); 35 | } 36 | 37 | /** 38 | * @param buf input buffer - the byte array isn't being copied; used directly 39 | * @param length length 40 | * @param contentType content type 41 | */ 42 | public ByteArrayDataSource(byte[] buf, int length, String contentType) { 43 | this.buf = buf; 44 | this.len = length; 45 | this.contentType = contentType; 46 | } 47 | 48 | @Override 49 | public String getContentType() { 50 | if(contentType==null) 51 | return "application/octet-stream"; 52 | return contentType; 53 | } 54 | 55 | @Override 56 | public InputStream getInputStream() { 57 | return new ByteArrayInputStream(buf,0,len); 58 | } 59 | 60 | @Override 61 | public String getName() { 62 | return null; 63 | } 64 | 65 | @Override 66 | public OutputStream getOutputStream() { 67 | throw new UnsupportedOperationException(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/script/setproxy.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | log.info("Checking proxy...") 12 | def itsettings = new XmlParser().parse(project.build.testResources.directory[0] + "/it-settings.xml") 13 | def itproxy = "" 14 | if (settings?.proxies) { 15 | Node proxies = new Node(itsettings, "proxies") 16 | settings?.proxies?.each { proxy -> 17 | if (proxy.active) { 18 | if ("http".equals(proxy.protocol)) { 19 | itproxy += " -Dhttp.proxyHost=" + proxy.host 20 | if (proxy.port) { 21 | itproxy += " -Dhttp.proxyPort=" + proxy.port 22 | } 23 | } else if ("https".equals(proxy.protocol)) { 24 | itproxy += " -Dhttps.proxyHost=" + proxy.host 25 | if (proxy.port) { 26 | itproxy += " -Dhttps.proxyPort=" + proxy.port 27 | } 28 | } 29 | def p = new Node(proxies, "proxy") 30 | new Node(p, "protocol", proxy.protocol) 31 | new Node(p, "port", proxy.port) 32 | if (proxy.username) {new Node(p, "username", proxy.username)} 33 | if (proxy.password) {new Node(p, "password", proxy.password)} 34 | if (proxy.id) {new Node(p, "id", proxy.id)} else {new Node(p, "id", proxy.protocol)} 35 | new Node(p, "host", proxy.host) 36 | new Node(p, "active", proxy.active) 37 | new Node(p, "nonProxyHosts", proxy.nonProxyHosts) 38 | } 39 | } 40 | } 41 | 42 | if (itproxy.trim().length() > 0) { 43 | log.info("Setting: " + itproxy.trim()) 44 | } else { 45 | log.info("No proxy found") 46 | } 47 | 48 | def writer = new FileWriter(new File(project.build.directory, "it-settings.xml")) 49 | groovy.xml.XmlNodePrinter printer = new groovy.xml.XmlNodePrinter(new PrintWriter(writer)) 50 | printer.setPreserveWhitespace(true) 51 | printer.print(itsettings) 52 | 53 | project.getModel().addProperty("ittest-proxy", itproxy.trim()) 54 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/test/script/setproxy.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | log.info("Checking proxy...") 12 | def itsettings = new XmlParser().parse(project.build.testResources.directory[0] + "/it-settings.xml") 13 | def itproxy = "" 14 | if (settings?.proxies) { 15 | Node proxies = new Node(itsettings, "proxies") 16 | settings?.proxies?.each { proxy -> 17 | if (proxy.active) { 18 | if ("http".equals(proxy.protocol)) { 19 | itproxy += " -Dhttp.proxyHost=" + proxy.host 20 | if (proxy.port) { 21 | itproxy += " -Dhttp.proxyPort=" + proxy.port 22 | } 23 | } else if ("https".equals(proxy.protocol)) { 24 | itproxy += " -Dhttps.proxyHost=" + proxy.host 25 | if (proxy.port) { 26 | itproxy += " -Dhttps.proxyPort=" + proxy.port 27 | } 28 | } 29 | def p = new Node(proxies, "proxy") 30 | new Node(p, "protocol", proxy.protocol) 31 | new Node(p, "port", proxy.port) 32 | if (proxy.username) {new Node(p, "username", proxy.username)} 33 | if (proxy.password) {new Node(p, "password", proxy.password)} 34 | if (proxy.id) {new Node(p, "id", proxy.id)} else {new Node(p, "id", proxy.protocol)} 35 | new Node(p, "host", proxy.host) 36 | new Node(p, "active", proxy.active) 37 | new Node(p, "nonProxyHosts", proxy.nonProxyHosts) 38 | } 39 | } 40 | } 41 | 42 | if (itproxy.trim().length() > 0) { 43 | log.info("Setting: " + itproxy.trim()) 44 | } else { 45 | log.info("No proxy found") 46 | } 47 | 48 | def writer = new FileWriter(new File(project.build.directory, "it-settings.xml")) 49 | groovy.xml.XmlNodePrinter printer = new groovy.xml.XmlNodePrinter(new PrintWriter(writer)) 50 | printer.setPreserveWhitespace(true) 51 | printer.print(itsettings) 52 | 53 | project.getModel().addProperty("ittest-proxy", itproxy.trim()) 54 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/main/java/com/oracle/istack/maven/DependencyResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.oracle.istack.maven; 12 | 13 | import java.util.List; 14 | import org.eclipse.aether.RepositorySystem; 15 | import org.eclipse.aether.RepositorySystemSession; 16 | import org.eclipse.aether.artifact.Artifact; 17 | import org.eclipse.aether.collection.CollectRequest; 18 | import org.eclipse.aether.graph.Dependency; 19 | import org.eclipse.aether.repository.RemoteRepository; 20 | import org.eclipse.aether.resolution.DependencyRequest; 21 | import org.eclipse.aether.resolution.DependencyResolutionException; 22 | import org.eclipse.aether.resolution.DependencyResult; 23 | import org.eclipse.aether.artifact.DefaultArtifact; 24 | 25 | /** 26 | * 27 | * @author lukas 28 | */ 29 | final class DependencyResolver { 30 | 31 | public static DependencyResult resolve(CollectRequest collectRequest, List remoteRepos, 32 | RepositorySystem repoSystem, RepositorySystemSession repoSession) throws DependencyResolutionException { 33 | DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null); 34 | return repoSystem.resolveDependencies(repoSession, dependencyRequest); 35 | } 36 | 37 | public static DependencyResult resolve(org.apache.maven.model.Dependency dependency, List remoteRepos, 38 | RepositorySystem repoSystem, RepositorySystemSession repoSession) throws DependencyResolutionException { 39 | CollectRequest collectRequest = new CollectRequest(createDependency(dependency), remoteRepos); 40 | return resolve(collectRequest, remoteRepos, repoSystem, repoSession); 41 | } 42 | 43 | private static Dependency createDependency(org.apache.maven.model.Dependency d) { 44 | Artifact artifact = new DefaultArtifact(d.getGroupId(), d.getArtifactId(), "pom", d.getVersion()); 45 | return new Dependency(artifact, d.getScope(), d.isOptional(), null); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/test/java/com/sun/istack/logging/LoggerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.logging; 12 | 13 | import org.junit.Assert; 14 | import org.junit.Test; 15 | 16 | import java.io.ByteArrayOutputStream; 17 | import java.nio.charset.StandardCharsets; 18 | import java.util.logging.Formatter; 19 | import java.util.logging.Level; 20 | import java.util.logging.LogRecord; 21 | import java.util.logging.StreamHandler; 22 | 23 | /** 24 | * 25 | * @author Marek Potociar 26 | */ 27 | public class LoggerTest { 28 | 29 | public LoggerTest() { 30 | } 31 | 32 | /** 33 | * Test of getLogger method, of class Logger. 34 | */ 35 | @Test 36 | public void testGetLogger() { 37 | Logger result = Logger.getLogger(LoggerTest.class); 38 | Assert.assertNotNull(result); 39 | } 40 | 41 | /** 42 | * Test of getSystemLoggerName method, of class Logger. 43 | */ 44 | @Test 45 | public void testGetSubsystemName() { 46 | String result = Logger.getSystemLoggerName(LoggerTest.class); 47 | Assert.assertEquals("com.sun.istack.logging", result); 48 | } 49 | 50 | /** 51 | * Test source method name resolution 52 | */ 53 | @Test 54 | public void testGetCallerMethodName() { 55 | Logger istackLogger = Logger.getLogger(LoggerTest.class); 56 | java.util.logging.Logger utilLogger = 57 | java.util.logging.Logger.getLogger(Logger.getSystemLoggerName(LoggerTest.class)); 58 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 59 | StreamHandler streamHandler = new StreamHandler(outputStream, new Formatter() { 60 | @Override 61 | public String format(LogRecord record) { 62 | return record.getSourceMethodName(); 63 | } 64 | }); 65 | utilLogger.addHandler(streamHandler); 66 | 67 | istackLogger.logException(new Exception("This LOG entry is part of the test"), Level.INFO); 68 | 69 | streamHandler.flush(); 70 | 71 | String logText = outputStream.toString(StandardCharsets.UTF_8); 72 | Assert.assertEquals("testGetCallerMethodName", logText); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/resources/it-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | it-repo 18 | 19 | true 20 | 21 | 22 | 23 | local.central 24 | @localRepositoryUrl@ 25 | 26 | true 27 | 28 | 29 | true 30 | 31 | 32 | 33 | jakarta-sonatype-nexus 34 | https://jakarta.oss.sonatype.org/service/local/staging/deploy/maven2/ 35 | default 36 | 37 | 38 | jakarta-sonatype-nexus-staging 39 | https://jakarta.oss.sonatype.org/content/repositories/staging/ 40 | default 41 | 42 | 43 | 44 | 45 | local.central 46 | @localRepositoryUrl@ 47 | 48 | true 49 | 50 | 51 | true 52 | 53 | 54 | 55 | jakarta-sonatype-nexus-plugins 56 | https://jakarta.oss.sonatype.org/service/local/staging/deploy/maven2/ 57 | default 58 | 59 | 60 | jakarta-sonatype-nexus-staging-plugins 61 | https://jakarta.oss.sonatype.org/content/repositories/staging/ 62 | default 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/test/resources/it-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | it-repo 18 | 19 | true 20 | 21 | 22 | 23 | local.central 24 | @localRepositoryUrl@ 25 | 26 | true 27 | 28 | 29 | true 30 | 31 | 32 | 33 | jakarta-sonatype-nexus 34 | https://jakarta.oss.sonatype.org/service/local/staging/deploy/maven2/ 35 | default 36 | 37 | 38 | jakarta-sonatype-nexus-staging 39 | https://jakarta.oss.sonatype.org/content/repositories/staging/ 40 | default 41 | 42 | 43 | 44 | 45 | local.central 46 | @localRepositoryUrl@ 47 | 48 | true 49 | 50 | 51 | true 52 | 53 | 54 | 55 | jakarta-sonatype-nexus-plugins 56 | https://jakarta.oss.sonatype.org/service/local/staging/deploy/maven2/ 57 | default 58 | 59 | 60 | jakarta-sonatype-nexus-staging-plugins 61 | https://jakarta.oss.sonatype.org/content/repositories/staging/ 62 | default 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/main/java/com/sun/istack/maven/LicenseCodeWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.maven; 12 | 13 | import com.sun.codemodel.CodeWriter; 14 | import com.sun.codemodel.JPackage; 15 | import com.sun.codemodel.writer.FilterCodeWriter; 16 | 17 | import java.io.BufferedReader; 18 | import java.io.File; 19 | import java.io.IOException; 20 | import java.io.PrintWriter; 21 | import java.io.Writer; 22 | import java.nio.charset.Charset; 23 | import java.nio.file.Files; 24 | import java.nio.file.Path; 25 | import java.util.Calendar; 26 | import java.util.regex.Matcher; 27 | import java.util.regex.Pattern; 28 | 29 | /** 30 | * Writes all the source files under the specified file folder and inserts a 31 | * license file each java source file. 32 | */ 33 | final class LicenseCodeWriter extends FilterCodeWriter { 34 | 35 | private static final String COPYRIGHT_LINE_TEMPLATE = "^.*Copyright \\(c\\) (YYYY) (by )?([A-Za-z].*)$"; 36 | private static final Pattern PATTERN = Pattern.compile(COPYRIGHT_LINE_TEMPLATE, Pattern.MULTILINE); 37 | private static final String CURRENT_YEAR = String.valueOf(Calendar.getInstance().get(Calendar.YEAR)); 38 | 39 | private final Path license; 40 | 41 | /** 42 | * @param core This CodeWriter will be used to actually create a storage 43 | * for files. LicenseCodeWriter simply decorates this underlying 44 | * CodeWriter by adding prolog comments. 45 | * @param license license File 46 | * @param encoding encoding 47 | */ 48 | public LicenseCodeWriter(CodeWriter core, File license, String encoding) { 49 | super(core); 50 | this.license = license.toPath(); 51 | this.encoding = encoding; 52 | } 53 | 54 | @Override 55 | public Writer openSource(JPackage pkg, String fileName) throws IOException { 56 | Writer w = super.openSource(pkg, fileName); 57 | 58 | PrintWriter out = new PrintWriter(w); 59 | try (BufferedReader br = Files.newBufferedReader(license, Charset.forName(encoding))) { 60 | String line; 61 | while ((line = br.readLine()) != null) { 62 | Matcher m = PATTERN.matcher(line); 63 | if (m.matches()) { 64 | out.write(line, 0, m.start(1)); 65 | out.write(CURRENT_YEAR); 66 | out.write(line, m.end(1), line.length() - m.end(1)); 67 | } else { 68 | out.write(line); 69 | } 70 | out.write(System.lineSeparator()); 71 | } 72 | } 73 | 74 | out.flush(); // we can't close the stream for that would close the underlying stream. 75 | 76 | return w; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /istack-commons/test/pom.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 4.0.0 15 | 16 | com.sun.istack 17 | istack-commons 18 | 4.2.1-SNAPSHOT 19 | ../pom.xml 20 | 21 | istack-commons-test 22 | 23 | istack common utility code test 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-compiler-plugin 30 | 31 | 32 | default-compile 33 | 34 | 35 | --add-reads 36 | com.sun.istack.test=ALL-UNNAMED 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-jar-plugin 45 | 46 | 47 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-javadoc-plugin 54 | 55 | 56 | --add-reads 57 | com.sun.istack.test=ALL-UNNAMED 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | junit 67 | junit 68 | compile 69 | 70 | 71 | org.apache.ant 72 | ant-junit 73 | true 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/Pool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack; 12 | 13 | import java.util.concurrent.ConcurrentLinkedQueue; 14 | import java.lang.ref.WeakReference; 15 | 16 | /** 17 | * Pool of reusable objects that are indistinguishable from each other, 18 | * such as JAXB marshallers. 19 | * 20 | * @author Kohsuke Kawaguchi 21 | * @param type 22 | */ 23 | public interface Pool { 24 | 25 | /** 26 | * Gets a new object from the pool. 27 | * 28 | *

29 | * If no object is available in the pool, this method creates a new one. 30 | * @return an object from the pool 31 | */ 32 | @NotNull T take(); 33 | 34 | /** 35 | * Returns an object back to the pool. 36 | * @param t object to put back to pool 37 | */ 38 | void recycle(@NotNull T t); 39 | 40 | /** 41 | * Default implementation that uses {@link ConcurrentLinkedQueue} 42 | * as the data store. 43 | * 44 | *

Note for Implementors

45 | *

46 | * Don't rely on the fact that this class extends from {@link ConcurrentLinkedQueue}. 47 | * @param type 48 | */ 49 | abstract class Impl implements Pool { 50 | 51 | private volatile WeakReference> queue; 52 | 53 | /** 54 | * Create new Impl 55 | */ 56 | protected Impl() { 57 | } 58 | 59 | /** 60 | * Gets a new object from the pool. 61 | * 62 | *

63 | * If no object is available in the pool, this method creates a new one. 64 | * 65 | * @return 66 | * always non-null. 67 | */ 68 | @Override 69 | public final @NotNull T take() { 70 | T t = getQueue().poll(); 71 | if(t==null) { 72 | return create(); 73 | } 74 | return t; 75 | } 76 | 77 | /** 78 | * Returns an object back to the pool. 79 | * @param t object to put back to the pool 80 | */ 81 | @Override 82 | public final void recycle(T t) { 83 | getQueue().offer(t); 84 | } 85 | 86 | private ConcurrentLinkedQueue getQueue() { 87 | WeakReference> q = queue; 88 | if (q != null) { 89 | ConcurrentLinkedQueue d = q.get(); 90 | if (d != null) { 91 | return d; 92 | } 93 | } 94 | // overwrite the queue 95 | ConcurrentLinkedQueue d = new ConcurrentLinkedQueue<>(); 96 | queue = new WeakReference<>(d); 97 | 98 | return d; 99 | } 100 | 101 | /** 102 | * Creates a new instance of object. 103 | * 104 | *

105 | * This method is used when someone wants to 106 | * {@link #take() take} an object from an empty pool. 107 | * 108 | *

109 | * Also note that multiple threads may call this method 110 | * concurrently. 111 | * @return an object from an empty pool 112 | */ 113 | protected abstract @NotNull T create(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /istack-commons/soimp/src/main/java/com/sun/istack/soimp/Proc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.soimp; 12 | 13 | import java.io.File; 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.io.OutputStream; 17 | 18 | public final class Proc { 19 | private final Process proc; 20 | private final Thread t1,t2; 21 | 22 | public Proc(String cmd,String[] env,OutputStream out, File workDir) throws IOException { 23 | this( Runtime.getRuntime().exec(new String [] {cmd},env,workDir), null, out ); 24 | } 25 | 26 | public Proc(String[] cmd,String[] env,OutputStream out, File workDir) throws IOException { 27 | this( Runtime.getRuntime().exec(cmd,env,workDir), null, out ); 28 | } 29 | 30 | public Proc(String[] cmd,String[] env,InputStream in,OutputStream out) throws IOException { 31 | this( Runtime.getRuntime().exec(cmd,env), in, out ); 32 | } 33 | 34 | private Proc( Process proc, InputStream in, OutputStream out ) throws IOException { 35 | this.proc = proc; 36 | t1 = new Copier(proc.getInputStream(), out); 37 | t1.start(); 38 | t2 = new Copier(proc.getErrorStream(), out); 39 | t2.start(); 40 | if(in!=null) 41 | new ByteCopier(in,proc.getOutputStream()).start(); 42 | else 43 | proc.getOutputStream().close(); 44 | } 45 | 46 | public int join() { 47 | try { 48 | t1.join(); 49 | t2.join(); 50 | return proc.waitFor(); 51 | } catch (InterruptedException e) { 52 | // aborting. kill the process 53 | proc.destroy(); 54 | return -1; 55 | } 56 | } 57 | 58 | private static class Copier extends Thread { 59 | private final InputStream in; 60 | private final OutputStream out; 61 | 62 | public Copier(InputStream in, OutputStream out) { 63 | this.in = in; 64 | this.out = out; 65 | } 66 | 67 | @Override 68 | public void run() { 69 | try { 70 | copyStream(in,out); 71 | in.close(); 72 | } catch (IOException e) { 73 | // TODO: what to do? 74 | } 75 | } 76 | } 77 | 78 | private static class ByteCopier extends Thread { 79 | private final InputStream in; 80 | private final OutputStream out; 81 | 82 | public ByteCopier(InputStream in, OutputStream out) { 83 | this.in = in; 84 | this.out = out; 85 | } 86 | 87 | @Override 88 | public void run() { 89 | try { 90 | while(true) { 91 | int ch = in.read(); 92 | if(ch==-1) break; 93 | out.write(ch); 94 | } 95 | in.close(); 96 | out.close(); 97 | } catch (IOException e) { 98 | // TODO: what to do? 99 | } 100 | } 101 | } 102 | 103 | public static void copyStream(InputStream in,OutputStream out) throws IOException { 104 | byte[] buf = new byte[256]; 105 | int len; 106 | while((len=in.read(buf))>0) 107 | out.write(buf,0,len); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/main/java/com/sun/istack/maven/RSFileSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.maven; 12 | 13 | import java.io.IOException; 14 | import java.nio.file.FileSystem; 15 | import java.nio.file.FileSystems; 16 | import java.nio.file.FileVisitResult; 17 | import static java.nio.file.FileVisitResult.CONTINUE; 18 | import java.nio.file.Files; 19 | import java.nio.file.LinkOption; 20 | import java.nio.file.Path; 21 | import java.nio.file.PathMatcher; 22 | import java.nio.file.Paths; 23 | import java.nio.file.SimpleFileVisitor; 24 | import java.nio.file.attribute.BasicFileAttributes; 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | /** 29 | * 30 | * @author lukas 31 | */ 32 | public class RSFileSet { 33 | 34 | private Path root; 35 | private List inc; 36 | private final PathMatcher exMatcher; 37 | 38 | public RSFileSet() { 39 | inc = new ArrayList<>(); 40 | exMatcher = FileSystems.getDefault().getPathMatcher("glob:*_*.properties"); 41 | } 42 | 43 | public void setDirectory(String dir) { 44 | root = Paths.get(dir); 45 | } 46 | 47 | public String getDirectory() { 48 | return root.toString(); 49 | } 50 | 51 | public boolean exists() { 52 | return Files.isDirectory(root, LinkOption.NOFOLLOW_LINKS); 53 | } 54 | public void addInclude(String include) { 55 | inc.add(include); 56 | } 57 | 58 | public List getIncludes() { 59 | return inc; 60 | } 61 | 62 | public void setIncludes(List inc) { 63 | this.inc = inc; 64 | } 65 | 66 | public Path resolve(Path path) { 67 | return root.resolve(path); 68 | } 69 | 70 | public List getIncludedFiles() { 71 | final List result = new ArrayList<>(); 72 | if (inc.isEmpty()) { 73 | inc.add("**"); 74 | } 75 | FileSystem fs = FileSystems.getDefault(); 76 | for (final String i : inc) { 77 | int idx = i.indexOf('/'); 78 | final PathMatcher matcher; 79 | final PathMatcher dirMatcher; 80 | if (idx < 0) { 81 | matcher = fs.getPathMatcher("glob:" + i); 82 | dirMatcher = null; 83 | } else { 84 | matcher = fs.getPathMatcher("glob:" + i.substring(idx + 1)); 85 | dirMatcher = fs.getPathMatcher("glob:" + i.substring(0, idx)); 86 | } 87 | try { 88 | Files.walkFileTree(root, new SimpleFileVisitor() { 89 | 90 | @Override 91 | public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { 92 | if (dirMatcher == null || (dirMatcher.matches(file.getParent()))) { 93 | Path name = file.getFileName(); 94 | if (name != null && matcher.matches(name) && !exMatcher.matches(name)) { 95 | result.add(root.relativize(file)); 96 | } 97 | } 98 | return CONTINUE; 99 | } 100 | }); 101 | } catch (IOException ex) { 102 | throw new RuntimeException(ex); 103 | } 104 | } 105 | return result; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/test/it/sample/pom.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 15 | 4.0.0 16 | 17 | com.sun.xml.ws 18 | importsample-bom 19 | 1.0-SNAPSHOT 20 | pom 21 | 22 | sample main 23 | 24 | 25 | 26 | 27 | com.sun.xml.ws 28 | imported-bom 29 | 1.0-SNAPSHOT 30 | import 31 | pom 32 | 33 | 34 | 35 | 36 | 37 | bom 38 | 39 | 40 | 41 | UTF-8 42 | 4.0.0-SNAPSHOT 43 | 44 | 45 | 46 | 47 | 48 | 49 | com.sun.istack 50 | import-properties-plugin 51 | ${ip.plugin.version} 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-enforcer-plugin 56 | 3.3.0 57 | 58 | 59 | 60 | 61 | 62 | com.sun.istack 63 | import-properties-plugin 64 | 65 | 66 | compile 67 | 68 | import-pom-properties 69 | 70 | 71 | 72 | 73 | 74 | org.apache.maven.plugins 75 | maven-enforcer-plugin 76 | 77 | 78 | enforce-property 79 | 80 | enforce 81 | 82 | compile 83 | 84 | 85 | 86 | tested.property 87 | Property not imported! 88 | 89 | 90 | true 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/com/sun/istack/test/VersionProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.test; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | import java.util.StringTokenizer; 16 | import org.w3c.dom.Document; 17 | import org.w3c.dom.Element; 18 | 19 | /** 20 | * Represents a range of versions. 21 | * 22 | * @author 23 | * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 24 | */ 25 | public final class VersionProcessor { 26 | /** 27 | * This test is only applicable to the RI of this version or later. 28 | * can be null. 29 | */ 30 | private final VersionNumber since; 31 | 32 | /** 33 | * This test is only applicable to the RI of this version or younger. 34 | * can be null. 35 | */ 36 | private final VersionNumber until; 37 | 38 | /** 39 | * This test shall be excluded from the RI of versions listed here. 40 | */ 41 | private final Set excludeVersions; 42 | 43 | /** 44 | * Special version number constant to represent ALL in 45 | * {@link #excludeVersions}. 46 | */ 47 | private static final Object ALL_VERSION = new Object(); 48 | 49 | /** 50 | * Creates a default {@link VersionProcessor} that accepts 51 | * any version. 52 | */ 53 | private VersionProcessor() { 54 | since = null; 55 | until = null; 56 | excludeVersions = null; 57 | } 58 | 59 | public VersionProcessor( String sinceValue, String untilValue, String excludeFromValue ) { 60 | if( sinceValue!=null && !sinceValue.trim().isEmpty()) 61 | since = new VersionNumber( sinceValue ); 62 | else 63 | since = null; 64 | 65 | if( untilValue!=null && !untilValue.trim().isEmpty()) 66 | until = new VersionNumber( untilValue ); 67 | else 68 | until = null; 69 | 70 | if( excludeFromValue!=null && !excludeFromValue.trim().isEmpty()) { 71 | excludeVersions = new HashSet<>(); 72 | String v = excludeFromValue.trim(); 73 | if(v.equals("all")) { 74 | excludeVersions.add(ALL_VERSION); 75 | } else { 76 | StringTokenizer tokens = new StringTokenizer( v ); 77 | while(tokens.hasMoreTokens()) 78 | excludeVersions.add( new VersionNumber( tokens.nextToken() ) ); 79 | } 80 | } else 81 | excludeVersions = null; 82 | } 83 | 84 | public VersionProcessor( Document testSpecMeta ) { 85 | this(testSpecMeta.getDocumentElement()); 86 | } 87 | 88 | public VersionProcessor( Element e ) { 89 | this(e.getAttribute("since"), e.getAttribute("until"), e.getAttribute("excludeFrom")); 90 | } 91 | 92 | /** 93 | * Checks if the test is valid against the JAXB RI of 94 | * the specified version. 95 | * @param v version to check 96 | * @return true if the test is valid 97 | */ 98 | public boolean isApplicable(VersionNumber v) { 99 | if( excludeVersions!=null ) { 100 | if( excludeVersions.contains(ALL_VERSION) 101 | || excludeVersions.contains(v) ) 102 | return false; 103 | } 104 | 105 | if(since!=null && since.isNewerThan(v)) 106 | return false; 107 | 108 | return until == null || !v.isNewerThan(until); 109 | } 110 | 111 | /** 112 | * Default {@link VersionProcessor} that accepts any version. 113 | */ 114 | public static final VersionProcessor DEFAULT = new VersionProcessor(); 115 | } 116 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/main/java/com/oracle/istack/maven/ImportPropertiesMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.oracle.istack.maven; 12 | 13 | import java.io.IOException; 14 | import java.util.List; 15 | import java.util.Properties; 16 | import java.util.logging.Level; 17 | import java.util.logging.Logger; 18 | import org.apache.maven.plugin.AbstractMojo; 19 | import org.apache.maven.plugin.MojoExecutionException; 20 | import org.apache.maven.plugins.annotations.Component; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.Mojo; 23 | import org.apache.maven.plugins.annotations.Parameter; 24 | import org.apache.maven.plugins.annotations.ResolutionScope; 25 | import org.apache.maven.project.MavenProject; 26 | import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 27 | import org.eclipse.aether.RepositorySystem; 28 | import org.eclipse.aether.RepositorySystemSession; 29 | import org.eclipse.aether.repository.RemoteRepository; 30 | 31 | /** 32 | * The import-properties goal imports all properties from scope-import poms 33 | * (boms) and sets them as project properties. 34 | * 35 | * @author Martin Grebac 36 | */ 37 | @Mojo(name = "import-pom-properties", threadSafe = true, 38 | defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.NONE) 39 | public class ImportPropertiesMojo extends AbstractMojo { 40 | 41 | /** 42 | * The Maven Project Object. 43 | */ 44 | @Parameter(defaultValue = "${project}", readonly = true) 45 | protected MavenProject project; 46 | 47 | /** 48 | * The entry point to Aether, i.e. the component doing all the work. 49 | * 50 | * @since 2.3.1 51 | */ 52 | @Component 53 | private RepositorySystem repoSystem; 54 | 55 | /** 56 | * The current repository/network configuration of Maven. 57 | * 58 | * @since 2.3.1 59 | */ 60 | @Parameter(defaultValue = "${repositorySystemSession}", readonly = true) 61 | private RepositorySystemSession repoSession; 62 | 63 | /** 64 | * The project's remote repositories to use for the resolution of project 65 | * and its dependencies. 66 | * 67 | * @since 2.3.1 68 | */ 69 | @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true) 70 | private List projectRepos; 71 | 72 | private Properties projectProperties = null; 73 | 74 | @Override 75 | public void execute() throws MojoExecutionException { 76 | try { 77 | projectProperties = project.getProperties(); 78 | 79 | MavenProject bomProject = project; 80 | while (bomProject != null && !bomProject.getArtifactId().endsWith("-bom")) { 81 | bomProject = bomProject.getParent(); 82 | } 83 | 84 | if (bomProject == null || !bomProject.getArtifactId().endsWith("-bom")) { 85 | getLog().warn("No '*-bom' project found in project hierarchy, using this project's pom for import search."); 86 | bomProject = project; 87 | } 88 | 89 | getLog().warn("Searching project: " + bomProject.getArtifactId()); 90 | 91 | PropertyResolver resolver = new PropertyResolver(new CommonLogger(getLog()), projectProperties, repoSession, repoSystem, projectRepos); 92 | resolver.resolveProperties(bomProject); 93 | 94 | } catch (XmlPullParserException | IOException ex) { 95 | Logger.getLogger(ImportPropertiesMojo.class.getName()).log(Level.SEVERE, null, ex); 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/com/sun/istack/test/VersionNumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.test; 12 | 13 | import java.util.Locale; 14 | import java.util.StringTokenizer; 15 | 16 | /** 17 | * Immutable representation of a dot-separated digits (such as "1.0.1"). 18 | * 19 | * {@link VersionNumber}s are {@link Comparable}. 20 | * 21 | *

22 | * We allow a component to be not just a number, but also "ea", "ea1", "ea2". 23 | * "ea" is treated as "ea0", and {@code eaN < M for any M > 0}. 24 | * 25 | *

26 | * '*' is also allowed as a component, and {@code '*' > M} for any {@code M > 0}. 27 | * 28 | *

 29 |  * {@code 2.0.* > 2.0.1 > 2.0.0 > 2.0.ea > 2.0 }
 30 |  * 
31 | * 32 | * @author 33 | * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 34 | */ 35 | public class VersionNumber implements Comparable { 36 | 37 | public static final VersionNumber v1_0 = new VersionNumber("1.0"); 38 | public static final VersionNumber v1_0_1 = new VersionNumber("1.0.1"); 39 | public static final VersionNumber v1_0_2 = new VersionNumber("1.0.2"); 40 | public static final VersionNumber v1_0_3 = new VersionNumber("1.0.3"); 41 | public static final VersionNumber v2_0 = new VersionNumber("2.0"); 42 | public static final VersionNumber v2_1 = new VersionNumber("2.1"); 43 | 44 | private final int[] digits; 45 | 46 | /** 47 | * Parses a string like "1.0.2" into the version number. 48 | * 49 | * @param num string to parse 50 | * @throws IllegalArgumentException 51 | * if the parsing fails. 52 | */ 53 | public VersionNumber( String num ) { 54 | StringTokenizer tokens = new StringTokenizer(num,"."); 55 | digits = new int[tokens.countTokens()]; 56 | if(digits.length<2) 57 | throw new IllegalArgumentException(); 58 | 59 | int i=0; 60 | while( tokens.hasMoreTokens() ) { 61 | String token = tokens.nextToken().toLowerCase(Locale.ENGLISH); 62 | if(token.equals("*")) { 63 | digits[i++] = 1000; 64 | } else 65 | if(token.startsWith("ea")) { 66 | if(token.length()==2) 67 | digits[i++] = -1000; // just "ea" 68 | else 69 | digits[i++] = -1000 + Integer.parseInt(token.substring(2)); // "eaNNN" 70 | } else { 71 | digits[i++] = Integer.parseInt(token); 72 | } 73 | } 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | StringBuilder buf = new StringBuilder(); 79 | for( int i=0; i0; 92 | } 93 | 94 | 95 | @Override 96 | public boolean equals( Object o ) { 97 | if (o instanceof VersionNumber) { 98 | return compareTo((VersionNumber)o)==0; 99 | } 100 | return false; 101 | } 102 | 103 | @Override 104 | public int hashCode() { 105 | int x=0; 106 | for (int i : digits) 107 | x = (x << 1) | i; 108 | return x; 109 | } 110 | 111 | @Override 112 | public int compareTo(VersionNumber rhs) { 113 | for( int i=0; ; i++ ) { 114 | if( i==this.digits.length && i==rhs.digits.length ) 115 | return 0; // equals 116 | if( i==this.digits.length ) 117 | return -1; // rhs is larger 118 | if( i==rhs.digits.length ) 119 | return 1; 120 | 121 | int r = this.digits[i] - rhs.digits[i]; 122 | if(r!=0) return r; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /istack-commons/tools/pom.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 4.0.0 15 | 16 | com.sun.istack 17 | istack-commons 18 | 4.2.1-SNAPSHOT 19 | ../pom.xml 20 | 21 | istack-commons-tools 22 | 23 | istack common utility code tools 24 | 25 | 26 | 27 | org.apache.ant 28 | ant 29 | true 30 | 31 | 32 | org.testng 33 | testng 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-compiler-plugin 47 | 48 | 49 | default-compile 50 | 51 | compile 52 | 53 | 54 | 55 | --add-reads 56 | com.sun.istack.tools=ALL-UNNAMED 57 | 58 | 59 | 60 | 61 | default-testCompile 62 | 63 | testCompile 64 | 65 | 66 | 67 | --add-reads 68 | com.sun.istack.tools=ALL-UNNAMED 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.apache.maven.plugins 76 | maven-surefire-plugin 77 | 78 | 79 | @{argLine} --add-opens java.base/java.net=com.sun.istack.tools 80 | 81 | 82 | 83 | 84 | org.apache.maven.plugins 85 | maven-jar-plugin 86 | 87 | 88 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-javadoc-plugin 95 | 96 | 97 | --add-reads 98 | com.sun.istack.tools=ALL-UNNAMED 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /istack-commons/tools/src/test/java/com/sun/istack/tools/ParallelWorldClassLoaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.tools; 12 | 13 | import java.io.File; 14 | import java.net.URL; 15 | import java.net.URLClassLoader; 16 | import java.util.ArrayList; 17 | import java.util.Collections; 18 | import java.util.Enumeration; 19 | import javax.xml.stream.XMLInputFactory; 20 | import org.testng.Assert; 21 | import org.testng.annotations.AfterMethod; 22 | import org.testng.annotations.BeforeMethod; 23 | import org.testng.annotations.Test; 24 | 25 | /** 26 | * 27 | * @author lukas 28 | */ 29 | public class ParallelWorldClassLoaderTest { 30 | 31 | private ClassLoader cl; 32 | private MaskingClassLoader mcl; 33 | private URLClassLoader ucl; 34 | private ParallelWorldClassLoader pwcl; 35 | private ClassLoader orig; 36 | 37 | public ParallelWorldClassLoaderTest() { 38 | } 39 | 40 | @BeforeMethod 41 | public void setUpMethod() throws Exception { 42 | cl = ClassLoader.getSystemClassLoader(); 43 | mcl = new MaskingClassLoader(cl, "javax.xml.ws"); 44 | String dir = System.getProperty("surefire.test.class.path").split(File.pathSeparator)[0]; 45 | ucl = new URLClassLoader(new URL[] {new File(dir).toURI().toURL()}, mcl); 46 | pwcl = new ParallelWorldClassLoader(ucl, ""); 47 | orig = Thread.currentThread().getContextClassLoader(); 48 | Thread.currentThread().setContextClassLoader(pwcl); 49 | } 50 | 51 | @AfterMethod(alwaysRun = true) 52 | public void tearDownMethod() { 53 | Thread.currentThread().setContextClassLoader(orig); 54 | } 55 | 56 | /** 57 | * Test of findClass method, of class ParallelWorldClassLoader. 58 | */ 59 | @Test 60 | public void testFindClass() { 61 | System.out.println("findClass"); 62 | //XXX: why this fails ? 63 | // Class c3 = pwcl.findClass("javax.xml.ws.Service"); 64 | // Assert.assertEquals(c3.getDeclaredMethods().length, 1); 65 | 66 | Class c1,c2; 67 | try { 68 | c1 = Class.forName("javax.xml.ws.Service", false, pwcl); 69 | // jacoco adds method '$jacocoInit' so there can be at most two 70 | Assert.assertTrue(c1.getDeclaredMethods().length < 3); 71 | } catch (ClassNotFoundException cnfe) { 72 | Assert.fail(); 73 | } 74 | try { 75 | c2 = Class.forName("javax.xml.ws.Service", false, Thread.currentThread().getContextClassLoader()); 76 | // jacoco adds method '$jacocoInit' so there can be at most two 77 | Assert.assertTrue(c2.getDeclaredMethods().length < 3); 78 | } catch (ClassNotFoundException cnfe) { 79 | Assert.fail(); 80 | } 81 | } 82 | 83 | /** 84 | * Test of findResource method, of class ParallelWorldClassLoader. 85 | */ 86 | @Test 87 | public void testFindResource() { 88 | if (isJDK9()) return; 89 | URL resource = pwcl.getResource("javax/xml/ws/Service.class"); 90 | URL object = pwcl.getResource("java/lang/Object.class"); 91 | String resJar = resource.getPath().substring(0, resource.getPath().indexOf("!")); 92 | String rtJar = object.getPath().substring(0, object.getPath().indexOf("!")); 93 | Assert.assertEquals(resJar, rtJar); 94 | } 95 | 96 | /** 97 | * Test of findResources method, of class ParallelWorldClassLoader. 98 | */ 99 | @Test 100 | public void testFindResources() throws Exception { 101 | if (isJDK9()) return; 102 | Enumeration foundURLs = pwcl.getResources("javax/xml/ws/Service.class"); 103 | // TODO - this depends on jdk, maven cp, e.g. 104 | ArrayList al = Collections.list(foundURLs); 105 | int found = al.size(); 106 | if (!((found == 3) || (found == 4))) { 107 | Assert.fail("Expected 3/4 elements. Verify the urls: \n" + al); 108 | } 109 | } 110 | 111 | @Test 112 | public void testJaxp() { 113 | XMLInputFactory inFactory = XMLInputFactory.newInstance(); 114 | Assert.assertEquals(inFactory.getClass().getClassLoader(), ucl); 115 | } 116 | 117 | private static boolean isJDK9() { 118 | return true; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/test/it/sample/pom.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 15 | 4.0.0 16 | 17 | com.sun.xml.ws 18 | sample 19 | 1.0-SNAPSHOT 20 | jar 21 | 22 | sample 23 | http://maven.apache.org 24 | 25 | 26 | UTF-8 27 | 4.0.0-SNAPSHOT 28 | ${tp.compiler.release} 29 | ${maven.compiler.release} 30 | 31 | 32 | 33 | 34 | com.sun.istack 35 | istack-commons-runtime 36 | ${resgen.plugin.version} 37 | 38 | 39 | jakarta.xml.bind 40 | jakarta.xml.bind-api 41 | 4.0.0 42 | 43 | 44 | junit 45 | junit 46 | 4.13.1 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | com.sun.istack 55 | istack-commons-maven-plugin 56 | ${resgen.plugin.version} 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-compiler-plugin 61 | 3.11.0 62 | 63 | 64 | 65 | 66 | 67 | com.sun.istack 68 | istack-commons-maven-plugin 69 | 70 | 71 | resource-gen 72 | 73 | rs-gen 74 | 75 | 76 | 77 | ${project.basedir}/src/main/resources 78 | 79 | 80 | 81 | 82 | quick-gen 83 | 84 | quick-gen 85 | 86 | 87 | org.app.annotation 88 | 89 | jakarta.xml.bind.annotation.XmlAttribute 90 | jakarta.xml.bind.annotation.XmlElement 91 | jakarta.xml.bind.annotation.XmlElementDecl 92 | jakarta.xml.bind.annotation.XmlElementRef 93 | jakarta.xml.bind.annotation.XmlElementRefs 94 | jakarta.xml.bind.annotation.XmlEnum 95 | jakarta.xml.bind.annotation.XmlRootElement 96 | jakarta.xml.bind.annotation.XmlSchema 97 | jakarta.xml.bind.annotation.XmlSchemaType 98 | jakarta.xml.bind.annotation.XmlTransient 99 | jakarta.xml.bind.annotation.XmlType 100 | jakarta.xml.bind.annotation.XmlValue 101 | 102 | false 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/src/main/java/com/oracle/istack/maven/PropertyResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.oracle.istack.maven; 12 | 13 | import org.apache.maven.model.Dependency; 14 | import org.apache.maven.model.DependencyManagement; 15 | import org.apache.maven.model.Model; 16 | import org.apache.maven.model.io.xpp3.MavenXpp3Reader; 17 | import org.apache.maven.project.MavenProject; 18 | import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 19 | import org.eclipse.aether.RepositorySystem; 20 | import org.eclipse.aether.RepositorySystemSession; 21 | import org.eclipse.aether.artifact.Artifact; 22 | import org.eclipse.aether.repository.RemoteRepository; 23 | import org.eclipse.aether.resolution.DependencyResolutionException; 24 | import org.eclipse.aether.resolution.DependencyResult; 25 | 26 | import java.io.FileNotFoundException; 27 | import java.io.FileReader; 28 | import java.io.IOException; 29 | import java.util.List; 30 | import java.util.Map; 31 | import java.util.Properties; 32 | import java.util.logging.Level; 33 | import java.util.logging.Logger; 34 | 35 | /** 36 | * 37 | * @author Martin Grebac 38 | */ 39 | public class PropertyResolver { 40 | 41 | private final CommonLogger logger; 42 | 43 | private final MavenXpp3Reader mavenreader = new MavenXpp3Reader(); 44 | 45 | private final Properties properties; 46 | 47 | private final RepositorySystemSession repoSession; 48 | 49 | private final RepositorySystem repoSystem; 50 | 51 | private final List pluginRepos; 52 | 53 | PropertyResolver(CommonLogger logger, Properties properties, RepositorySystemSession session, 54 | RepositorySystem repoSystem, List pluginRepositories) { 55 | this.logger = logger; 56 | this.properties = properties; 57 | this.repoSession = session; 58 | this.repoSystem = repoSystem; 59 | this.pluginRepos = pluginRepositories; 60 | } 61 | 62 | /** 63 | * 64 | * @param project maven project 65 | * @throws FileNotFoundException properties not found 66 | * @throws IOException IO error 67 | * @throws XmlPullParserException error parsing xml 68 | */ 69 | public void resolveProperties(MavenProject project) throws FileNotFoundException, IOException, XmlPullParserException { 70 | logger.info("Resolving properties for " + project.getGroupId() + ":" + project.getArtifactId()); 71 | 72 | Model model = null; 73 | FileReader reader; 74 | try { 75 | reader = new FileReader(project.getFile()); 76 | model = mavenreader.read(reader); 77 | } catch (IOException ex) { 78 | Logger.getLogger(ImportPropertiesMojo.class.getName()).log(Level.SEVERE, null, ex); 79 | } 80 | MavenProject loadedProject = new MavenProject(model); 81 | 82 | DependencyManagement dm = loadedProject.getDependencyManagement(); 83 | if (dm == null) { 84 | logger.warn("No dependency management section found in: " + loadedProject.getGroupId() + ":" + loadedProject.getArtifactId()); 85 | return; 86 | } 87 | 88 | List depList = dm.getDependencies(); 89 | 90 | DependencyResult result; 91 | for (Dependency d : depList) { 92 | if ("import".equals(d.getScope())) { 93 | try { 94 | String version = d.getVersion(); 95 | logger.info("Imported via import-scope: " + d.getGroupId() + ":" + d.getArtifactId() + ":" + version); 96 | if (version.contains("$")) { 97 | version = properties.getProperty(version.substring(version.indexOf('{')+1, version.lastIndexOf('}'))); 98 | logger.info("Imported version resolved to: " + version); 99 | } 100 | d.setVersion(version); 101 | d.setType("pom"); 102 | d.setClassifier("pom"); 103 | result = DependencyResolver.resolve(d, pluginRepos, repoSystem, repoSession); 104 | Artifact a = result.getArtifactResults().get(0).getArtifact(); 105 | reader = new FileReader(a.getFile()); 106 | Model m = mavenreader.read(reader); 107 | MavenProject p = new MavenProject(m); 108 | p.setFile(a.getFile()); 109 | for (Map.Entry e : p.getProperties().entrySet()) { 110 | logger.info("Setting property: " + e.getKey() + ":" + e.getValue()); 111 | properties.setProperty((String)e.getKey(), (String)e.getValue()); 112 | } 113 | 114 | resolveProperties(p); 115 | } catch (DependencyResolutionException ex) { 116 | Logger.getLogger(ImportPropertiesMojo.class.getName()).log(Level.SEVERE, null, ex); 117 | } 118 | } 119 | } 120 | } 121 | 122 | 123 | } 124 | -------------------------------------------------------------------------------- /istack-commons/runtime/src/main/java/com/sun/istack/localization/Localizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.localization; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.HashMap; 15 | import java.util.Locale; 16 | import java.util.MissingResourceException; 17 | import java.util.ResourceBundle; 18 | 19 | /** 20 | * Localizes the {@link Localizable} into a message 21 | * by using a configured {@link Locale}. 22 | * 23 | * @author WS Development Team 24 | */ 25 | public class Localizer { 26 | 27 | private final Locale _locale; 28 | private final HashMap _resourceBundles; 29 | 30 | public Localizer() { 31 | this(Locale.getDefault()); 32 | } 33 | 34 | public Localizer(Locale l) { 35 | _locale = l; 36 | _resourceBundles = new HashMap<>(); 37 | } 38 | 39 | public Locale getLocale() { 40 | return _locale; 41 | } 42 | 43 | public String localize(Localizable l) { 44 | String key = l.getKey(); 45 | if (key == Localizable.NOT_LOCALIZABLE) { 46 | // this message is not localizable 47 | return (String) l.getArguments()[0]; 48 | } 49 | 50 | String bundlename = l.getResourceBundleName(); 51 | 52 | try { 53 | ResourceBundle bundle = 54 | _resourceBundles.get(bundlename); 55 | 56 | if (bundle == null) { 57 | bundle = l.getResourceBundle(_locale); 58 | if (bundle != null) { 59 | _resourceBundles.put(bundlename, bundle); 60 | } 61 | } 62 | 63 | if (bundle == null) { 64 | try { 65 | bundle = ResourceBundle.getBundle(bundlename, _locale); 66 | } catch (MissingResourceException e) { 67 | // work around a bug in the com.sun.enterprise.deployment.WebBundleArchivist: 68 | // all files with an extension different from .class (hence all the .properties files) 69 | // get copied to the top level directory instead of being in the package where they 70 | // are defined 71 | // so, since we can't find the bundle under its proper name, we look for it under 72 | // the top-level package 73 | 74 | int i = bundlename.lastIndexOf('.'); 75 | if (i != -1) { 76 | String alternateBundleName = 77 | bundlename.substring(i + 1); 78 | try { 79 | bundle = 80 | ResourceBundle.getBundle( 81 | alternateBundleName, 82 | _locale); 83 | } catch (MissingResourceException e2) { 84 | //try context classloader 85 | try { 86 | bundle = ResourceBundle.getBundle(bundlename, _locale, Thread.currentThread().getContextClassLoader()); 87 | } catch (MissingResourceException e3) { 88 | // give up 89 | return getDefaultMessage(l); 90 | } 91 | 92 | } 93 | } 94 | } 95 | 96 | _resourceBundles.put(bundlename, bundle); 97 | } 98 | 99 | if (bundle == null) { 100 | return getDefaultMessage(l); 101 | } 102 | 103 | if (key == null) 104 | key = "undefined"; 105 | 106 | String msg; 107 | try { 108 | msg = bundle.getString(key); 109 | } catch (MissingResourceException e) { 110 | // notice that this may throw a MissingResourceException of its own (caught below) 111 | msg = bundle.getString("undefined"); 112 | } 113 | 114 | // localize all arguments to the given localizable object 115 | Object[] args = l.getArguments(); 116 | for (int i = 0; i < args.length; ++i) { 117 | if (args[i] instanceof Localizable) 118 | args[i] = localize((Localizable) args[i]); 119 | } 120 | 121 | return MessageFormat.format(msg, args); 122 | 123 | } catch (MissingResourceException e) { 124 | return getDefaultMessage(l); 125 | } 126 | 127 | } 128 | 129 | private String getDefaultMessage(Localizable l) { 130 | String key = l.getKey(); 131 | Object[] args = l.getArguments(); 132 | StringBuilder sb = new StringBuilder(); 133 | sb.append("[failed to localize] "); 134 | sb.append(key); 135 | if (args != null) { 136 | sb.append('('); 137 | for (int i = 0; i < args.length; ++i) { 138 | if (i != 0) 139 | sb.append(", "); 140 | sb.append(String.valueOf(args[i])); 141 | } 142 | sb.append(')'); 143 | } 144 | return sb.toString(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /istack-commons/tools/src/test/java/javax/xml/ws/XMLFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package javax.xml.ws; 12 | 13 | import java.io.InputStream; 14 | import java.io.Reader; 15 | import javax.xml.stream.EventFilter; 16 | import javax.xml.stream.StreamFilter; 17 | import javax.xml.stream.XMLEventReader; 18 | import javax.xml.stream.XMLInputFactory; 19 | import javax.xml.stream.XMLReporter; 20 | import javax.xml.stream.XMLResolver; 21 | import javax.xml.stream.XMLStreamException; 22 | import javax.xml.stream.XMLStreamReader; 23 | import javax.xml.stream.util.XMLEventAllocator; 24 | import javax.xml.transform.Source; 25 | 26 | /** 27 | * 28 | * @author lukas 29 | */ 30 | public class XMLFactory extends XMLInputFactory { 31 | 32 | public void test() { 33 | } 34 | 35 | @Override 36 | public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { 37 | throw new UnsupportedOperationException("Not supported yet."); 38 | } 39 | 40 | @Override 41 | public XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException { 42 | throw new UnsupportedOperationException("Not supported yet."); 43 | } 44 | 45 | @Override 46 | public XMLStreamReader createXMLStreamReader(InputStream stream) throws XMLStreamException { 47 | throw new UnsupportedOperationException("Not supported yet."); 48 | } 49 | 50 | @Override 51 | public XMLStreamReader createXMLStreamReader(InputStream stream, String encoding) throws XMLStreamException { 52 | throw new UnsupportedOperationException("Not supported yet."); 53 | } 54 | 55 | @Override 56 | public XMLStreamReader createXMLStreamReader(String systemId, InputStream stream) throws XMLStreamException { 57 | throw new UnsupportedOperationException("Not supported yet."); 58 | } 59 | 60 | @Override 61 | public XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException { 62 | throw new UnsupportedOperationException("Not supported yet."); 63 | } 64 | 65 | @Override 66 | public XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException { 67 | throw new UnsupportedOperationException("Not supported yet."); 68 | } 69 | 70 | @Override 71 | public XMLEventReader createXMLEventReader(String systemId, Reader reader) throws XMLStreamException { 72 | throw new UnsupportedOperationException("Not supported yet."); 73 | } 74 | 75 | @Override 76 | public XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException { 77 | throw new UnsupportedOperationException("Not supported yet."); 78 | } 79 | 80 | @Override 81 | public XMLEventReader createXMLEventReader(Source source) throws XMLStreamException { 82 | throw new UnsupportedOperationException("Not supported yet."); 83 | } 84 | 85 | @Override 86 | public XMLEventReader createXMLEventReader(InputStream stream) throws XMLStreamException { 87 | throw new UnsupportedOperationException("Not supported yet."); 88 | } 89 | 90 | @Override 91 | public XMLEventReader createXMLEventReader(InputStream stream, String encoding) throws XMLStreamException { 92 | throw new UnsupportedOperationException("Not supported yet."); 93 | } 94 | 95 | @Override 96 | public XMLEventReader createXMLEventReader(String systemId, InputStream stream) throws XMLStreamException { 97 | throw new UnsupportedOperationException("Not supported yet."); 98 | } 99 | 100 | @Override 101 | public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException { 102 | throw new UnsupportedOperationException("Not supported yet."); 103 | } 104 | 105 | @Override 106 | public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException { 107 | throw new UnsupportedOperationException("Not supported yet."); 108 | } 109 | 110 | @Override 111 | public XMLResolver getXMLResolver() { 112 | throw new UnsupportedOperationException("Not supported yet."); 113 | } 114 | 115 | @Override 116 | public void setXMLResolver(XMLResolver resolver) { 117 | } 118 | 119 | @Override 120 | public XMLReporter getXMLReporter() { 121 | throw new UnsupportedOperationException("Not supported yet."); 122 | } 123 | 124 | @Override 125 | public void setXMLReporter(XMLReporter reporter) { 126 | } 127 | 128 | @Override 129 | public void setProperty(String name, Object value) throws IllegalArgumentException { 130 | } 131 | 132 | @Override 133 | public Object getProperty(String name) throws IllegalArgumentException { 134 | throw new UnsupportedOperationException("Not supported yet."); 135 | } 136 | 137 | @Override 138 | public boolean isPropertySupported(String name) { 139 | throw new UnsupportedOperationException("Not supported yet."); 140 | } 141 | 142 | @Override 143 | public void setEventAllocator(XMLEventAllocator allocator) { 144 | } 145 | 146 | @Override 147 | public XMLEventAllocator getEventAllocator() { 148 | throw new UnsupportedOperationException("Not supported yet."); 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # Notices for Eclipse Implementation of JAXB 10 | 11 | This content is produced and maintained by the Eclipse Implementation of JAXB 12 | project. 13 | 14 | * Project home: https://projects.eclipse.org/projects/ee4j.jaxb-impl 15 | 16 | ## Trademarks 17 | 18 | Eclipse Implementation of JAXB is a trademark of the Eclipse Foundation. 19 | 20 | ## Copyright 21 | 22 | All content is the property of the respective authors or their employers. For 23 | more information regarding authorship of content, please consult the listed 24 | source code repository logs. 25 | 26 | ## Declared Project Licenses 27 | 28 | This program and the accompanying materials are made available under the terms 29 | of the Eclipse Distribution License v. 1.0 which is available at 30 | http://www.eclipse.org/org/documents/edl-v10.php. 31 | 32 | SPDX-License-Identifier: BSD-3-Clause 33 | 34 | ## Source Code 35 | 36 | The project maintains the following source code repositories: 37 | 38 | * https://github.com/eclipse-ee4j/jaxb-ri 39 | * https://github.com/eclipse-ee4j/jaxb-istack-commons 40 | * https://github.com/eclipse-ee4j/jaxb-dtd-parser 41 | * https://github.com/eclipse-ee4j/jaxb-fi 42 | * https://github.com/eclipse-ee4j/jaxb-stax-ex 43 | * https://github.com/eclipse-ee4j/jax-rpc-ri 44 | 45 | ## Third-party Content 46 | 47 | This project leverages the following third party content. 48 | 49 | Apache Ant (1.10.2) 50 | 51 | * License: Apache-2.0 AND W3C AND LicenseRef-Public-Domain 52 | 53 | Apache Ant (1.10.2) 54 | 55 | * License: Apache-2.0 AND W3C AND LicenseRef-Public-Domain 56 | 57 | Apache Felix (1.2.0) 58 | 59 | * License: Apache License, 2.0 60 | 61 | args4j (2.33) 62 | 63 | * License: MIT License 64 | 65 | dom4j (1.6.1) 66 | 67 | * License: Custom license based on Apache 1.1 68 | 69 | file-management (3.0.0) 70 | 71 | * License: Apache-2.0 72 | * Project: https://maven.apache.org/shared/file-management/ 73 | * Source: 74 | https://svn.apache.org/viewvc/maven/shared/tags/file-management-3.0.0/ 75 | 76 | JUnit (4.12) 77 | 78 | * License: Eclipse Public License 79 | 80 | JUnit (4.12) 81 | 82 | * License: Eclipse Public License 83 | 84 | maven-compat (3.5.2) 85 | 86 | * License: Apache-2.0 87 | * Project: https://maven.apache.org/ref/3.5.2/maven-compat/ 88 | * Source: 89 | https://mvnrepository.com/artifact/org.apache.maven/maven-compat/3.5.2 90 | 91 | maven-core (3.5.2) 92 | 93 | * License: Apache-2.0 94 | * Project: https://maven.apache.org/ref/3.5.2/maven-core/index.html 95 | * Source: https://mvnrepository.com/artifact/org.apache.maven/maven-core/3.5.2 96 | 97 | maven-plugin-annotations (3.5) 98 | 99 | * License: Apache-2.0 100 | * Project: https://maven.apache.org/plugin-tools/maven-plugin-annotations/ 101 | * Source: 102 | https://github.com/apache/maven-plugin-tools/tree/master/maven-plugin-annotations 103 | 104 | maven-plugin-api (3.5.2) 105 | 106 | * License: Apache-2.0 107 | 108 | maven-resolver-api (1.1.1) 109 | 110 | * License: Apache-2.0 111 | 112 | maven-resolver-api (1.1.1) 113 | 114 | * License: Apache-2.0 115 | 116 | maven-resolver-connector-basic (1.1.1) 117 | 118 | * License: Apache-2.0 119 | 120 | maven-resolver-impl (1.1.1) 121 | 122 | * License: Apache-2.0 123 | 124 | maven-resolver-spi (1.1.1) 125 | 126 | * License: Apache-2.0 127 | 128 | maven-resolver-transport-file (1.1.1) 129 | 130 | * License: Apache-2.0 131 | * Project: https://maven.apache.org/resolver/maven-resolver-transport-file/ 132 | * Source: 133 | https://github.com/apache/maven-resolver/tree/master/maven-resolver-transport-file 134 | 135 | maven-resolver-util (1.1.1) 136 | 137 | * License: Apache-2.0 138 | 139 | maven-settings (3.5.2) 140 | 141 | * License: Apache-2.0 142 | * Source: 143 | https://mvnrepository.com/artifact/org.apache.maven/maven-settings/3.5.2 144 | 145 | OSGi Service Platform Core Companion Code (6.0) 146 | 147 | * License: Apache License, 2.0 148 | 149 | plexus-archiver (3.5) 150 | 151 | * License: Apache-2.0 152 | * Project: https://codehaus-plexus.github.io/plexus-archiver/ 153 | * Source: https://github.com/codehaus-plexus/plexus-archiver 154 | 155 | plexus-io (3.0.0) 156 | 157 | * License: Apache-2.0 158 | 159 | plexus-utils (3.1.0) 160 | 161 | * License: Apache- 2.0 or Apache- 1.1 or BSD or Public Domain or Indiana 162 | University Extreme! Lab Software License V1.1.1 (Apache 1.1 style) 163 | 164 | relaxng-datatype (1.0) 165 | 166 | * License: New BSD license 167 | 168 | Sax (0.2) 169 | 170 | * License: SAX-PD 171 | * Project: http://www.megginson.com/downloads/SAX/ 172 | * Source: http://sourceforge.net/project/showfiles.php?group_id=29449 173 | 174 | testng (6.14.2) 175 | 176 | * License: Apache-2.0 AND (MIT OR GPL-1.0+) 177 | * Project: https://testng.org/doc/index.html 178 | * Source: https://github.com/cbeust/testng 179 | 180 | wagon-http-lightweight (3.0.0) 181 | 182 | * License: Pending 183 | * Project: https://maven.apache.org/wagon/ 184 | * Source: 185 | https://mvnrepository.com/artifact/org.apache.maven.wagon/wagon-http-lightweight/3.0.0 186 | 187 | xz for java (1.8) 188 | 189 | * License: LicenseRef-Public-Domain 190 | 191 | ## Cryptography 192 | 193 | Content may contain encryption software. The country in which you are currently 194 | may have restrictions on the import, possession, and use, and/or re-export to 195 | another country, of encryption software. BEFORE using any encryption software, 196 | please check the country's laws, regulations and policies concerning the import, 197 | possession, or use, and re-export of encryption software, to see if this is 198 | permitted. 199 | -------------------------------------------------------------------------------- /istack-commons/test/src/main/java/com/sun/istack/test/AntXmlFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.test; 12 | 13 | import junit.framework.AssertionFailedError; 14 | import junit.framework.Test; 15 | import junit.framework.TestListener; 16 | import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter; 17 | import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; 18 | import org.apache.tools.ant.taskdefs.optional.junit.JUnitVersionHelper; 19 | 20 | import java.io.ByteArrayOutputStream; 21 | import java.io.Closeable; 22 | import java.io.File; 23 | import java.io.FileNotFoundException; 24 | import java.io.FileOutputStream; 25 | import java.io.IOException; 26 | import java.io.PrintStream; 27 | import java.util.logging.Level; 28 | import java.util.logging.Logger; 29 | 30 | /** 31 | * {@link TestListener} that bridges to {@link JUnitResultFormatter}. 32 | * 33 | * @author Kohsuke Kawaguchi 34 | */ 35 | public class AntXmlFormatter implements TestListener,Closeable { 36 | private JUnitResultFormatter antf; 37 | private JUnitTest antTest; // Ant wants this 38 | private final Class formatter; 39 | private long startTime; 40 | 41 | private final File dir; 42 | 43 | FileOutputStream outStream = null; 44 | 45 | /** 46 | * Stdout, stderr that were replaced. Kept so that we can restore them in {@link #close()}. 47 | */ 48 | private final PrintStream out,err; 49 | 50 | private final ByteArrayOutputStream outBuf = new ByteArrayOutputStream(); 51 | private final ByteArrayOutputStream errBuf = new ByteArrayOutputStream(); 52 | 53 | private int id = 0; 54 | 55 | public AntXmlFormatter(Class formatter, File dir) { 56 | this.formatter = formatter; 57 | this.dir = dir; 58 | 59 | out = System.out; 60 | err = System.err; 61 | System.setOut(new PrintStream(new ForkOutputStream(outBuf,out))); 62 | System.setErr(new PrintStream(new ForkOutputStream(errBuf,err))); 63 | } 64 | 65 | @Override 66 | public void close() { 67 | // restore 68 | System.setOut(out); 69 | System.setErr(err); 70 | } 71 | 72 | public void addError(Test test, Throwable t) { 73 | antf.addError(test,t); 74 | antTest.setCounts(1,0,1); 75 | } 76 | 77 | public void addFailure(Test test, AssertionFailedError t) { 78 | antf.addFailure(test,t); 79 | antTest.setCounts(1,1,0); 80 | } 81 | 82 | public void startTest(Test test) { 83 | assert antf==null; 84 | try { 85 | antf = formatter.getConstructor().newInstance(); 86 | } catch (IllegalAccessException e) { 87 | throw new IllegalAccessError(e.getMessage()); 88 | } catch (ReflectiveOperationException e) { 89 | throw new InstantiationError(e.getMessage()); 90 | } 91 | 92 | String testName = getTestName(test); 93 | 94 | antTest = new JUnitTest(testName); 95 | antTest.setCounts(1,0,0); 96 | try { 97 | outStream = new FileOutputStream(new File(dir,getResultFileName(testName))); 98 | antf.setOutput(outStream); 99 | } catch (FileNotFoundException e) { 100 | throw new Error(e); 101 | } 102 | antf.startTestSuite(antTest); 103 | antf.startTest(test); 104 | outBuf.reset(); 105 | errBuf.reset(); 106 | startTime = System.currentTimeMillis(); 107 | } 108 | 109 | private String getTestName(Test test) { 110 | String testName = JUnitVersionHelper.getTestCaseName(test); 111 | if(testName==null) testName="unknown"; 112 | 113 | // if you extend from junit.framework.TestCase where you have public testXXX methods, 114 | // those test names are just the method name, and doesn't include the package name. 115 | // this doesn't work well with our harness, which uses the fully-qualified name as the 116 | // test names. To bridge this gap, detect the plain TestCase classes and fix up 117 | // the package name. 118 | if(testName.indexOf('.')==-1) 119 | testName = test.getClass().getPackage().getName()+"."+testName; 120 | 121 | return testName; 122 | } 123 | 124 | private String getResultFileName(String testName) { 125 | // try to use a test name. 126 | StringBuilder sb = new StringBuilder(testName); 127 | if(sb.length()>70) 128 | sb.delete(0,sb.length()-70); // remove any portion longer than 70 to avoid file names that are too long 129 | 130 | for(int i=0; i driver = (Class) cl.loadClass(getCoreClassName()); 63 | 64 | Task t = driver.getDeclaredConstructor().newInstance(); 65 | t.setProject(getProject()); 66 | t.setTaskName(getTaskName()); 67 | root.configure(t); 68 | 69 | Thread.currentThread().setContextClassLoader(cl); 70 | try { 71 | t.execute(); 72 | } finally { 73 | driver = null; 74 | t.setTaskName(null); 75 | t.setProject(null); 76 | t = null; 77 | } 78 | } catch (UnsupportedClassVersionError e) { 79 | throw new BuildException("Requires Java SE 8 or later. Please download it from https://www.oracle.com/java/technologies/javase-download.html"); 80 | } catch (ReflectiveOperationException | IOException e) { 81 | throw new BuildException(e); 82 | } finally { 83 | ClassLoader cl = Thread.currentThread().getContextClassLoader(); 84 | Thread.currentThread().setContextClassLoader(ccl); 85 | 86 | //close/cleanup all classloaders but the one which loaded this class 87 | while (cl != null && !ccl.equals(cl)) { 88 | try { 89 | ((Closeable) cl).close(); 90 | } catch (IOException ex) { 91 | throw new BuildException(ex); 92 | } 93 | cl = getParentClassLoader(cl); 94 | } 95 | cl = null; 96 | } 97 | } 98 | 99 | /** 100 | * Returns the name of the class that extends {@link Task}.This class will 101 | * be loaded int the protected classloader. 102 | * @return Task class name 103 | */ 104 | protected abstract String getCoreClassName(); 105 | 106 | /** 107 | * Creates a protective class loader that will host the actual task. 108 | * @return ClassLoader use d for task execution 109 | * @throws java.lang.ClassNotFoundException if required APIs are not found 110 | * @throws java.io.IOException if error happens 111 | */ 112 | protected abstract ClassLoader createClassLoader() throws ClassNotFoundException, IOException; 113 | 114 | private ClassLoader getParentClassLoader(final ClassLoader cl) { 115 | //Calling getParent() on AntClassLoader doesn't return the - expected - 116 | //actual parent classloader but always the SystemClassLoader. 117 | if (cl instanceof AntClassLoader) { 118 | //1.8 added getConfiguredParent() to get correct 'parent' classloader 119 | ClassLoader loader = ((AntClassLoader) cl).getConfiguredParent(); 120 | // we may be called by Gradle, in such case do not close its classloader, 121 | // so Gradle can handle it itself and return null here; 122 | // in other cases return parent or null if not found 123 | return loader == null ? null 124 | : loader.getClass().getName().startsWith("org.gradle.") ? null : loader; 125 | } 126 | return cl.getParent(); 127 | } 128 | 129 | /** 130 | * Captures the elements and attributes. 131 | */ 132 | private class AntElement implements DynamicConfigurator { 133 | 134 | private final String name; 135 | 136 | private final Map attributes = new HashMap<>(); 137 | 138 | private final List elements = new ArrayList<>(); 139 | 140 | public AntElement(String name) { 141 | this.name = name; 142 | } 143 | 144 | @Override 145 | public void setDynamicAttribute(String name, String value) throws BuildException { 146 | attributes.put(name, value); 147 | } 148 | 149 | @Override 150 | public Object createDynamicElement(String name) throws BuildException { 151 | AntElement e = new AntElement(name); 152 | elements.add(e); 153 | return e; 154 | } 155 | 156 | /** 157 | * Copies the properties into the Ant task. 158 | */ 159 | public void configure(Object antObject) { 160 | IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); 161 | 162 | // set attributes first 163 | for (Entry att : attributes.entrySet()) { 164 | ih.setAttribute(getProject(), antObject, att.getKey(), att.getValue()); 165 | } 166 | 167 | // then nested elements 168 | for (AntElement e : elements) { 169 | Object child = ih.getElementCreator(getProject(), "", antObject, e.name, null).create(); 170 | e.configure(child); 171 | ih.storeElement(getProject(), antObject, child, e.name); 172 | } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/src/main/java/com/sun/istack/maven/MetainfServicesCompilerMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.maven; 12 | 13 | import org.apache.maven.plugin.AbstractMojo; 14 | import org.apache.maven.plugin.MojoExecutionException; 15 | import org.apache.maven.plugins.annotations.LifecyclePhase; 16 | import org.apache.maven.plugins.annotations.Mojo; 17 | import org.eclipse.aether.RepositorySystemSession; 18 | import org.eclipse.aether.artifact.Artifact; 19 | import org.eclipse.aether.artifact.DefaultArtifact; 20 | import org.eclipse.aether.impl.ArtifactResolver; 21 | import org.eclipse.aether.repository.RemoteRepository; 22 | import org.eclipse.aether.resolution.ArtifactRequest; 23 | import org.eclipse.aether.resolution.ArtifactResolutionException; 24 | 25 | import java.io.BufferedReader; 26 | import java.io.File; 27 | import java.io.IOException; 28 | import java.io.InputStream; 29 | import java.io.InputStreamReader; 30 | import java.io.PrintWriter; 31 | import java.util.List; 32 | import java.util.logging.Level; 33 | import java.util.logging.Logger; 34 | import java.util.zip.ZipEntry; 35 | import java.util.zip.ZipFile; 36 | 37 | /** 38 | * Goal which compiles META-INF/services files from various dependencies 39 | * 40 | * @author japod 41 | * 42 | * Goal: metainf-services 43 | * 44 | * Phase: generate-sources 45 | */ 46 | @Mojo(name = "metainf-services", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) 47 | public class MetainfServicesCompilerMojo extends AbstractMojo { 48 | 49 | /** 50 | * Collection of ArtifactItems to take the META-INF/services from. (ArtifactItem contains groupId, 51 | * artifactId, version) 52 | * 53 | * parameter 54 | * required 55 | * @since 1.0 56 | */ 57 | private List artifactItems; 58 | /** 59 | * Collection of files from META-INF/services to compile 60 | * 61 | * parameter 62 | * required 63 | * @since 1.0 64 | */ 65 | private List providers; 66 | /** 67 | * Destination for the generated service registry files 68 | * 69 | * parameter 70 | * required 71 | * @since 1.0 72 | */ 73 | private File destDir; 74 | 75 | /** 76 | * component role="org.apache.maven.artifact.resolver.ArtifactResolver" 77 | * required 78 | * readonly 79 | */ 80 | protected ArtifactResolver artifactResolver; 81 | /** 82 | * parameter expression="${project.remoteArtifactRepositories}" 83 | * readonly 84 | * required 85 | */ 86 | protected List remoteRepositories; 87 | 88 | /** 89 | * The current repository/network configuration of Maven. 90 | * 91 | * parameter default-value="${repositorySystemSession}" 92 | * readonly 93 | */ 94 | private RepositorySystemSession repoSession; 95 | 96 | @Override 97 | public void execute() throws MojoExecutionException { 98 | getLog().info("About to compile META-INF/services files"); 99 | getLog().info("Artifact Items = " + artifactItems); 100 | getLog().info("SPIs = " + providers); 101 | getLog().info("dest dir = " + destDir); 102 | File msDir = new File(destDir, "META-INF/services"); 103 | boolean created =msDir.mkdirs(); 104 | if (!created) { 105 | Logger.getLogger(MetainfServicesCompilerMojo.class.getName()).log(Level.FINE, "Cannot create directory: {0}", msDir); 106 | } 107 | for (String spi : providers) { 108 | PrintWriter registryWriter = null; 109 | try { 110 | File spiRegistry = new File(msDir, spi); 111 | if (spiRegistry.exists()) { 112 | boolean deleted = spiRegistry.delete(); 113 | if (!deleted) { 114 | Logger.getLogger(MetainfServicesCompilerMojo.class.getName()).log(Level.FINE, "Cannot delete file: {0}", spiRegistry); 115 | } 116 | } 117 | created = spiRegistry.createNewFile(); 118 | if (!created) { 119 | Logger.getLogger(MetainfServicesCompilerMojo.class.getName()).log(Level.FINE, "Cannot create file: {0}", spiRegistry); 120 | } 121 | registryWriter = new PrintWriter(spiRegistry); 122 | ZipFile zipFile = null; 123 | try { 124 | BufferedReader reader = null; 125 | InputStreamReader isReader = null; 126 | for (ArtifactItem ai : artifactItems) { 127 | Artifact artifact; 128 | artifact = new DefaultArtifact(ai.getGroupId(), ai.getArtifactId(), null, ai.getVersion()); 129 | // artifact = artifactFactory.createExtensionArtifact(ai.getGroupId(), ai.getArtifactId(), VersionRange.createFromVersion(ai.getVersion())); 130 | 131 | ArtifactRequest request = new ArtifactRequest(); 132 | request.setArtifact( artifact ); 133 | request.setRepositories(remoteRepositories); 134 | artifactResolver.resolveArtifact(repoSession, request); 135 | zipFile = new ZipFile(artifact.getFile()); 136 | final ZipEntry servicesEntry = zipFile.getEntry("META-INF/services/" + spi); 137 | if (servicesEntry != null) { 138 | try { 139 | final InputStream inputStream = zipFile.getInputStream(servicesEntry); 140 | isReader = new InputStreamReader(inputStream); 141 | reader = new BufferedReader(isReader); 142 | while (reader.ready()) { 143 | registryWriter.println(reader.readLine()); 144 | } 145 | } finally { 146 | if (reader != null) { 147 | reader.close(); 148 | } 149 | if (isReader != null) { 150 | isReader.close(); 151 | } 152 | } 153 | } 154 | } 155 | } catch (ArtifactResolutionException ex) { 156 | Logger.getLogger(MetainfServicesCompilerMojo.class.getName()).log(Level.SEVERE, null, ex); 157 | throw new MojoExecutionException("Can not resolve artifact!", ex); 158 | } finally { 159 | if (zipFile != null) { 160 | zipFile.close(); 161 | } 162 | } 163 | } catch (IOException ex) { 164 | throw new MojoExecutionException("Can not create spi registry file!", ex); 165 | } finally { 166 | if (registryWriter != null) { 167 | registryWriter.close(); 168 | } 169 | } 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /istack-commons/import-properties-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | istack-commons 17 | com.sun.istack 18 | 4.2.1-SNAPSHOT 19 | ../pom.xml 20 | 21 | 22 | 4.0.0 23 | com.sun.istack 24 | import-properties-plugin 25 | maven-plugin 26 | istack common import properties plugin 27 | 28 | 29 | 3.0 30 | 31 | 32 | 33 | ${project.basedir}/exclude.xml 34 | 35 | 36 | 37 | 38 | org.apache.maven 39 | maven-plugin-api 40 | provided 41 | 42 | 43 | org.apache.maven 44 | maven-core 45 | provided 46 | 47 | 48 | org.codehaus.plexus 49 | plexus-utils 50 | 51 | 52 | org.apache.maven.plugin-tools 53 | maven-plugin-annotations 54 | provided 55 | 56 | 57 | org.apache.maven.resolver 58 | maven-resolver-api 59 | 60 | 61 | org.apache.maven 62 | maven-model 63 | provided 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-plugin-plugin 72 | 73 | 74 | mojo-descriptor 75 | 76 | descriptor 77 | helpmojo 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | ittest 88 | 89 | 90 | ittest 91 | true 92 | 93 | 94 | 95 | 96 | 97 | org.codehaus.gmaven 98 | gmaven-plugin 99 | 100 | 101 | set-proxy 102 | pre-integration-test 103 | 104 | execute 105 | 106 | 107 | ${project.basedir}/src/test/script/setproxy.groovy 108 | 109 | 110 | 111 | 112 | 113 | org.apache.maven.plugins 114 | maven-invoker-plugin 115 | 116 | ${project.build.directory}/it-repo 117 | true 118 | true 119 | ${project.build.directory}/it-settings.xml 120 | ${ittest-proxy} 121 | 122 | ${project.version} 123 | 124 | 125 | 126 | 127 | integration-test-installdeps 128 | pre-integration-test 129 | 130 | install 131 | 132 | 133 | 134 | integration-test 135 | 136 | run 137 | 138 | 139 | src/test/it 140 | ${project.build.directory}/it 141 | 142 | 143 | 144 | 145 | 146 | org.apache.maven.plugins 147 | maven-failsafe-plugin 148 | 149 | 150 | integration-test-verify 151 | post-integration-test 152 | 153 | integration-test 154 | verify 155 | 156 | 157 | 158 | ${project.build.directory}/it 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /istack-commons/tools/src/main/java/com/sun/istack/tools/ParallelWorldClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.tools; 12 | 13 | import java.io.InputStream; 14 | import java.io.ByteArrayOutputStream; 15 | import java.io.Closeable; 16 | import java.io.File; 17 | import java.io.IOException; 18 | import java.net.JarURLConnection; 19 | import java.net.URISyntaxException; 20 | import java.net.URL; 21 | import java.net.MalformedURLException; 22 | import java.net.URLConnection; 23 | import java.util.Collections; 24 | import java.util.Enumeration; 25 | import java.util.HashSet; 26 | import java.util.Set; 27 | import java.util.jar.JarFile; 28 | import java.util.logging.Level; 29 | import java.util.logging.Logger; 30 | 31 | /** 32 | * Load classes/resources from a side folder, so that 33 | * classes of the same package can live in a single jar file. 34 | * 35 | *

36 | * For example, with the following jar file: 37 | *

 38 |  *  /
 39 |  *  +- foo
 40 |  *     +- X.class
 41 |  *  +- bar
 42 |  *     +- X.class
 43 |  * 
44 | *

45 | * {@link ParallelWorldClassLoader}("foo/") would load {@code X.class} from 46 | * {@code /foo/X.class} (note that X is defined in the root package, not 47 | * {@code foo.X}. 48 | * 49 | *

50 | * This can be combined with {@link MaskingClassLoader} to mask classes which are loaded by the parent 51 | * class loader so that the child class loader 52 | * classes living in different folders are loaded 53 | * before the parent class loader loads classes living the jar file publicly 54 | * visible 55 | * For example, with the following jar file: 56 | *

 57 |  *  /
 58 |  *  +- foo
 59 |  *     +- X.class
 60 |  *  +- bar
 61 |  *     +-foo
 62 |  *        +- X.class
 63 |  * 
64 | *

65 | * {@link ParallelWorldClassLoader}(MaskingClassLoader.class.getClassLoader()) 66 | * would load {@code foo.X.class} from 67 | * {@code /bar/foo.X.class} not the {@code foo.X.class} 68 | * in the publicly visible place in the jar file, thus 69 | * masking the parent classLoader from loading the class from {@code foo.X.class} 70 | * (note that X is defined in the package foo, not 71 | * {@code bar.foo.X}. 72 | * 73 | * @author Kohsuke Kawaguchi 74 | */ 75 | public class ParallelWorldClassLoader extends ClassLoader implements Closeable { 76 | 77 | /** 78 | * Strings like "prefix/", "abc/", or "" to indicate 79 | * classes should be loaded normally. 80 | */ 81 | private final String prefix; 82 | private final Set jars; 83 | 84 | public ParallelWorldClassLoader(ClassLoader parent,String prefix) { 85 | super(parent); 86 | this.prefix = prefix; 87 | jars = Collections.synchronizedSet(new HashSet<>()); 88 | } 89 | 90 | @Override 91 | protected Class findClass(String name) throws ClassNotFoundException { 92 | 93 | StringBuilder sb = new StringBuilder(name.length()+prefix.length()+6); 94 | sb.append(prefix).append(name.replace('.','/')).append(".class"); 95 | 96 | URL u = getParent().getResource(sb.toString()); 97 | if (u == null) { 98 | throw new ClassNotFoundException(name); 99 | } 100 | 101 | InputStream is = null; 102 | URLConnection con = null; 103 | 104 | try { 105 | con = u.openConnection(); 106 | is = con.getInputStream(); 107 | } catch (IOException ioe) { 108 | throw new ClassNotFoundException(name); 109 | } 110 | 111 | if (is==null) 112 | throw new ClassNotFoundException(name); 113 | 114 | try { 115 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 116 | byte[] buf = new byte[1024]; 117 | int len; 118 | while((len=is.read(buf))>=0) 119 | baos.write(buf,0,len); 120 | 121 | buf = baos.toByteArray(); 122 | int packIndex = name.lastIndexOf('.'); 123 | if (packIndex != -1) { 124 | String pkgname = name.substring(0, packIndex); 125 | // Check if package already loaded. 126 | Package pkg = getDefinedPackage(pkgname); 127 | if (pkg == null) { 128 | definePackage(pkgname, null, null, null, null, null, null, null); 129 | } 130 | } 131 | return defineClass(name,buf,0,buf.length); 132 | } catch (IOException e) { 133 | throw new ClassNotFoundException(name,e); 134 | } finally { 135 | try { 136 | if (con instanceof JarURLConnection) { 137 | jars.add(((JarURLConnection) con).getJarFile()); 138 | } 139 | } catch (IOException ioe) { 140 | //ignore 141 | } 142 | try { 143 | is.close(); 144 | } catch (IOException ioe) { 145 | //ignore 146 | } 147 | } 148 | } 149 | 150 | @Override 151 | protected URL findResource(String name) { 152 | URL u = getParent().getResource(prefix + name); 153 | if (u != null) { 154 | try { 155 | jars.add(new JarFile(new File(toJarUrl(u).toURI()))); 156 | } catch (URISyntaxException | IOException ex) { 157 | Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); 158 | } catch (ClassNotFoundException ex) { 159 | //ignore - not a jar 160 | } 161 | } 162 | return u; 163 | } 164 | 165 | @Override 166 | protected Enumeration findResources(String name) throws IOException { 167 | Enumeration en = getParent().getResources(prefix + name); 168 | while (en.hasMoreElements()) { 169 | try { 170 | jars.add(new JarFile(new File(toJarUrl(en.nextElement()).toURI()))); 171 | } catch (URISyntaxException | IOException ex) { 172 | //should not happen 173 | Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); 174 | } catch (ClassNotFoundException ex) { 175 | //ignore - not a jar 176 | } 177 | } 178 | return en; 179 | } 180 | 181 | @Override 182 | public synchronized void close() throws IOException { 183 | for (JarFile jar : jars) { 184 | jar.close(); 185 | } 186 | } 187 | 188 | /** 189 | * Given the URL inside jar, returns the URL to the jar itself. 190 | * @param res Resource in a jar 191 | * @return URL to the conaining jar file 192 | * @throws java.lang.ClassNotFoundException if res does not denote jar URL 193 | * @throws java.net.MalformedURLException if computed URL is invalid 194 | */ 195 | public static URL toJarUrl(URL res) throws ClassNotFoundException, MalformedURLException { 196 | String url = res.toExternalForm(); 197 | if(!url.startsWith("jar:")) 198 | throw new ClassNotFoundException("Loaded outside a jar "+url); 199 | url = url.substring(4); // cut off jar: 200 | url = url.substring(0,url.lastIndexOf('!')); // cut off everything after '!' 201 | url = url.replaceAll(" ", "%20"); // support white spaces in path 202 | return new URL(url); 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /istack-commons/maven-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | istack-commons 17 | com.sun.istack 18 | 4.2.1-SNAPSHOT 19 | ../pom.xml 20 | 21 | 4.0.0 22 | com.sun.istack 23 | istack-commons-maven-plugin 24 | maven-plugin 25 | istack common maven mojo 26 | 27 | 28 | 29 | org.apache.maven 30 | maven-plugin-api 31 | provided 32 | 33 | 34 | org.apache.maven.resolver 35 | maven-resolver-api 36 | 37 | 38 | org.apache.maven.resolver 39 | maven-resolver-impl 40 | 41 | 42 | org.apache.maven 43 | maven-artifact 44 | provided 45 | 46 | 47 | org.apache.maven.plugin-tools 48 | maven-plugin-annotations 49 | provided 50 | 51 | 52 | junit 53 | junit 54 | 55 | 56 | org.apache.maven 57 | maven-core 58 | provided 59 | 60 | 61 | org.glassfish.jaxb 62 | codemodel 63 | 64 | 65 | 66 | 67 | 68 | ittest 69 | 70 | 71 | ittest 72 | true 73 | 74 | 75 | 76 | 77 | 78 | org.codehaus.gmaven 79 | gmaven-plugin 80 | 81 | 82 | set-proxy 83 | pre-integration-test 84 | 85 | execute 86 | 87 | 88 | ${project.basedir}/src/test/script/setproxy.groovy 89 | 90 | 91 | 92 | 93 | 94 | org.apache.maven.plugins 95 | maven-invoker-plugin 96 | 97 | ${project.build.directory}/it-repo 98 | true 99 | true 100 | ${project.build.directory}/it-settings.xml 101 | ${ittest-proxy} 102 | 103 | ${project.version} 104 | ${maven.compiler.release} 105 | 106 | 107 | 108 | 109 | integration-test-installdeps 110 | pre-integration-test 111 | 112 | install 113 | 114 | 115 | 116 | integration-test 117 | 118 | run 119 | 120 | 121 | src/test/it 122 | ${project.build.directory}/it 123 | 124 | 125 | 126 | 127 | 128 | org.apache.maven.plugins 129 | maven-failsafe-plugin 130 | 131 | 132 | integration-test-verify 133 | post-integration-test 134 | 135 | integration-test 136 | verify 137 | 138 | 139 | 140 | ${project.build.directory}/it 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | org.apache.maven.plugins 155 | maven-plugin-plugin 156 | 157 | 158 | descriptors 159 | 160 | descriptor 161 | helpmojo 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /istack-commons/tools/src/test/java/com/sun/istack/tools/DefaultAuthenticatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.tools; 12 | 13 | import java.io.File; 14 | import java.lang.reflect.Field; 15 | import java.net.Authenticator; 16 | import java.net.MalformedURLException; 17 | import java.net.PasswordAuthentication; 18 | import java.net.URL; 19 | import java.util.Arrays; 20 | import java.util.logging.Level; 21 | import java.util.logging.Logger; 22 | import static org.testng.Assert.*; 23 | import org.testng.annotations.AfterMethod; 24 | import org.testng.annotations.Test; 25 | 26 | /** 27 | * @author Rama Pulavarthi 28 | * @author Lukas Jungmann 29 | */ 30 | public class DefaultAuthenticatorTest { 31 | 32 | private static final Logger logger = Logger.getLogger(DefaultAuthenticatorTest.class.getName()); 33 | 34 | public DefaultAuthenticatorTest() { 35 | } 36 | 37 | private static class MyAuthenticator extends DefaultAuthenticator { 38 | 39 | private String requestingURL; 40 | 41 | @Override 42 | protected URL getRequestingURL() { 43 | try { 44 | return new URL(requestingURL); 45 | } catch (MalformedURLException e) { 46 | logger.log(Level.SEVERE, null, e); 47 | } 48 | return null; 49 | } 50 | 51 | void setRequestingURL(String url) { 52 | requestingURL = url; 53 | } 54 | } 55 | 56 | @AfterMethod 57 | public void after() { 58 | clearTestAuthenticator(); 59 | } 60 | 61 | @Test 62 | public void testDefaultAuth() throws Exception { 63 | URL url = getResourceAsUrl("com/sun/istack/tools/.auth"); 64 | MyAuthenticator ma = createTestAuthenticator(); 65 | ma.setRequestingURL("http://foo.com/myservice?wsdl"); 66 | assertNull(DefaultAuthenticator.getCurrentAuthenticator()); 67 | assertEquals(0, getCounter()); 68 | try { 69 | DefaultAuthenticator da = DefaultAuthenticator.getAuthenticator(); 70 | assertEquals(ma, da); 71 | assertEquals(1, getCounter()); 72 | da.setAuth(new File(url.toURI()), null); 73 | PasswordAuthentication pa = da.getPasswordAuthentication(); 74 | assertTrue(pa != null && pa.getUserName().equals("duke") && Arrays.equals(pa.getPassword(), "test".toCharArray())); 75 | } finally { 76 | DefaultAuthenticator.reset(); 77 | assertNotEquals(ma, DefaultAuthenticator.getCurrentAuthenticator()); 78 | assertEquals(0, getCounter()); 79 | } 80 | } 81 | 82 | @Test 83 | public void testGetDefaultAuth() { 84 | Authenticator orig = DefaultAuthenticator.getCurrentAuthenticator(); 85 | try { 86 | DefaultAuthenticator da = DefaultAuthenticator.getAuthenticator(); 87 | assertNotEquals(orig, da); 88 | assertEquals(1, getCounter()); 89 | Authenticator auth = DefaultAuthenticator.getCurrentAuthenticator(); 90 | assertNotNull(auth); 91 | assertEquals(da, auth); 92 | } finally { 93 | DefaultAuthenticator.reset(); 94 | assertEquals(orig, DefaultAuthenticator.getCurrentAuthenticator()); 95 | assertEquals(0, getCounter()); 96 | } 97 | } 98 | 99 | @Test 100 | public void testJaxWs_1101() throws Exception { 101 | URL url = getResourceAsUrl("com/sun/istack/tools/auth_test.resource"); 102 | MyAuthenticator ma = createTestAuthenticator(); 103 | 104 | try { 105 | DefaultAuthenticator da = DefaultAuthenticator.getAuthenticator(); 106 | assertEquals(1, getCounter()); 107 | assertEquals(ma, da); 108 | da.setAuth(new File(url.toURI()), null); 109 | 110 | ma.setRequestingURL("http://server1.myserver.com/MyService/Service.svc?wsdl"); 111 | PasswordAuthentication pa = da.getPasswordAuthentication(); 112 | assertEquals("user", pa.getUserName()); 113 | assertEquals(")/_@B8M)gDw", new String(pa.getPassword())); 114 | 115 | ma.setRequestingURL("http://server1.myserver.com/MyService/Service.svc?xsd=xsd0"); 116 | pa = da.getPasswordAuthentication(); 117 | assertEquals("user", pa.getUserName()); 118 | assertEquals(")/_@B8M)gDw", new String(pa.getPassword())); 119 | 120 | ma.setRequestingURL("http://server1.myserver.com/MyService/Service.svc"); 121 | pa = da.getPasswordAuthentication(); 122 | assertEquals("user", pa.getUserName()); 123 | assertEquals(")/_@B8M)gDw", new String(pa.getPassword())); 124 | 125 | ma.setRequestingURL("http://server1.myserver.com/encoded/MyService/Service.svc?wsdl"); 126 | pa = da.getPasswordAuthentication(); 127 | assertEquals("user2", pa.getUserName()); 128 | assertEquals(")/_@B8M)gDw", new String(pa.getPassword())); 129 | } finally { 130 | DefaultAuthenticator.reset(); 131 | assertEquals(0, getCounter()); 132 | } 133 | } 134 | 135 | private static URL getResourceAsUrl(String resourceName) throws RuntimeException { 136 | URL input = Thread.currentThread().getContextClassLoader().getResource(resourceName); 137 | if (input == null) { 138 | throw new RuntimeException("Failed to find resource \"" + resourceName + "\""); 139 | } 140 | return input; 141 | } 142 | 143 | private MyAuthenticator createTestAuthenticator() { 144 | Field f1 = null; 145 | try { 146 | f1 = DefaultAuthenticator.class.getDeclaredField("instance"); 147 | f1.setAccessible(true); 148 | MyAuthenticator auth = new MyAuthenticator(); 149 | f1.set(null, auth); 150 | return auth; 151 | } catch (Exception ex) { 152 | logger.log(Level.SEVERE, null, ex); 153 | } finally { 154 | if (f1 != null) { 155 | f1.setAccessible(false); 156 | } 157 | } 158 | return null; 159 | } 160 | 161 | private void clearTestAuthenticator() { 162 | Field f1, f2 = f1 = null; 163 | try { 164 | f1 = DefaultAuthenticator.class.getDeclaredField("instance"); 165 | f1.setAccessible(true); 166 | MyAuthenticator auth = new MyAuthenticator(); 167 | f1.set(null, null); 168 | f2 = DefaultAuthenticator.class.getDeclaredField("counter"); 169 | f2.setAccessible(true); 170 | f2.setInt(null, 0); 171 | } catch (Exception ex) { 172 | logger.log(Level.SEVERE, null, ex); 173 | } finally { 174 | if (f1 != null) { 175 | f1.setAccessible(false); 176 | } 177 | if (f2 != null) { 178 | f2.setAccessible(false); 179 | } 180 | } 181 | } 182 | 183 | private int getCounter() { 184 | Field f = null; 185 | try { 186 | f = DefaultAuthenticator.class.getDeclaredField("counter"); 187 | f.setAccessible(true); 188 | return f.getInt(null); 189 | } catch (Exception ex) { 190 | logger.log(Level.SEVERE, null, ex); 191 | } finally { 192 | if (f != null) { 193 | f.setAccessible(false); 194 | } 195 | } 196 | return -1; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /istack-commons/tools/src/main/java/com/sun/istack/tools/DefaultAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.tools; 12 | 13 | import org.xml.sax.Locator; 14 | import org.xml.sax.helpers.LocatorImpl; 15 | 16 | import java.io.BufferedReader; 17 | import java.io.File; 18 | import java.io.FileInputStream; 19 | import java.io.FileNotFoundException; 20 | import java.io.IOException; 21 | import java.io.InputStreamReader; 22 | import java.net.Authenticator; 23 | import java.net.MalformedURLException; 24 | import java.net.PasswordAuthentication; 25 | import java.net.URL; 26 | import java.net.URLDecoder; 27 | import java.net.URLEncoder; 28 | import java.nio.charset.StandardCharsets; 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | import java.util.logging.Level; 32 | import java.util.logging.Logger; 33 | import java.util.regex.Pattern; 34 | 35 | /** 36 | * @author Vivek Pandey 37 | * @author Lukas Jungmann 38 | */ 39 | public class DefaultAuthenticator extends Authenticator { 40 | 41 | private static final Logger LOGGER = Logger.getLogger(DefaultAuthenticator.class.getName()); 42 | private static DefaultAuthenticator instance; 43 | private static Authenticator systemAuthenticator = getCurrentAuthenticator(); 44 | private String proxyUser; 45 | private String proxyPasswd; 46 | private final List authInfo = new ArrayList<>(); 47 | private static int counter = 0; 48 | 49 | DefaultAuthenticator() { 50 | //try undocumented but often used properties 51 | if (System.getProperty("http.proxyUser") != null) { 52 | proxyUser = System.getProperty("http.proxyUser"); 53 | } else { 54 | proxyUser = System.getProperty("proxyUser"); 55 | } 56 | if (System.getProperty("http.proxyPassword") != null) { 57 | proxyPasswd = System.getProperty("http.proxyPassword"); 58 | } else { 59 | proxyPasswd = System.getProperty("proxyPassword"); 60 | } 61 | } 62 | 63 | public static synchronized DefaultAuthenticator getAuthenticator() { 64 | if (instance == null) { 65 | instance = new DefaultAuthenticator(); 66 | Authenticator.setDefault(instance); 67 | } 68 | counter++; 69 | return instance; 70 | } 71 | 72 | public static synchronized void reset() { 73 | --counter; 74 | if (instance != null && counter == 0) { 75 | Authenticator.setDefault(systemAuthenticator); 76 | } 77 | } 78 | 79 | @Override 80 | protected PasswordAuthentication getPasswordAuthentication() { 81 | //If user sets proxy user and passwd and the RequestType is from proxy server then create 82 | // PasswordAuthentication using proxyUser and proxyPasswd; 83 | if ((getRequestorType() == RequestorType.PROXY) && proxyUser != null && proxyPasswd != null) { 84 | return new PasswordAuthentication(proxyUser, proxyPasswd.toCharArray()); 85 | } 86 | for (AuthInfo auth : authInfo) { 87 | if (auth.matchingHost(getRequestingURL())) { 88 | return new PasswordAuthentication(auth.getUser(), auth.getPassword().toCharArray()); 89 | } 90 | } 91 | return null; 92 | } 93 | 94 | /** 95 | * Proxy authorization string in form of username:password. 96 | * 97 | * @param proxyAuth Proxy authorization string 98 | */ 99 | public void setProxyAuth(String proxyAuth) { 100 | if (proxyAuth == null) { 101 | this.proxyUser = null; 102 | this.proxyPasswd = null; 103 | } else { 104 | int i = proxyAuth.indexOf(':'); 105 | if (i < 0) { 106 | this.proxyUser = proxyAuth; 107 | this.proxyPasswd = ""; 108 | } else if (i == 0) { 109 | this.proxyUser = ""; 110 | this.proxyPasswd = proxyAuth.substring(1); 111 | } else { 112 | this.proxyUser = proxyAuth.substring(0, i); 113 | this.proxyPasswd = proxyAuth.substring(i + 1); 114 | } 115 | } 116 | } 117 | 118 | public void setAuth(File f, Receiver l) { 119 | Receiver listener = l == null ? new DefaultRImpl() : l; 120 | BufferedReader in = null; 121 | FileInputStream fi = null; 122 | InputStreamReader is = null; 123 | try { 124 | String text; 125 | LocatorImpl locator = new LocatorImpl(); 126 | locator.setSystemId(f.getAbsolutePath()); 127 | try { 128 | fi = new FileInputStream(f); 129 | is = new InputStreamReader(fi, StandardCharsets.UTF_8); 130 | in = new BufferedReader(is); 131 | } catch (FileNotFoundException e) { 132 | listener.onError(e, locator); 133 | return; 134 | } 135 | try { 136 | int lineno = 1; 137 | locator.setSystemId(f.getCanonicalPath()); 138 | while ((text = in.readLine()) != null) { 139 | locator.setLineNumber(lineno++); 140 | //ignore empty lines and treat those starting with '#' as comments 141 | if ("".equals(text.trim()) || text.startsWith("#")) { 142 | continue; 143 | } 144 | try { 145 | AuthInfo ai = parseLine(text); 146 | authInfo.add(ai); 147 | } catch (Exception e) { 148 | listener.onParsingError(text, locator); 149 | } 150 | } 151 | } catch (IOException e) { 152 | listener.onError(e, locator); 153 | LOGGER.log(Level.SEVERE, e.getMessage(), e); 154 | } 155 | } finally { 156 | try { 157 | if (in != null) { 158 | in.close(); 159 | } 160 | if (is != null) { 161 | is.close(); 162 | } 163 | if (fi != null) { 164 | fi.close(); 165 | } 166 | } catch (IOException ex) { 167 | LOGGER.log(Level.SEVERE, null, ex); 168 | } 169 | } 170 | } 171 | 172 | private AuthInfo parseLine(String text) throws Exception { 173 | URL url; 174 | try { 175 | url = new URL(text); 176 | } catch (MalformedURLException mue) { 177 | //possible cause of this can be that password contains 178 | //character which has to be encoded in URL, 179 | //such as '@', ')', '#' and few others 180 | //so try to recreate the URL with encoded string 181 | //between 2nd ':' and last '@' 182 | int i = text.indexOf(':', text.indexOf(':') + 1) + 1; 183 | int j = text.lastIndexOf('@'); 184 | String encodedUrl = 185 | text.substring(0, i) 186 | + URLEncoder.encode(text.substring(i, j), StandardCharsets.UTF_8) 187 | + text.substring(j); 188 | url = new URL(encodedUrl); 189 | } 190 | 191 | String authinfo = url.getUserInfo(); 192 | 193 | if (authinfo != null) { 194 | int i = authinfo.indexOf(':'); 195 | 196 | if (i >= 0) { 197 | String user = authinfo.substring(0, i); 198 | String password = authinfo.substring(i + 1); 199 | return new AuthInfo( 200 | new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile()), 201 | user, URLDecoder.decode(password, StandardCharsets.UTF_8)); 202 | } 203 | } 204 | throw new Exception(); 205 | } 206 | 207 | static Authenticator getCurrentAuthenticator() { 208 | return Utils.getCurrentAuthenticator(); 209 | } 210 | 211 | public interface Receiver { 212 | 213 | void onParsingError(String line, Locator loc); 214 | 215 | void onError(Exception e, Locator loc); 216 | } 217 | 218 | private static class DefaultRImpl implements Receiver { 219 | 220 | @Override 221 | public void onParsingError(String line, Locator loc) { 222 | System.err.println(getLocationString(loc) + ": " + line); 223 | } 224 | 225 | @Override 226 | public void onError(Exception e, Locator loc) { 227 | System.err.println(getLocationString(loc) + ": " + e.getMessage()); 228 | LOGGER.log(Level.SEVERE, e.getMessage(), e); 229 | } 230 | 231 | private String getLocationString(Locator l) { 232 | return "[" + l.getSystemId() + "#" + l.getLineNumber() + "]"; 233 | } 234 | } 235 | 236 | /** 237 | * Represents authorization information needed by 238 | * {@link DefaultAuthenticator} to authenticate access to remote resources. 239 | * 240 | * @author Vivek Pandey 241 | * @author Lukas Jungmann 242 | */ 243 | final static class AuthInfo { 244 | 245 | private final String user; 246 | private final String password; 247 | private final Pattern urlPattern; 248 | 249 | public AuthInfo(URL url, String user, String password) { 250 | String u = url.toExternalForm().replaceFirst("\\?", "\\\\?"); 251 | this.urlPattern = Pattern.compile(u.replace("*", ".*"), Pattern.CASE_INSENSITIVE); 252 | this.user = user; 253 | this.password = password; 254 | } 255 | 256 | public String getUser() { 257 | return user; 258 | } 259 | 260 | public String getPassword() { 261 | return password; 262 | } 263 | 264 | /** 265 | * Returns if the requesting host and port are associated with this 266 | * {@link AuthInfo} 267 | */ 268 | public boolean matchingHost(URL requestingURL) { 269 | return urlPattern.matcher(requestingURL.toExternalForm()).matches(); 270 | } 271 | } 272 | } 273 | -------------------------------------------------------------------------------- /istack-commons/buildtools/src/main/java/com/sun/istack/build/NameConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package com.sun.istack.build; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.Locale; 16 | import java.util.StringTokenizer; 17 | 18 | /** 19 | * Converts arbitrary strings into Java identifiers. 20 | * 21 | * @author 22 | * Kohsuke KAWAGUCHI 23 | */ 24 | public interface NameConverter 25 | { 26 | /** 27 | * converts a string into an identifier suitable for classes. 28 | * 29 | * In general, this operation should generate "NamesLikeThis". 30 | * @param token string to convert 31 | * @return converted token 32 | */ 33 | String toClassName( String token ); 34 | 35 | /** 36 | * converts a string into an identifier suitable for interfaces. 37 | * 38 | * In general, this operation should generate "NamesLikeThis". 39 | * But for example, it can prepend every interface with 'I'. 40 | * @param token string to convert 41 | * @return converted token 42 | */ 43 | String toInterfaceName( String token ); 44 | 45 | /** 46 | * converts a string into an identifier suitable for properties. 47 | * 48 | * In general, this operation should generate "NamesLikeThis", 49 | * which will be used with known prefixes like "get" or "set". 50 | * @param token string to convert 51 | * @return converted token 52 | */ 53 | String toPropertyName( String token ); 54 | 55 | /** 56 | * converts a string into an identifier suitable for constants. 57 | * 58 | * In the standard Java naming convention, this operation should 59 | * generate "NAMES_LIKE_THIS". 60 | * @param token string to convert 61 | * @return converted token 62 | */ 63 | String toConstantName( String token ); 64 | 65 | /** 66 | * Converts a string into an identifier suitable for variables. 67 | * 68 | * In general it should generate "namesLikeThis". 69 | * @param token string to convert 70 | * @return converted token 71 | */ 72 | String toVariableName( String token ); 73 | 74 | /** 75 | * Converts a namespace URI into a package name. 76 | * This method should expect strings like 77 | * "http://foo.bar.zot/org", "urn:abc:def:ghi" "", or even "###" 78 | * (basically anything) and expected to return a package name, 79 | * liks "org.acme.foo". 80 | * 81 | * @param namespaceUri ns uri to convert 82 | * @return converted uri 83 | */ 84 | String toPackageName( String namespaceUri ); 85 | 86 | /** 87 | * The name converter implemented by Code Model. 88 | * 89 | * This is the standard name conversion for JAXB. 90 | */ 91 | NameConverter standard = new Standard(); 92 | 93 | /** 94 | * Default implementation of {@link NameConverter}. 95 | */ 96 | class Standard extends NameUtil implements NameConverter { 97 | @Override 98 | public String toClassName(String s) { 99 | return toMixedCaseName(toWordList(s), true); 100 | } 101 | @Override 102 | public String toVariableName(String s) { 103 | return toMixedCaseName(toWordList(s), false); 104 | } 105 | @Override 106 | public String toInterfaceName( String token ) { 107 | return toClassName(token); 108 | } 109 | @Override 110 | public String toPropertyName(String s) { 111 | String prop = toClassName(s); 112 | // property name "Class" with collide with Object.getClass, 113 | // so escape this. 114 | if(prop.equals("Class")) 115 | prop = "Clazz"; 116 | return prop; 117 | } 118 | @Override 119 | public String toConstantName( String token ) { 120 | return super.toConstantName(token); 121 | } 122 | /** 123 | * Computes a Java package name from a namespace URI, 124 | * as specified in the spec. 125 | * 126 | * @param nsUri to convert 127 | * @return 128 | * null if it fails to derive a package name. 129 | */ 130 | @Override 131 | public String toPackageName( String nsUri ) { 132 | // remove scheme and :, if present 133 | // spec only requires us to remove 'http' and 'urn'... 134 | int idx = nsUri.indexOf(':'); 135 | String scheme = ""; 136 | if(idx>=0) { 137 | scheme = nsUri.substring(0,idx); 138 | if( scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("urn") ) 139 | nsUri = nsUri.substring(idx+1); 140 | } 141 | 142 | // tokenize string 143 | ArrayList tokens = tokenize( nsUri, "/: " ); 144 | if( tokens.isEmpty() ) { 145 | return null; 146 | } 147 | 148 | // remove trailing file type, if necessary 149 | if( tokens.size() > 1 ) { 150 | // for uri's like "www.foo.com" and "foo.com", there is no trailing 151 | // file, so there's no need to look at the last '.' and substring 152 | // otherwise, we loose the "com" (which would be wrong) 153 | String lastToken = tokens.get( tokens.size()-1 ); 154 | idx = lastToken.lastIndexOf( '.' ); 155 | if( idx > 0 ) { 156 | lastToken = lastToken.substring( 0, idx ); 157 | tokens.set( tokens.size()-1, lastToken ); 158 | } 159 | } 160 | 161 | // tokenize domain name and reverse. Also remove :port if it exists 162 | String domain = tokens.get( 0 ); 163 | idx = domain.indexOf(':'); 164 | if( idx >= 0) domain = domain.substring(0, idx); 165 | ArrayList r = reverse( tokenize( domain, scheme.equals("urn")?".-":"." ) ); 166 | if( r.get( r.size()-1 ).equalsIgnoreCase( "www" ) ) { 167 | // remove leading www 168 | r.remove( r.size()-1 ); 169 | } 170 | 171 | // replace the domain name with tokenized items 172 | tokens.addAll( 1, r ); 173 | tokens.remove( 0 ); 174 | 175 | // iterate through the tokens and apply xml->java name algorithm 176 | for( int i = 0; i < tokens.size(); i++ ) { 177 | 178 | // get the token and remove illegal chars 179 | String token = tokens.get( i ); 180 | token = removeIllegalIdentifierChars( token ); 181 | 182 | // this will check for reserved keywords 183 | if( !NameUtil.isJavaIdentifier( token ) ) { 184 | token = '_' + token; 185 | } 186 | 187 | tokens.set( i, token.toLowerCase(Locale.ENGLISH) ); 188 | } 189 | 190 | // concat all the pieces and return it 191 | return combine( tokens, '.' ); 192 | } 193 | 194 | 195 | private static String removeIllegalIdentifierChars(String token) { 196 | StringBuilder newToken = new StringBuilder(); 197 | for( int i = 0; i < token.length(); i++ ) { 198 | char c = token.charAt( i ); 199 | 200 | if( i ==0 && !Character.isJavaIdentifierStart( c ) ) { 201 | // prefix an '_' if the first char is illegal 202 | newToken.append('_').append(c); 203 | } else if( !Character.isJavaIdentifierPart( c ) ) { 204 | // replace the char with an '_' if it is illegal 205 | newToken.append( '_' ); 206 | } else { 207 | // add the legal char 208 | newToken.append( c ); 209 | } 210 | } 211 | return newToken.toString(); 212 | } 213 | 214 | 215 | private static ArrayList tokenize( String str, String sep ) { 216 | StringTokenizer tokens = new StringTokenizer(str,sep); 217 | ArrayList r = new ArrayList<>(); 218 | 219 | while(tokens.hasMoreTokens()) 220 | r.add( tokens.nextToken() ); 221 | 222 | return r; 223 | } 224 | 225 | private static ArrayList reverse( List a ) { 226 | ArrayList r = new ArrayList<>(); 227 | 228 | for( int i=a.size()-1; i>=0; i-- ) 229 | r.add( a.get(i) ); 230 | 231 | return r; 232 | } 233 | 234 | private static String combine( List r, char sep ) { 235 | StringBuilder buf = new StringBuilder(r.get(0)); 236 | 237 | for( int i=1; i