Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1329836

Summary: groovyc runs afoul of security manager
Product: Red Hat Enterprise Linux 7 Reporter: Luke Meyer <lmeyer>
Component: groovyAssignee: Java maintainers <java-maint>
Status: CLOSED WORKSFORME QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: msimacek
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-27 15:36:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luke Meyer 2016-04-23 17:19:42 UTC
Description of problem:

I have a simple groovy file with

println System.getProperty("java.class.path")

If I run it with groovy, it runs as expected. If I try to compile with groovyc, it has an exception.


Version-Release number of selected component (if applicable):
groovy-1.8.9-7


Steps to Reproduce:
1. echo 'println System.getProperty("java.class.path")' > info.groovy
2. groovy info.groovy
3. groovyc info.groovy

Actual results:
$ groovy info.groovy 
/usr/share/java/ant.jar:/usr/share/java/ant/ant-junit.jar:/usr/share/java/ant-launcher.jar:/usr/share/java/antlr.jar:/usr/share/java/objectweb-asm/asm.jar:/usr/share/java/objectweb-asm/asm-analysis.jar:/usr/shar
e/java/objectweb-asm/asm-tree.jar:/usr/share/java/objectweb-asm/asm-util.jar:/usr/share/java/bsf.jar:/usr/share/java/commons-cli.jar:/usr/share/java/commons-logging.jar:/usr/share/java/groovy.jar:/usr/share/java
/ivy.jar:/usr/share/java/jline.jar:/usr/share/java/jsp.jar:/usr/share/java/junit.jar:/usr/share/java/servlet.jar:/usr/share/java/xstream.jar:/usr/share/java/jansi.jar
However, groovyc chokes on it:

$ groovyc info.groovy                                                                                                                                                         [19/472]
>>> a serious error occurred: BUG! exception in phase 'semantic analysis' in source unit 'info.groovy' Prohibited package name: java.lang
>>> stacktrace:
BUG! exception in phase 'semantic analysis' in source unit 'info.groovy' Prohibited package name: java.lang
        at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:850)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:550)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:499)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:482)
        at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60)
        at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216)
        at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:149)
        at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:179)
        at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Caused by: java.lang.SecurityException: Prohibited package name: java.lang
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:661)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:797)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:152)
        at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:124)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:692)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:560)
        at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:183)
[...]

Expected results:
groovyc should compile this.

Additional info:
$ groovy -version
Groovy Version: 1.8.9 JVM: 1.7.0_99 Vendor: Oracle Corporation OS: Linux
$ java -version
java version "1.7.0_99"
OpenJDK Runtime Environment (rhel-2.6.5.0.el7_2-x86_64 u99-b00)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

Comment 2 Michael Simacek 2016-04-27 08:50:21 UTC
I cannot reproduce the issue using the data provided. The file compiles without any exceptions on freshly installed RHEL 7.2 using the same version of groovy. I also tried multiple builds of JDK 7. Do you have any additional data about differences from default installation?

Comment 3 Luke Meyer 2016-04-27 15:36:56 UTC
Thanks for looking into this. Now I can't reproduce it either. Must have been something strange about that particular system. Sorry for the noise!