RE: The field StringPool.SLASH is deprecated

Roc Vidal, modified 4 Years ago. New Member Posts: 5 Join Date: 9/16/20 Recent Posts

Hi, I have imported a project into Liferay developer studio and appear some java errors like this:

 

The field StringPool.SLASH is deprecated

on this code:

for(String val : orderValue.split("###")){
                    if(val.contains(StringPool.SLASH)){
                        // parent category
                        String category = val.substring(0 , val.indexOf(StringPool.SLASH));
                        
                        // order per catalog
                        String order = val.substring(val.indexOf(StringPool.SLASH)+1);
                        

 

How can I update this code?

thumbnail
Roc Vidal, modified 4 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

1. this is a deprecation warning, not an error. You can just leave it as is, or ignore it.

2. Which version are you talking about? I've checked the DXP 7.3 source code, and don't see deprecation there

3. What I see in that code is

public static final String SLASH = FORWARD_SLASH;

 - so you might want to be more explicit than "slash" and explicitly reference "forward-slash" as opposed to backslash

Of course, you can always test for "/" occurrences.

Roc Vidal, modified 4 Years ago. New Member Posts: 5 Join Date: 9/16/20 Recent Posts

Ok. My version is liferay-commerce-2.0.5

 

Thanks for your response.

thumbnail
Eric D, modified 15 Days ago. Junior Member Posts: 59 Join Date: 3/25/16 Recent Posts

May be it is because StringPool is now in the package com.liferay.petra.string.StringPool.

The dependency is now : 

        <dependency>
            <groupId>com.liferay</groupId>
            <artifactId>com.liferay.petra.string</artifactId>
            <scope>provided</scope>
        </dependency>

The 6.2 class com.liferay.portal.kernel.util.StringPool is deprecated.

When Liferay move classes from the kernel to a module, the older classes are first deprecated and after they are deleted.