Reason: BUG! exception in phase 'semantic analysis' in source unit

The below simple line of code is failing in Katalon v5.9, v5.9.1, v5.10 (Beta), but works fine in v7.1

Katalon team … Could you please explain why ??? is this happening. I want to correct myself :grinning:

But this :imp: issue really screwed me up for more than a week.

To solve this issue, remove static from the method.

import java.text.SimpleDateFormat as SimpleDateFormat

System.err.println datefnWithTime()

static String datefnWithTime() {
String pattern = “dd-MMM-yyyy hh:mm:ss”
SimpleDateFormat format = new SimpleDateFormat(pattern)
return format.format(new Date())
}

while copy pasting this piece of code, delete the double quote and type again “dd-MMM-yyyy hh:mm:ss”

2 Likes

Let me explain what I have done, what I think.

I made a 15451.groovy file which contains just the same lines as you presented above. And I executed it with groovy command in command-line.

kazurayam@N01-0370 MINGW64 ~/tmp
$ cat 15451.groovy
import java.text.SimpleDateFormat as SimpleDateFormat

System.err.println datefnWithTime()

static String datefnWithTime() {
       String pattern = "dd-MMM-yyyy hh:mm:ss"
       SimpleDateFormat format = new SimpleDateFormat(pattern)
       return format.format(new Date())
}
kazurayam@N01-0370 MINGW64 ~/tmp
$ groovy 15451.groovy
14-Dec-2018 09:48:51

This worked fine. This proves your script is just legal, has no problem as a Groovy script.

I made a Test Case in a new Katalon Studio project, copied & pasted your script into it, ran it, and got a error:

12-14-2018 09:25:47 AM Test Cases/TC1

Elapsed time: 0.435s

Test Cases/TC1 FAILED.
Reason:
BUG! exception in phase 'semantic analysis' in source unit 'file:/C:/Users/qcq0264/katalon-workspace/KatalonForum15451/Scripts/TC1/Script1544747107739.groovy' ClassNode#getTypeClass for Script1544747107739 is called before the type class is set 
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:252)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:181)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:292)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:185)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:274)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:183)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:101)
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:71)
	at com.kms.katalon.core.ast.AstTestStepTransformation.getKeywordNameForStatement(AstTestStepTransformation.groovy:306)
	at com.kms.katalon.core.ast.AstTestStepTransformation.visit(AstTestStepTransformation.groovy:254)
	at com.kms.katalon.core.ast.AstTestStepTransformation.visit(AstTestStepTransformation.groovy:78)
	at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:321)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:312)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:291)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:283)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:222)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1544747144293.run(TempTestCase1544747144293.groovy:22)

Among the lines I got interested in the line:

ClassNode#getTypeClass for Script1544747107739 is called before the type class is set 
	at com.kms.katalon.core.ast.AstTextValueUtil.getTextValue(AstTextValueUtil.java:252)

This line firmly tells you that the method getTextValue of the class com.kms.katalon.core.ast.AstTextValueUtil is calling the getTypeClass method of the org.codehaus.groovy.ast.ClassNode class.

You can read the api document here:

The document tells you as follows:

public Class getTypeClass()
Returns the concrete class this classnode relates to. However, this method is inherently unsafe as it may return null depending on the compile phase you are using. AST transformations should never use this method directly, but rather obtain a new class node using getPlainNodeReference() .
Returns:
the class this classnode relates to. May return null.

this method is inherently unsafe as it may return null depending on the compile phase you are using” : I think this is the reason why we got “BUG! exception in phase ‘semantic analysis’ in source unit” message.

I want to point out that the document sais: “AST transformations should never use this method directly”. However, the StackTrace above clearly indicates that com.kms.katalon.core.ast.AstTextValueUtil.getTextValue is directly using the getTypeClass method. Katalon should not do this. I think this should be regarded as a bug.

By the way, ‘AST’ means “Abstract Syntax Tree”. See http://glaforge.appspot.com/article/groovy-ast-transformations-tutorials for Groovy’s internal magic.

3 Likes

:smiley: Thank KAZ for your in depth / detailed reply.

Katalon Team … Indeed You are doing a great Job. Keep up the good work. I believe this issue is worth fixing in 5.10 release … :wink:

Thank you @kazurayam @discover.selenium. I’ve reopened the topic for the team to investigate. Just to clarify, was removing static make things work properly for you?

Yes devalex : removing static solved the problem.

This is still an issue in Katalon 5.10.1

I am still struggling with this issue. Please fix this bug Katalon Team. It’s a major wall for me and my team at work.

Thanks for pointing out to remove static, this helped me get my code working again. Hopefully the Katalon team addresses this issue soon in a future update.

@duyluong @YoungNgo

This bug is still exist. I have developed a framework in speadsheet itself what Katalon doing in UI. I am following Katalon from 2018. Fix this issue ASAP. Because, if I create any method inside Test Case page with static keyword, it throwing error like cannot call TestCase. It is very main issue now.

This issue has been created on GitHub, you guys can follow via this link: https://github.com/katalon-studio/katalon-studio/issues/105. We hope KS v5.11 will fix this issue.

Many thanks to @discover.selenium and @kazurayam

This issue has been addressed in 6.1.2 beta.

This is still an issue in v6.2.1 not able to run test case using Cucumber keyword , getting “semantic analysis error”

I also getting the same error in KS.

import org.apache.poi.ss.util.CellRangeAddress
import org.apache.poi.xssf.usermodel.XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilter
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilterColumn

String fileName = "C:\\Users\\UserUser\\Katalon Studio\\ExcelJava\\Data Files\\MCCTest.xlsx";
InputStream input = new FileInputStream(fileName);

XSSFWorkbook wb = new XSSFWorkbook(input);
XSSFSheet sheet = wb.getSheet("MCC_File");

sheet.setAutoFilter(CellRangeAddress.valueOf("A1:D1"));

CTAutoFilter sheetFilter = sheet.getCTWorksheet().getAutoFilter();
CTFilterColumn filterColumn = sheetFilter.addNewFilterColumn();
filterColumn.setColId("1");
CTFilter filter = filterColumn.addNewFilters().insertNewFilter(0);
filter.setVal("AE");

FileOutputStream fos = new FileOutputStream(fileName);
wb.write(fos);
fos.close();

Reason:
BUG! exception in phase ‘semantic analysis’ in source unit ‘file:/C:/Users/a757721/Katalon%20Studio/ExcelJava/Scripts/ExcelTest/Script1567044814608.groovy’ class “org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter”'s signer information does not match signer information of other classes in the same package
at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1567046076609.run(TempTestCase1567046076609.groovy:21)
Caused by: java.lang.SecurityException: class “org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter”'s signer information does not match signer information of other classes in the same package
… 12 more

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.