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 extends T> 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 | [](https://github.com/eclipse-ee4j/jaxb-istack-commons/actions/workflows/maven.yml?branch=master)
12 | [](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