//
// END - LambdaAWSInfo
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// BEGIN - Private
//
350486
func validateSpartaPreconditions(lambdaAWSInfos []*LambdaAWSInfo,
	logger *logrus.Logger) error {

	var errorText []string
	collisionMemo := make(map[string]int)

	incrementCounter := func(keyName string) {
		_, exists := collisionMemo[keyName]
		if !exists {
			collisionMemo[keyName] = 1
		} else {
			collisionMemo[keyName] = collisionMemo[keyName] + 1
		}
	}
	// 0 - check for invalid signatures
	for _, eachLambda := range lambdaAWSInfos {
		validationErr := ensureValidSignature(eachLambda.userSuppliedFunctionName,
			eachLambda.handlerSymbol)
		if validationErr != nil {
			errorText = append(errorText, validationErr.Error())
		}
	}

	// 1 - check for duplicate golang function references.
	for _, eachLambda := range lambdaAWSInfos {
		incrementCounter(eachLambda.lambdaFunctionName())
		for _, eachCustom := range eachLambda.customResources {
			incrementCounter(eachCustom.userFunctionName)
		}
	}
	// Duplicates?
	for eachLambdaName, eachCount := range collisionMemo {
		if eachCount > 1 {
			logger.WithFields(logrus.Fields{
				"CollisionCount": eachCount,
				"Name":           eachLambdaName,
			}).Error("NewAWSLambda")
			errorText = append(errorText,
				fmt.Sprintf("Multiple definitions of lambda: %s", eachLambdaName))
		}
	}
	logger.WithFields(logrus.Fields{
		"CollisionMap": collisionMemo,
	}).Debug("Lambda collision map")

	if len(errorText) != 0 {
		return errors.New(strings.Join(errorText[:], "\n"))
	}
	// Check that the sysinfo package is installed. This
	// may not be installed on OSX, since it's excluded
	// via a build tag
	goPath := system.GoPath()

	// Check that the file exists
	sysinfoPath := filepath.Join(goPath, "src",
		"github.com",
		"zcalusic",
		"sysinfo",
		"sysinfo.go")
	logger.WithFields(logrus.Fields{
		"sysinfoPath": sysinfoPath,
	}).Debug("Checking installation status of github.com/zcalusic/sysinfo")
	_, sysinfoErr := os.Stat(sysinfoPath)
	if os.IsNotExist(sysinfoErr) {
		// Let's make sure it's really not there.
		// In case `gvm` is managing paths
		sysinfoErr = buildSysInfoSample(logger)
		if sysinfoErr != nil {
			logger.WithFields(logrus.Fields{
				"sysinfoMarkerPath": sysinfoPath,
				"os":                runtime.GOOS,
				"gopath":            goPath,
			}).Error("The `github.com/zcalusic/sysinfo` package is not installed")
			return errors.New("Please run `go get -u -v github.com/zcalusic/sysinfo` to install this Linux-only package. This package is used when cross-compiling your AWS Lambda binary and cannot be reliably imported across platforms. When you `go get` the package, you may see errors as in `undefined: syscall.Utsname`. These are expected and can be ignored")
		}
	}
	return nil
}
1306539
func (u *marshalInfo) computeMarshalInfo() {
	u.Lock()
	defer u.Unlock()
	if u.initialized != 0 { // non-atomic read is ok as it is protected by the lock
		return
	}

	t := u.typ
	u.unrecognized = invalidField
	u.extensions = invalidField
	u.v1extensions = invalidField
	u.sizecache = invalidField

	// If the message can marshal itself, let it do it, for compatibility.
	// NOTE: This is not efficient.
	if reflect.PtrTo(t).Implements(marshalerType) {
		u.hasmarshaler = true
		atomic.StoreInt32(&u.initialized, 1)
		return
	}

	// get oneof implementers
	var oneofImplementers []interface{}
	switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
	case oneofFuncsIface:
		_, _, _, oneofImplementers = m.XXX_OneofFuncs()
	case oneofWrappersIface:
		oneofImplementers = m.XXX_OneofWrappers()
	}

	n := t.NumField()

	// deal with XXX fields first
	for i := 0; i < t.NumField(); i++ {
		f := t.Field(i)
		if !strings.HasPrefix(f.Name, "XXX_") {
			continue
		}
		switch f.Name {
		case "XXX_sizecache":
			u.sizecache = toField(&f)
		case "XXX_unrecognized":
			u.unrecognized = toField(&f)
		case "XXX_InternalExtensions":
			u.extensions = toField(&f)
			u.messageset = f.Tag.Get("protobuf_messageset") == "1"
		case "XXX_extensions":
			u.v1extensions = toField(&f)
		case "XXX_NoUnkeyedLiteral":
			// nothing to do
		default:
			panic("unknown XXX field: " + f.Name)
		}
		n--
	}

	// normal fields
	fields := make([]marshalFieldInfo, n) // batch allocation
	u.fields = make([]*marshalFieldInfo, 0, n)
	for i, j := 0, 0; i < t.NumField(); i++ {
		f := t.Field(i)

		if strings.HasPrefix(f.Name, "XXX_") {
			continue
		}
		field := &fields[j]
		j++
		field.name = f.Name
		u.fields = append(u.fields, field)
		if f.Tag.Get("protobuf_oneof") != "" {
			field.computeOneofFieldInfo(&f, oneofImplementers)
			continue
		}
		if f.Tag.Get("protobuf") == "" {
			// field has no tag (not in generated message), ignore it
			u.fields = u.fields[:len(u.fields)-1]
			j--
			continue
		}
		field.computeMarshalFieldInfo(&f)
	}

	// fields are marshaled in tag order on the wire.
	sort.Sort(byTag(u.fields))

	atomic.StoreInt32(&u.initialized, 1)
}
447369
func (m *HeaderOrReference) ToRawInfo() interface{} {
	// ONE OF WRAPPER
	// HeaderOrReference
	// {Name:header Type:Header StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	v0 := m.GetHeader()
	if v0 != nil {
		return v0.ToRawInfo()
	}
	// {Name:reference Type:Reference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	v1 := m.GetReference()
	if v1 != nil {
		return v1.ToRawInfo()
	}
	return nil
}
244600
func main() {
	var memprofile, cpuprofile string
	flag.BoolVar(&debug, "d", debug, "Enable debug mode")
	flag.BoolVar(&carve, "c", carve, "Carve events from file")
	flag.BoolVar(&version, "V", version, "Show version and exit")
	flag.BoolVar(&timestamp, "t", timestamp, "Prints event timestamp (as int) at the beginning of line to make sorting easier")
	flag.BoolVar(&unordered, "u", unordered, "Does not care about ordering the events before printing (faster for large files)")
	flag.BoolVar(&statflag, "s", statflag, "Prints stats about events in files")
	flag.Int64Var(&offset, "o", offset, "Offset to start from (carving mode only)")
	flag.IntVar(&limit, "l", limit, "Limit the number of chunks to parse (carving mode only)")
	flag.Var(&start, "start", "Print logs starting from start")
	flag.Var(&stop, "stop", "Print logs before stop")

	flag.StringVar(&memprofile, "memprofile", "", "write memory profile to this file")
	flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to this file")

	flag.StringVar(&outType, "type", "", "Type of remote log collector. JSON-over-HTTP, JSON-over-TCP, Kafka")
	flag.StringVar(&outHttp, "http", "", "url for sending output to remote site over HTTP")
	flag.StringVar(&outTcp, "tcp", "", "tcp socket address for sending output to remote site over TCP")
	flag.StringVar(&brURL, "brURL", "", "Kafka Broker URL")
	flag.StringVar(&topic, "topic", "", "Kafka topic")
	flag.StringVar(&cID, "cID", "", "Kafka client ID")
	flag.StringVar(&tag, "tag", "", "special tag for matching purpose on remote collector")

	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage of %s: %[1]s [OPTIONS] FILES...\n", filepath.Base(os.Args[0]))
		flag.PrintDefaults()
	}

	flag.Parse()

	// Debug mode
	if debug {
		log.InitLogger(log.LDebug)
	}

	// version
	if version {
		fmt.Fprintf(os.Stderr, "%s\n%s\n%s\n", Version, Copyright, License)
		return
	}

	// Handle profiling functions
	if memprofile != "" {
		defer func() {
			f, err := os.Create(memprofile)
			if err != nil {
				log.LogErrorAndExit(err)
			}
			pprof.WriteHeapProfile(f)
			f.Close()
		}()
	}

	if cpuprofile != "" {
		f, err := os.Create(cpuprofile)
		if err != nil {
			log.LogErrorAndExit(err)
		}
		err = pprof.StartCPUProfile(f)
		if err != nil {
			log.LogErrorAndExit(err)
		}
		defer func() {
			pprof.StopCPUProfile()
			f.Close()
		}()
	}

	// init stats in case needed
	s := newStats()

	// init tcp sender if exists
	var out output.Output
	switch outType {
	case "http":
		httpOut := &output.HttpJSON{
			Url: outHttp,
			Tag: tag,
		}
		if err := httpOut.Open(outHttp); err != nil {
			log.Errorf("Can't init http conn", err)
		}
		out = httpOut
	case "tcp":
		tcpOut := &output.TcpJSON{
			Tag: tag,
		}
		if err := tcpOut.Open(outTcp); err != nil {
			log.Errorf("Can't init tcp conn", err)
		}
		out = tcpOut
	case "kafka":
		kafkaOut := &output.Kafka{
			BrokerURLs: brURL,
			Topic:      topic,
			ClientID:   cID,
			Tag:        tag,
		}
		if err := kafkaOut.Open(outHttp); err != nil {
			log.Errorf("Can't init Kafka conn", err)
		}
		out = kafkaOut
	}

	for _, evtxFile := range flag.Args() {
		switch {
		case carve:
		default:

		}
		if !carve {
			// Regular EVTX file
			ef, err := evtx.New(evtxFile)
			if err != nil {
				log.Error(err)
				continue
			}
			for e := range ef.FastEvents() {
				if statflag {
					// We update the stats
					s.update(e.Channel(), e.EventID())
				} else {
					// We print events
					if outType != "" {
						out.Request(e)
					} else {
						printEvent(e)
					}
				}
			}
		} else {
			evtx.SetModeCarving(true)
			// We have to carve the file
			carveFile(evtxFile, offset, limit)
		}
	}

	// We print the stats if needed
	if statflag {
		s.print()
	}
}
618123
func HandleAWSLambda(functionName string,
	lambdaHandler interface{},
	roleNameOrIAMRoleDefinition interface{}) *LambdaAWSInfo {

	lambda, lambdaErr := NewAWSLambda(functionName, lambdaHandler, roleNameOrIAMRoleDefinition)
	if lambdaErr != nil {
		panic(lambdaErr)
	}
	lambda.deprecationNotices = append(lambda.deprecationNotices, "sparta.HandleAWSLambda is deprecated starting with v1.6.0. Prefer sparta.NewAWSLambda(...)")
	return lambda
}
1255753
func main() {
	app := iris.New()
	app.Use(cw.New("us-east-1", "test").ServeHTTP)

	app.Get("/", func(ctx iris.Context) {
		put := cw.GetPutFunc(ctx)

		put([]*cloudwatch.MetricDatum{
			{
				MetricName: aws.String("MyMetric"),
				Dimensions: []*cloudwatch.Dimension{
					{
						Name:  aws.String("ThingOne"),
						Value: aws.String("something"),
					},
					{
						Name:  aws.String("ThingTwo"),
						Value: aws.String("other"),
					},
				},
				Timestamp: aws.Time(time.Now()),
				Unit:      aws.String("Count"),
				Value:     aws.Float64(42),
			},
		})

		ctx.StatusCode(iris.StatusOK)
		ctx.Text("success!\n")
	})

	// http://localhost:8080
	// should give: NoCredentialProviders
	// which is correct, you have to authorize your aws, we asumme that you know how to.
	app.Run(iris.Addr(":8080"))
}
485043
func ContextInfo(path string, lineNumber int) ([]string, int, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, -1, err
	}

	data, err := ioutil.ReadAll(file)
	if err != nil {
		return nil, -1, err
	}

	// We split on linebreak to get the lines.
	lines := strings.Split(string(data), "\n")

	// We try to get at most the 7 preceding lines.
	start := lineNumber - 7
	if start < 0 {
		start = 0
	}

	// Similar to the preceding lines, we also try for at most the 7 proceding
	// lines.
	end := lineNumber + 7
	if end >= len(lines) {
		end = len(lines) - 1
	}

	return lines[start:end], lineNumber - start, nil
}
1032102
func (m *OauthFlow) ToRawInfo() interface{} {
	info := yaml.MapSlice{}
	if m == nil {
		return info
	}
	if m.AuthorizationUrl != "" {
		info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl})
	}
	if m.TokenUrl != "" {
		info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl})
	}
	if m.RefreshUrl != "" {
		info = append(info, yaml.MapItem{Key: "refreshUrl", Value: m.RefreshUrl})
	}
	if m.Scopes != nil {
		info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()})
	}
	// &{Name:scopes Type:Strings StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.SpecificationExtension != nil {
		for _, item := range m.SpecificationExtension {
			info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()})
		}
	}
	// &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
	return info
}
217868
func (info *LambdaAWSInfo) lambdaFunctionName() string {
	if info.cachedLambdaFunctionName != "" {
		return info.cachedLambdaFunctionName
	}
	var lambdaFuncName string

	if info.Options != nil &&
		info.Options.SpartaOptions != nil &&
		info.Options.SpartaOptions.Name != "" {
		lambdaFuncName = info.Options.SpartaOptions.Name
	} else if info.userSuppliedFunctionName != "" {
		lambdaFuncName = info.userSuppliedFunctionName
	} else {
		// Using the default name, let's at least remove the
		// first prefix, since that's the SCM provider and
		// doesn't provide a lot of value...

		if info.handlerSymbol != nil {
			lambdaPtr := runtime.FuncForPC(reflect.ValueOf(info.handlerSymbol).Pointer())
			lambdaFuncName = lambdaPtr.Name()
		}

		// Split
		// cwd: /Users/mweagle/Documents/gopath/src/github.com/mweagle/SpartaHelloWorld
		// anonymous: github.com/mweagle/Sparta.(*StructHandler1).(github.com/mweagle/Sparta.handler)-fm
		//	RE==> var reSplit = regexp.MustCompile("[\\(\\)\\.\\*]+")
		// 	RESULT ==> Hello,[github com/mweagle/Sparta StructHandler1 github com/mweagle/Sparta handler -fm]
		// Same package: main.helloWorld
		// Other package, free function: github.com/mweagle/SpartaPython.HelloWorld

		// Grab the name of the function...
		structDefined := strings.Contains(lambdaFuncName, "(") || strings.Contains(lambdaFuncName, ")")
		otherPackage := strings.Contains(lambdaFuncName, "/")
		canonicalName := lambdaFuncName
		if structDefined {
			var reSplit = regexp.MustCompile(`[*\(\)\[\]]+`)
			// Function name:
			// github.com/mweagle/Sparta.(*StructHandler1).handler-fm
			parts := reSplit.Split(lambdaFuncName, -1)
			lastPart := parts[len(parts)-1]
			penultimatePart := lastPart
			if len(parts) > 1 {
				penultimatePart = parts[len(parts)-2]
			}
			intermediateName := fmt.Sprintf("%s-%s", penultimatePart, lastPart)
			reClean := regexp.MustCompile(`[\*\(\)]+`)
			canonicalName = reClean.ReplaceAllString(intermediateName, "")
		} else if otherPackage {
			parts := strings.Split(lambdaFuncName, "/")
			canonicalName = parts[len(parts)-1]
		}
		// Final sanitization
		// Issue: https://github.com/mweagle/Sparta/issues/63
		lambdaFuncName = sanitizedName(canonicalName)
	}
	// Cache it so we only do this once
	info.cachedLambdaFunctionName = lambdaFuncName
	return info.cachedLambdaFunctionName
}
172120
func (m *Oauth2AccessCodeSecurity) ToRawInfo() interface{} {
	info := yaml.MapSlice{}
	if m == nil {
		return info
	}
	// always include this required field.
	info = append(info, yaml.MapItem{Key: "type", Value: m.Type})
	// always include this required field.
	info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow})
	if m.Scopes != nil {
		info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()})
	}
	// &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	// always include this required field.
	info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl})
	// always include this required field.
	info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl})
	if m.Description != "" {
		info = append(info, yaml.MapItem{Key: "description", Value: m.Description})
	}
	if m.VendorExtension != nil {
		for _, item := range m.VendorExtension {
			info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()})
		}
	}
	// &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
	return info
}
82077
func (m *Parameter) ToRawInfo() interface{} {
	info := yaml.MapSlice{}
	if m.Id != "" {
		info = append(info, yaml.MapItem{Key: "id", Value: m.Id})
	}
	if m.Type != "" {
		info = append(info, yaml.MapItem{Key: "type", Value: m.Type})
	}
	if m.XRef != "" {
		info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef})
	}
	if m.Description != "" {
		info = append(info, yaml.MapItem{Key: "description", Value: m.Description})
	}
	if m.Default != "" {
		info = append(info, yaml.MapItem{Key: "default", Value: m.Default})
	}
	if m.Required != false {
		info = append(info, yaml.MapItem{Key: "required", Value: m.Required})
	}
	if m.Format != "" {
		info = append(info, yaml.MapItem{Key: "format", Value: m.Format})
	}
	if m.Pattern != "" {
		info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern})
	}
	if m.Minimum != "" {
		info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum})
	}
	if m.Maximum != "" {
		info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum})
	}
	if len(m.Enum) != 0 {
		info = append(info, yaml.MapItem{Key: "enum", Value: m.Enum})
	}
	if len(m.EnumDescriptions) != 0 {
		info = append(info, yaml.MapItem{Key: "enumDescriptions", Value: m.EnumDescriptions})
	}
	if m.Repeated != false {
		info = append(info, yaml.MapItem{Key: "repeated", Value: m.Repeated})
	}
	if m.Location != "" {
		info = append(info, yaml.MapItem{Key: "location", Value: m.Location})
	}
	if m.Properties != nil {
		info = append(info, yaml.MapItem{Key: "properties", Value: m.Properties.ToRawInfo()})
	}
	// &{Name:properties Type:Schemas StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.AdditionalProperties != nil {
		info = append(info, yaml.MapItem{Key: "additionalProperties", Value: m.AdditionalProperties.ToRawInfo()})
	}
	// &{Name:additionalProperties Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.Items != nil {
		info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()})
	}
	// &{Name:items Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.Annotations != nil {
		info = append(info, yaml.MapItem{Key: "annotations", Value: m.Annotations.ToRawInfo()})
	}
	// &{Name:annotations Type:Annotations StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	return info
}
935113
func main() {
	if len(os.Args) < 5 {
		log.Println("USAGE ERROR: go run concatenateObjects.go <region> <endpoint to database> <iam arn>")
		os.Exit(1)
	}

	awsRegion := os.Args[1]
	dbUser := os.Args[2]
	dbName := os.Args[3]
	dbEndpoint := os.Args[4]
	awsCreds := stscreds.NewCredentials(session.New(&aws.Config{Region: &awsRegion}), os.Args[5])
	authToken, err := rdsutils.BuildAuthToken(dbEndpoint, awsRegion, dbUser, awsCreds)

	// Create the MySQL DNS string for the DB connection
	// user:password@protocol(endpoint)/dbname?<params>
	dnsStr := fmt.Sprintf("%s:%s@tcp(%s)/%s?tls=true",
		dbUser, authToken, dbEndpoint, dbName,
	)

	driver := mysql.MySQLDriver{}
	_ = driver
	// Use db to perform SQL operations on database
	if _, err = sql.Open("mysql", dnsStr); err != nil {
		panic(err)
	}

	fmt.Println("Successfully opened connection to database")
}
305484
func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool CpupoolInfo) {
	err := Ctx.CheckOpen()
	if err != nil {
		return
	}

	var c_cpupool C.libxl_cpupoolinfo

	ret := C.libxl_cpupool_info(Ctx.ctx, &c_cpupool, C.uint32_t(Poolid))
	if ret != 0 {
		err = Error(-ret)
		return
	}
	defer C.libxl_cpupoolinfo_dispose(&c_cpupool)

	pool = c_cpupool.toGo()

	return
}
323447
func resourceAwsLambdaAliasUpdate(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).lambdaconn

	log.Printf("[DEBUG] Updating Lambda alias: %s:%s", d.Get("function_name"), d.Get("name"))

	params := &lambda.UpdateAliasInput{
		Description:     aws.String(d.Get("description").(string)),
		FunctionName:    aws.String(d.Get("function_name").(string)),
		FunctionVersion: aws.String(d.Get("function_version").(string)),
		Name:            aws.String(d.Get("name").(string)),
		RoutingConfig:   expandLambdaAliasRoutingConfiguration(d.Get("routing_config").([]interface{})),
	}

	_, err := conn.UpdateAlias(params)
	if err != nil {
		return fmt.Errorf("Error updating Lambda alias: %s", err)
	}

	return nil
}
859770
func (m *ParametersItem) ToRawInfo() interface{} {
	// ONE OF WRAPPER
	// ParametersItem
	// {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	v0 := m.GetParameter()
	if v0 != nil {
		return v0.ToRawInfo()
	}
	// {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	v1 := m.GetJsonReference()
	if v1 != nil {
		return v1.ToRawInfo()
	}
	return nil
}
681913
@Override
    public void visitLambda(JCLambda tree) {
        LambdaTranslationContext localContext = (LambdaTranslationContext)context;
        MethodSymbol sym = localContext.translatedSym;
        MethodType lambdaType = (MethodType) sym.type;

        {   /* Type annotation management: Based on where the lambda features, type annotations that
               are interior to it, may at this point be attached to the enclosing method, or the first
               constructor in the class, or in the enclosing class symbol or in the field whose
               initializer is the lambda. In any event, gather up the annotations that belong to the
               lambda and attach it to the implementation method.
            */

            Symbol owner = localContext.owner;
            apportionTypeAnnotations(tree,
                    owner::getRawTypeAttributes,
                    owner::setTypeAttributes,
                    sym::setTypeAttributes);


            boolean init;
            if ((init = (owner.name == names.init)) || owner.name == names.clinit) {
                owner = owner.owner;
                apportionTypeAnnotations(tree,
                        init ? owner::getInitTypeAttributes : owner::getClassInitTypeAttributes,
                        init ? owner::setInitTypeAttributes : owner::setClassInitTypeAttributes,
                        sym::appendUniqueTypeAttributes);
            }
            if (localContext.self != null && localContext.self.getKind() == ElementKind.FIELD) {
                owner = localContext.self;
                apportionTypeAnnotations(tree,
                        owner::getRawTypeAttributes,
                        owner::setTypeAttributes,
                        sym::appendUniqueTypeAttributes);
            }
        }

        //create the method declaration hoisting the lambda body
        JCMethodDecl lambdaDecl = make.MethodDef(make.Modifiers(sym.flags_field),
                sym.name,
                make.QualIdent(lambdaType.getReturnType().tsym),
                List.nil(),
                localContext.syntheticParams,
                lambdaType.getThrownTypes() == null ?
                    List.nil() :
                    make.Types(lambdaType.getThrownTypes()),
                null,
                null);
        lambdaDecl.sym = sym;
        lambdaDecl.type = lambdaType;

        //translate lambda body
        //As the lambda body is translated, all references to lambda locals,
        //captured variables, enclosing members are adjusted accordingly
        //to refer to the static method parameters (rather than i.e. acessing to
        //captured members directly).
        lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl));

        //Add the method to the list of methods to be added to this class.
        kInfo.addMethod(lambdaDecl);

        //now that we have generated a method for the lambda expression,
        //we can translate the lambda into a method reference pointing to the newly
        //created method.
        //
        //Note that we need to adjust the method handle so that it will match the
        //signature of the SAM descriptor - this means that the method reference
        //should be added the following synthetic arguments:
        //
        // * the "this" argument if it is an instance method
        // * enclosing locals captured by the lambda expression

        ListBuffer<JCExpression> syntheticInits = new ListBuffer<>();

        if (localContext.methodReferenceReceiver != null) {
            syntheticInits.append(localContext.methodReferenceReceiver);
        } else if (!sym.isStatic()) {
            syntheticInits.append(makeThis(
                    sym.owner.enclClass().asType(),
                    localContext.owner.enclClass()));
        }

        //add captured locals
        for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) {
            if (fv != localContext.self) {
                JCTree captured_local = make.Ident(fv).setType(fv.type);
                syntheticInits.append((JCExpression) captured_local);
            }
        }
        // add captured outer this instances (used only when `this' capture itself is illegal)
        for (Symbol fv : localContext.getSymbolMap(CAPTURED_OUTER_THIS).keySet()) {
            JCTree captured_local = make.QualThis(fv.type);
            syntheticInits.append((JCExpression) captured_local);
        }

        //then, determine the arguments to the indy call
        List<JCExpression> indy_args = translate(syntheticInits.toList(), localContext.prev);

        //build a sam instance using an indy call to the meta-factory
        int refKind = referenceKind(sym);

        //convert to an invokedynamic call
        result = makeMetafactoryIndyCall(context, refKind, sym, indy_args);
    }
652293
func (m *OauthFlows) ToRawInfo() interface{} {
	info := yaml.MapSlice{}
	if m == nil {
		return info
	}
	if m.Implicit != nil {
		info = append(info, yaml.MapItem{Key: "implicit", Value: m.Implicit.ToRawInfo()})
	}
	// &{Name:implicit Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.Password != nil {
		info = append(info, yaml.MapItem{Key: "password", Value: m.Password.ToRawInfo()})
	}
	// &{Name:password Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.ClientCredentials != nil {
		info = append(info, yaml.MapItem{Key: "clientCredentials", Value: m.ClientCredentials.ToRawInfo()})
	}
	// &{Name:clientCredentials Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.AuthorizationCode != nil {
		info = append(info, yaml.MapItem{Key: "authorizationCode", Value: m.AuthorizationCode.ToRawInfo()})
	}
	// &{Name:authorizationCode Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
	if m.SpecificationExtension != nil {
		for _, item := range m.SpecificationExtension {
			info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()})
		}
	}
	// &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
	return info
}