Search in sources :

Example 41 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class InteropTests method testIopRefinesDefaultAccessMethodInAnotherPkg.

@Test
public void testIopRefinesDefaultAccessMethodInAnotherPkg() {
    compile("access/JavaAccessModifiers.java");
    assertErrors("RefinesDefaultAccessMethodInAnotherPkg", new CompilerError(27, "refined declaration is not visible: 'defaultAccessMethod' in 'RefinesDefaultAccessMethodInAnotherPkg' refines 'defaultAccessMethod' in 'JavaAccessModifiers' which is package private"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 42 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class InteropTests method testIopCallsDefaultAccessMethodInAnotherPkg.

@Test
public void testIopCallsDefaultAccessMethodInAnotherPkg() {
    compile("access/JavaAccessModifiers.java");
    assertErrors("CallsDefaultAccessMethodInAnotherPkg", new CompilerError(25, "method or attribute is not visible: 'protectedAccessMethod' of type 'JavaAccessModifiers' is protected"), new CompilerError(27, "method or attribute is not visible: 'defaultAccessMethod' of type 'JavaAccessModifiers' is package private"), new CompilerError(36, "function or value is not visible: 'defaultAccessMethod' is package private"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 43 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class InteropTests method testIopRefinesDefaultAccessMethodWithActual.

@Test
public void testIopRefinesDefaultAccessMethodWithActual() {
    compile("access/JavaAccessModifiers.java");
    assertErrors("access/RefinesDefaultAccessMethodWithActual", new CompilerError(22, "actual declaration must be shared: 'defaultAccessMethod'"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 44 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class CMRTests method testMdlCarWithInvalidSHA1.

@Ignore("See https://github.com/ceylon/ceylon/issues/6027")
@Test
public void testMdlCarWithInvalidSHA1() throws IOException {
    compile("modules/single/module.ceylon");
    File carFile = getModuleArchive("org.eclipse.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    // just to be sure
    ZipEntry moduleClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/$module_.class");
    assertNotNull(moduleClass);
    car.close();
    // now let's break the SHA1
    File shaFile = getArchiveName("org.eclipse.ceylon.compiler.java.test.cmr.modules.single", "6.6.6", destDir, "car.sha1");
    Writer w = new FileWriter(shaFile);
    w.write("fubar");
    w.flush();
    w.close();
    // now try to compile the subpackage with a broken SHA1
    String carName = "/org/eclipse/ceylon/compiler/java/test/cmr/modules/single/6.6.6/org.eclipse.ceylon.compiler.java.test.cmr.modules.single-6.6.6.car";
    carName = carName.replace('/', File.separatorChar);
    assertErrors("modules/single/subpackage/Subpackage", new CompilerError(-1, "Module car " + carName + " obtained from repository " + (new File(destDir).getAbsolutePath()) + " has an invalid SHA1 signature: you need to remove it and rebuild the archive, since it may be corrupted."));
}
Also used : ZipEntry(java.util.zip.ZipEntry) FileWriter(java.io.FileWriter) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Writer(java.io.Writer) FileWriter(java.io.FileWriter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 45 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class CMRTests method testMdlBug1062IncompatibleMissingImport.

@Test
public void testMdlBug1062IncompatibleMissingImport() throws IOException {
    // compile our java class
    File classesOutputFolder = new File(destDir + "-jar-classes");
    cleanCars(classesOutputFolder.getPath());
    classesOutputFolder.mkdirs();
    File jarOutputFolder = new File(destDir + "-jar");
    cleanCars(jarOutputFolder.getPath());
    jarOutputFolder.mkdirs();
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "1", new File(getPackagePath(), "modules/bug1062/javaA1-src"), new File[0], "bug1062/javaA/JavaA.java");
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "2", new File(getPackagePath(), "modules/bug1062/javaA2-src"), new File[0], "bug1062/javaA/JavaA.java");
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaB", "1", new File(getPackagePath(), "modules/bug1062/javaB-nomodule-src"), new File[] { new File(jarOutputFolder, "bug1062/javaA/1/bug1062.javaA-1.jar") }, "bug1062/javaB/JavaB.java");
    assertErrors("modules/bug1062/ceylon/test", Arrays.asList("-rep", jarOutputFolder.getPath()), null, new CompilerError(5, "could not determine type of method or attribute reference: 'method' of 'JavaB' is ambiguous - Error while loading the bug1062.javaB/1 module:\n" + "   Declaration 'bug1062.javaA.JavaA' could not be found in module 'bug1062.javaB' or its imported modules but was found in the non-imported module 'bug1062.javaA'"), new CompilerError(5, "parameter type could not be determined: 'arg0' of 'method' in 'JavaB' - Error while loading the bug1062.javaB/1 module:\n" + "   Declaration 'bug1062.javaA.JavaA' could not be found in module 'bug1062.javaB' or its imported modules but was found in the non-imported module 'bug1062.javaA'"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Aggregations

CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)55 Test (org.junit.Test)54 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)19 File (java.io.File)15 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)12 JarFile (java.util.jar.JarFile)11 ZipEntry (java.util.zip.ZipEntry)8 LinkedList (java.util.LinkedList)7 ZipFile (java.util.zip.ZipFile)5 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 JarOutputStream (java.util.jar.JarOutputStream)2 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)2 CompilationTask (org.eclipse.ceylon.javax.tools.JavaCompiler.CompilationTask)2 Ignore (org.junit.Ignore)2 HttpServer (com.sun.net.httpserver.HttpServer)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 TreeSet (java.util.TreeSet)1 JarEntry (java.util.jar.JarEntry)1