Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveIn throws FileNotFoundException #6

Closed
ghost opened this issue Aug 27, 2014 · 2 comments
Closed

saveIn throws FileNotFoundException #6

ghost opened this issue Aug 27, 2014 · 2 comments
Assignees
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Aug 27, 2014

Hi,

The sample code snippet throws FileNotFoundException. If the folder structure created manually (c:/app-classpath/sample/app) saveIn works successfully. I am not sure if this is a bug, should i create package structure manually?

Thanks

package sample.app;

import java.io.File;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.DynamicType.Unloaded;
import net.bytebuddy.instrumentation.FixedValue;
import net.bytebuddy.instrumentation.method.matcher.MethodMatchers;

public class Sample {

    public String test() {
        return null;
    }

    public static void main(String[] args) throws Exception {
        File file = new File("C:\\app-classpath");
        file.mkdir();
        ByteBuddy buddy = new ByteBuddy();
        Unloaded<Sample> unloaded = buddy
                                        .subclass(Sample.class)
                                        .method(MethodMatchers.named("test"))
                                        .intercept(FixedValue.value("test"))
                                        .make();
        unloaded.saveIn(file);
    }
}

Exception Message:

Exception in thread "main" java.io.FileNotFoundException: C:\app-classpath\sample\app\Sample$ByteBuddy$314824326.class (No such file or directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:206)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:156)
    at net.bytebuddy.dynamic.DynamicType$Default.saveIn(DynamicType.java:1289)
    at sample.app.Sample.main(Sample.java:25)

Environment:
Windows 8.1
Java 1.8.0_20-b26

@raphw raphw added the bug label Aug 27, 2014
@raphw raphw added this to the 0.3 milestone Aug 27, 2014
@raphw raphw self-assigned this Aug 27, 2014
@raphw
Copy link
Owner

raphw commented Aug 27, 2014

It's a bug. Thanks for reporting. Its gonna be fixed with the 0.3 release which is due in September.

@raphw
Copy link
Owner

raphw commented Sep 16, 2014

Fixed in version 0.3

@raphw raphw closed this as completed Sep 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant