Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to compile with Java 17 #4014

Draft
wants to merge 12 commits into
base: 4.10.x
Choose a base branch
from
28 changes: 16 additions & 12 deletions core/feature-manager/org.wso2.carbon.feature.mgt.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId>
<exclusions>
<exclusion>
<groupId>org.wso2.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</exclusion>
<exclusion>
Expand All @@ -68,7 +68,7 @@
<artifactId>org.eclipse.equinox.http.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.jsp.jasper</artifactId>
</exclusion>
<exclusion>
Expand All @@ -90,39 +90,39 @@
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.director</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata.repository</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.simpleconfigurator</artifactId>
</dependency>
<dependency>
Expand Down Expand Up @@ -162,6 +162,10 @@
<Export-Package>
org.wso2.carbon.feature.mgt.core.*
</Export-Package>
<!-- TODO this is wrong. Just trying out -->
<Provide-Capability>
osgi.service;objectClass=org.eclipse.equinox.p2.core.IProvisioningAgentProvider
</Provide-Capability>
</instructions>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@
<artifactId>org.wso2.carbon.feature.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions core/feature-manager/org.wso2.carbon.p2.touchpoint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

<dependencies>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.equinox</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
</dependency>
</dependencies>
Expand Down
17 changes: 8 additions & 9 deletions core/javax.cache/src/main/java/javax/cache/CacheManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

package javax.cache;

import javax.transaction.UserTransaction;

/**
* A CacheManager is used for looking up Caches and controls their lifecycle. It represents a collection of caches.
* <p/>
Expand Down Expand Up @@ -127,13 +125,14 @@ public interface CacheManager {
*/
boolean removeCache(String cacheName);

/**
* This method will return a UserTransaction.
*
* @return the UserTransaction.
* @throws UnsupportedOperationException if JTA is not supported
*/
UserTransaction getUserTransaction();
// TODO javax.transaction package is no longer available. Need to find a way to add this back
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javax.transaction is not available with JDK 17. Since this seems to be not used, removed. But need to validate the functionality.

// /**
// * This method will return a UserTransaction.
// *
// * @return the UserTransaction.
// * @throws UnsupportedOperationException if JTA is not supported
// */
// UserTransaction getUserTransaction();

/**
* Indicates whether a optional feature is supported by this CacheManager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
*/
package org.wso2.carbon.caching.impl;

import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;

import javax.cache.Cache;
import javax.cache.CacheBuilder;
import javax.cache.CacheException;
import javax.cache.CacheManager;
import javax.cache.OptionalFeature;
import javax.cache.Status;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.cache.Cache;
import javax.cache.CacheBuilder;
import javax.cache.CacheException;
import javax.cache.CacheManager;
import javax.cache.OptionalFeature;
import javax.cache.Status;

import static org.wso2.carbon.caching.impl.CachingConstants.ILLEGAL_STATE_EXCEPTION_MESSAGE;

/**
Expand Down Expand Up @@ -202,13 +203,13 @@ boolean removeLocalCaches() {
return this.caches.isEmpty();
}

@Override
public javax.transaction.UserTransaction getUserTransaction() {
Util.checkAccess(ownerTenantDomain, ownerTenantId);
checkStatusStarted();
touch();
return null; //To change body of implemented methods use File | Settings | File Templates.
}
// @Override
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javax.transaction is not available with JDK 17. Since this seems to be not used, removed. But need to validate the functionality.

// public javax.transaction.UserTransaction getUserTransaction() {
// Util.checkAccess(ownerTenantDomain, ownerTenantId);
// checkStatusStarted();
// touch();
// return null; //To change body of implemented methods use File | Settings | File Templates.
// }

@Override
public boolean isSupported(OptionalFeature optionalFeature) {
Expand Down
2 changes: 1 addition & 1 deletion core/org.wso2.carbon.application.deployer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.eclipse.osgi</groupId>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
Expand Down
14 changes: 12 additions & 2 deletions core/org.wso2.carbon.base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>

<extensions>true</extensions>
<configuration>
<instructions>
Expand All @@ -48,7 +47,7 @@
org.wso2.carbon.base.*; version="1.0.0"
</Export-Package>
<Import-Package>
javax.activation.*;version="[0.0.0, 1.0.0)",
javax.activation.*;version="[1.0.0, 2.0.0)",
javax.servlet; version="${imp.pkg.version.javax.servlet}",
javax.servlet.http; version="${imp.pkg.version.javax.servlet}",
org.wso2.securevault.*,
Expand All @@ -59,6 +58,9 @@
<Import-Package>
*;resolution:=optional
</Import-Package>
<Provide-Capability>
osgi.service;objectClass=org.wso2.carbon.base.api.ServerConfigurationService
</Provide-Capability>
</instructions>
</configuration>
</plugin>
Expand All @@ -67,12 +69,19 @@
<artifactId>maven-surefire-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<argLine>
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
</argLine>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.wso2.org.ops4j.pax.logging:pax-logging-api</classpathDependencyExclude>
</classpathDependencyExcludes>
<systemPropertyVariables>
<java.util.logging.manager>org.apache.logging.log4j.jul.LogManager</java.util.logging.manager>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -118,6 +127,7 @@
<groupId>org.eclipse.equinox</groupId>
<artifactId>javax.servlet</artifactId>
</dependency>

<dependency>
<groupId>org.wso2.orbit.xerces</groupId>
<artifactId>xercesImpl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.impl.Constants;
import org.apache.xerces.util.SecurityManager;
import org.osgi.service.component.annotations.Component;
import org.w3c.dom.Element;
import org.wso2.carbon.base.api.ServerConfigurationService;
import org.wso2.carbon.securevault.SecretManagerInitializer;
Expand Down Expand Up @@ -55,6 +56,7 @@
* This class stores the configuration of the Carbon Server.
*/
@SuppressWarnings("unused")
//@Component(service = ServerConfigurationService.class)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

public class ServerConfiguration implements ServerConfigurationService {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wso2.carbon.base.api;

import org.osgi.service.component.annotations.Component;
import org.w3c.dom.Element;

public interface ServerConfigurationService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.wso2.carbon.base.CarbonBaseConstants;
import org.wso2.carbon.base.CarbonBaseUtils;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.base.ServerConfigurationException;
import org.wso2.carbon.base.api.ServerConfigurationService;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletException;
import java.io.*;

/**
* Activator of the {@link org.wso2.carbon.base} bundle
Expand All @@ -52,7 +55,6 @@ public void start(BundleContext bundleContext) throws Exception {
System.setProperty("portOffset", portOffset);
//register carbon server confg as an OSGi service
registration = bundleContext.registerService(ServerConfigurationService.class.getName(), carbonServerConfiguration, null);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setSecurityManager() {
String resourcePath = resourceURL.getPath();
resourcePath = resourcePath + "policy-test.policy";
System.setProperty("java.security.policy", resourcePath);
System.setSecurityManager(new SecurityManager());
// System.setSecurityManager(new SecurityManager());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security manager not working properly with Java 17. Hence need to get rid of security manager.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void createInstance() throws ServerConfigurationException, NoSuchFieldExc
IllegalAccessException {
assertFalse(getIsInitialized(ServerConfiguration.getInstance(), "isInitialized"));
InputStream inputStream = readFile("carbon.xml");
//TODO carbon.home is not set
ServerConfiguration.getInstance().forceInit(inputStream);
assertTrue(getIsInitialized(ServerConfiguration.getInstance(), "isInitialized"));
}
Expand Down
32 changes: 32 additions & 0 deletions core/org.wso2.carbon.base/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Carbon-Kernel-Core_Test-Suite">
<test name="carbon-core-unit-tests" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.carbon.base.CarbonApplicationContextHolderBaseTest" />
<class name="org.wso2.carbon.base.CarbonBaseUtilsTest" />
<!-- <class name="org.wso2.carbon.base.CarbonBaseUtilsWithIncorrectSecPolicy" />-->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security manager related functionality is not working with JDK 17.

<class name="org.wso2.carbon.base.CarbonContextHolderBaseTest" />
<!-- <class name="org.wso2.carbon.base.ServerConfigurationTest" />-->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was working incorrectly before. Due to a new validation added in Files API, this is failing now.

</classes>
</test>
</suite>
Loading