Katalon Studio ignores java access modifiers

Hi there :slight_smile:

I currently analyze Katalon Studio and it’s capabilities to manage java code in keyword files. When I was playing around with access modifiers (private, protected, public, package private) I got the feeling, Katalon Studio sometimes ignores these modifiers. This would lead to polluted namespaces in the end, I believe.

Let me show you two examples.

  1. I have packages “a” and “b” and a class “A” in package “a” and a class “B” in package “b”. Class “B” is package private. I can still see it and call it’s methods from class “A”.
  2. I have two classes “A” and “B” again. “A” contains a private method. It seems, “B” can call it without problems.

The access modifiers seem to be respected when it comes to private classes. It seems, I can’t access those from different classes and I get an IllegalAccessException - this seems ok.

As we intend to make heavy use of Katalon Studio’s scripting capabilities I’m a bit worried, our namespaces would get too crowded. Could somebody please tell me what’s going on here and if I can somehow get Katalon Studio to behave as the java specification commands? Could this maybe be a bunch of bugs?

I generally go snow-blind trying to follow A, a, B, b, package, class, method stuff. That’s not your fault, that’s all me. :upside_down_face:

The script is written in Groovy not Java.


The Apache Groovy programming language - Differences with Java

Also,

https://dzone.com/articles/groovy-goodness-using-package

3 Likes

Ahh, thank you very much, that was a really good hint! I wasn’t aware of such big differences between java and groovy and will research that area in more detail now to resolve the remaining question (Why does the groovy script accesses private methods in a way, that java regards as illegal?).

Answered so far is the question, why package privacy doesn’t seem to work.
Solution: Missing access modifier in groovy is not package private, but you have to add the @PackageScope annotation.

Thanks a lot so far! I will get back here with my results.

Ok, after a bit more research: It’s a (horrible) major bug in groovy, that is known for quite some time now. The “private” access modifier is completely ignored.
See this (and many posts on stackoverflow, for example) for more information.

1 Like

Great detective work. And thanks for posting your results :sunglasses:

1 Like